Skip to main content
added 31 characters in body
Source Link
efru
  • 23
  • 5

Of course, these are just guesses. BTW, this behavior also happens when I useregardless of whether the --noplugins flag to startis present or not when vim is started.

Of course, these are just guesses. BTW, this behavior also happens when I use the --noplugins flag to start vim.

Of course, these are just guesses. BTW, this behavior happens regardless of whether the --noplugins flag is present or not when vim is started.

added 118 characters in body
Source Link
efru
  • 23
  • 5

I am attempting to write a vim function that I would like to be loaded automatically when vim starts, thus I am putting it in my vimrc. It should modify the currently edited file (eg abc.txtbut maybe that is wrong?). When called during normal editing, thenit should write thea modified version of the current buffer's contents to another file (eg abc_x.txt), and finallythen return me to my original file to continue editing abc.txtit. My verionversion of vim is 8.1.5126.

I am attempting to write a vim function in my vimrc. It should modify the currently edited file (eg abc.txt), then write the modified contents to another file (eg abc_x.txt), and finally return to continue editing abc.txt. My verion of vim is 8.1.5126.

I am attempting to write a vim function that I would like to be loaded automatically when vim starts, thus I am putting it in my vimrc (but maybe that is wrong?). When called during normal editing, it should write a modified version of the current buffer's contents to another file, and then return me to my original file to continue editing it. My version of vim is 8.1.5126.

added 14 characters in body
Source Link
efru
  • 23
  • 5
function! Write_new_file() " Hold the original and new file names in variables. let l:fn_no_ext = expand('%:p:r') let l:fn_ext = expand('%:e') let l:original_name = l:fn_no_ext.'.'.l:fn_ext let l:new_name = l:fn_no_ext.'_x.'.l:fn_ext " Save the current state of the current buffer to the original file. write " Assign a new file name to the current buffer. exe 'file '.l:new_name " Make all the modifications to the current buffer. call Many_Modifications() " Save the modified buffer to the new file. write! " Return to editing the original file. exe 'edit! '.l:original_name endfunction 
function! Write_new_file() " Hold the original and new file names in variables. let l:fn_no_ext = expand('%:p:r') let l:fn_ext = expand('%:e') let l:original_name = l:fn_no_ext.'.'.l:fn_ext let l:new_name = l:fn_no_ext.'_x.'.l:fn_ext " Save the current state of the original file. write " Assign a new file name to the current buffer. exe 'file '.l:new_name " Make all the modifications to the current buffer. call Many_Modifications() " Save the modified buffer to the new file. write! " Return to editing the original file. exe 'edit! '.l:original_name endfunction 
function! Write_new_file() " Hold the original and new file names in variables. let l:fn_no_ext = expand('%:p:r') let l:fn_ext = expand('%:e') let l:original_name = l:fn_no_ext.'.'.l:fn_ext let l:new_name = l:fn_no_ext.'_x.'.l:fn_ext " Save the state of the current buffer to the original file. write " Assign a new file name to the current buffer. exe 'file '.l:new_name " Make all the modifications to the current buffer. call Many_Modifications() " Save the modified buffer to the new file. write! " Return to editing the original file. exe 'edit! '.l:original_name endfunction 
deleted 58 characters in body
Source Link
efru
  • 23
  • 5
Loading
added 32 characters in body
Source Link
efru
  • 23
  • 5
Loading
added 34 characters in body
Source Link
efru
  • 23
  • 5
Loading
deleted 12 characters in body
Source Link
efru
  • 23
  • 5
Loading
added 90 characters in body
Source Link
efru
  • 23
  • 5
Loading
added 1230 characters in body; edited title
Source Link
efru
  • 23
  • 5
Loading
added 51 characters in body
Source Link
romainl
  • 45.7k
  • 5
  • 91
  • 129
Loading
Source Link
efru
  • 23
  • 5
Loading