Vim Tips Wiki

Map semicolon to colon

1,624pages on
this wiki
Add New Page
Talk0 Share
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.

Caveats Edit

When you run a command like :ls that leaves output on the screen while waiting for you to enter another command, using semi-colon instead of colon will cause the output of :ls to be hidden as soon as you start entering the new command. There may be a fix for this, but I haven't found one yet.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki