Quantcast
Channel: Active questions tagged user-commands - Vi and Vim Stack Exchange
Viewing all articles
Browse latest Browse all 60

How to create user command to delete current file and saveas to new file?

$
0
0

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?


Viewing all articles
Browse latest Browse all 60

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>