I use :saveas
to move a file while maintaining its undo history. Most of the time I immediately delete the old file. So if I'm editing foo.txt
I'll issue
:saveas bar.txt
:!rm foo.txt
I wanted to make this into a single command, so I'm trying
command! -nargs=* Move :call delete(expand('%')) | saveas arg1
But if I issue
:Move bar.txt
instead it creates a new file called (literally) arg1
I'm guessing I misunderstand how arg1
works (and probably how |
works).
Is there a better way to do this anyway?