Vim Tips Wiki

Map semicolon to colon

Revision as of 06:08, July 13, 2012 by JohnBot (Talk | contribs)

1,619pages on
this wiki
Tip 1111 Printable Monobook Previous Next

created 2006 · complexity basic · author Gert Vierman · version 5.7

To avoid the extra 'shift' keypress when typing the colon to go to cmdline mode, I mapped the semicolon key to do the same thing.

:nmap ; :

This overwrites the original mapping of repeating the last f or t command.


You can do the following to regain the functionality of ;

nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;

I use the following instead:

map ; :

This takes over the ; even in visual mode (why should I be forced to hold the shift down there but not in normal mode?). Furthermore, sometimes I want to run a custom command that starts with a capital letter, so I might have the shift already held down when I hit the ; (making it a colon), which would cause problems if the colon were mapped back to the semicolon. I get around this by this mapping:

noremap ;; ;

So, to get the original ; behaviour, I just hit it twice.

As a rule, I don't get encumbered by the timeout delay caused by the ambiguous mapping because I hit another character immediately after ; when it's a command I'm trying to execute from the command-line. The delay is only a problem if I hit the ; and hit nothing else after it. If I hit ;s, for example (the start of :sp), there is no delay.

Around Wikia's network

Random Wiki