Last Updated: February 25, 2016
·
1.714K
· jkirchartz

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.

5 Responses
Add your response

I prefer to use ZZ (2 keystrokes) instead of :wq enter (4 keystrokes)

over 1 year ago ·

:x

over 1 year ago ·

Another one? Seventh post about it?

over 1 year ago ·

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 :)

over 1 year ago ·

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.....

over 1 year ago ·