VIM stuff

February 24, 2009

linux

Today if removed two annoyances I had with VIM.

Command mistyping

I often mistype the following:

:w! becomes :W!

or

:q! becomes :Q!

Which is annoying because W and Q do not mean anything, and I don’t write or VIM does not quit. VIM has a nifty feature called commands which you can (re)define or add new commands.

Lets try some to fix this, in a running vi:

:com -bang W write!

or

:com -bang Q quit!

Now you can write :Q! and you will force quit.

But it will now always use the force variant because the bang (!). Well of course VIM would not be VIM, if there weren’t a solution:

:com -bang W write<bang>
:com -bang Q write<bang>

Mode has changed

This was the other annoyance

Warning: Mode of file "{filename}" has changed since editing started

Kill it with set autoread in your .vimrc. See :help W16 too.

None