“Not an editor command: W” – How To Never See This Again!

Anyone who’s used vi or vim has probably stumbled into the error message “Not an editor command: W” while try to save in a rush. Since “:” enters command mode and you have to press Shift to type a colon, it’s really easy to then type a capital “W” instead of a lowercase one.

There’s an easy fix for this, though. In vim, user-defined commands always start with capital letters. You can define a command with the command command; it has the syntax command NewCommand whatever-you-would-have-typed-in-command-mode.

You can define a new command in your .vimrc:

command W w

This defines a new command, W, that does the same thing as w. With that in your .vimrc, you will never see “Not an editor command: W” again, because you just made what you intended to type an editor command. I first set this in my own .vimrc years ago, and I have never regret it once.


There are, of course, fun ways you could define this command. A fun prank might be:

command W q!

That’ll be really funny and a great way to get a good laugh!

Leave a Reply

Your email address will not be published. Required fields are marked *