sponsor Vim development Vim logo Vim Book Ad

basic Tip #22: handle common typos for :commands

 tip karma   Rating 22/14, Viewed by 2137 

created:   February 27, 2001 7:11      complexity:   basic
author:   [email protected]      as of Vim:   5.7

I frequently hold the shift key for too long when typing, for instance :wq, and end up with :Wq.  Vim then whines "Not an editor command: Wq"

In my .vimrc, I have taught vim my common typos:
command! Q  quit
command! W  write
command! Wq wq
" this one won't work, because :X is already a built-in command
command! X  xit

 rate this tip  Life Changing Helpful Unfulfilling 

<<easy pasting to windows apps | Vim xterm title >>

Additional Notes

[email protected], February 28, 2001 10:54
Or you can also do a cabbrev to change
:Wq to :wq.

Would be done like this:
cabbrev Wq wq

[email protected], March 21, 2001 14:31
I like that cabbrev tip.  That lets you get away with:
   cabbrev X x
The drawback is that it becomes tricky to use "X" as a work in any
command.  For example, with "cabbrev X x", you cannot perform the
search "/X" --> the abbrev changes it to "/x"
parakleta at@ darkreality dot. org, May 11, 2004 10:49
Even better that :wq to write and quit, just type ZZ instead, much quicker, and you can keep the shift key down.
[email protected], September 2, 2004 1:31
:x is even quicker
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo