I love vim and the speed it gives me. But sometimes, my fingers are too speedy and I find myself typing :WQ
instead of :wq
. (On a German keyboard, you have to press Shift to get the colon :
.) Vim will then complain that WQ
is Not an editor command
.
Is there some way to make W
and Q
editor commands?
To map a sequence of keys to execute another sequence of keys, use the ':map' command. For example, the following command maps the <F2> key to display the current date and time. The ':map' command creates a key map that works in normal, visual, select and operator pending modes.
In the command window, type :p and then press the up key. It will provide the history of all commands in each press that you have used recently.
The Ex mode is similar to the command line mode as it also allows you to enter Ex commands. Unlike the command-line mode you won't return to normal mode automatically. You can enter an Ex command by typing a Q in normal mode and leave it again with the :visual command.
Try
:command WQ wq :command Wq wq :command W w :command Q q
This way you can define your own commands. See :help command
for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With