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:
- delete buffer
:bd bar.txt - perform move on shell
mv foo/bar.txt foo/bar2.txt - load file in vim
:e foo/bar2.txt
second solution:
- close vim, buffer closed.
- perform move on shell...
- 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
Post a Comment