Saturday, 17 August 2013

How do you quit without saving when using vim -c flag

How do you quit without saving when using vim -c flag

I want to run something along the lines of
vim -r -c "w %.new | q!" ${filename}
However, the ! is parsed as the prefix for an external command. Similar
issues happen when using single quotes.
I could work around this with the following code, but it feels much less
clean or obvious than the previous code.
cp ${filename} ${filename}.new && mv ${filename}.swp ${filename}.new.swp;
vim -r -c "wq" ${filename}.new;

No comments:

Post a Comment