Move File within Vim -


is there way move file within vim? e.g. opened file foo/bar.txt in vim. know 2 ways move file:

first solution:

  1. delete buffer :bd bar.txt
  2. perform move on shell mv foo/bar.txt foo/bar2.txt
  3. load file in vim :e foo/bar2.txt

second solution:

  1. close vim, buffer closed.
  2. perform move on shell...
  3. start vim , load file.

but these 2 solutions embarrassing. know, there plugin renaming files vim-enuch, isn't there vim way performing such basic functionality?

there no atomic way move file that, should close:

function! movefile(newspec)      let old = expand('%')      " improved:      if (old == a:newspec)          return 0      endif      exe 'sav' fnameescape(a:newspec)      call delete(old) endfunction  command! -nargs=1 -complete=file -bar movefile call movefile('<args>') 

now say:

:movefile file2.txt 

to rename file2.txt

:movefile %.0 

to move file2.txt file2.txt.0


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -