Prevent VIM write misfires
If you find yourself accidentally hitting :Wq
or :W
when you try to save, you'll have to try again, lets avoid these misfires by adding the following to your .vimrc file:
command W w
command Q q
command Wq wq
command WQ wq
These will map common misfires to the desired command.
Written by Joel Kirchartz
Related protips
5 Responses
I prefer to use ZZ (2 keystrokes) instead of :wq enter (4 keystrokes)

:x

Another one? Seventh post about it?

Maps like these are bad form; remember that not every server or machine you're on is going to have these maps and you're using them as a crutch. Don't fall over, now :)

indeed this is a "crutch", in-so-much as BASH aliases are too. It only avoids a minor annoyance on the device you set it on. If you're on a server where you haven't set it up no harm done you just have to try again & hope your fingers aren't so chubby this time.....