Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To disable "Entering Ex mode" in Vim

Tags:

vim

ex-mode

I get the following 10X times a day by accident.

Entering Ex mode. Type "visual" to go to Normal mode.

How can you disable the combo which causes it in Vim?

like image 674
Léo Léopold Hertz 준영 Avatar asked Aug 13 '09 02:08

Léo Léopold Hertz 준영


People also ask

How do I get out of Ex mode?

To leave Ex mode you have to type :visual . To enter it, you type Q , which some people hit accidentally and consider an annoyance. Scripts sometimes use Ex mode, and plugin authors occasionally use it to try out snippets of Vim script. Many people use Vim for years without using it at all, and some even remap Q .

What is Vim Ex mode?

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.


2 Answers

<Nop> is meant for use in mapping keys to "nothing". See :h <Nop>.

:map Q <Nop> 

Or put it in your ~/.vimrc:

map Q <Nop> 

.

like image 65
Brian Carper Avatar answered Oct 05 '22 11:10

Brian Carper


This answer is based on @NielsBom's comment 4. October 2012 and on @BrianCarper's answer 13. August 2009.

I think NielsBom is completely right, please see the article. The command map is really evil in Vim and has caused me a lot of problems during years. I did not realize the thing before NielsBom's comment. So please use the following command instead:

:nnoremap Q <Nop> 
like image 40
Léo Léopold Hertz 준영 Avatar answered Oct 05 '22 10:10

Léo Léopold Hertz 준영