Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I (re)map Ex commands in vim?

Tags:

vim

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?

like image 865
innaM Avatar asked Sep 22 '08 19:09

innaM


People also ask

How do I remap a key in vim?

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.

How do I find previous commands in vim?

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.

What is ex command in vim?

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.


1 Answers

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.

like image 138
WMR Avatar answered Oct 08 '22 11:10

WMR