Wikia

Vim Tips Wiki

Changes: Map semicolon to colon

Edit

Back to page

(Comments: make the colon/semicolon swap work in visual mode too)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=1110
 
|previous=1110
 
|next=1112
 
|next=1112
|created=January 18, 2006
+
|created=2006
 
|complexity=basic
 
|complexity=basic
 
|author=Gert Vierman
 
|author=Gert Vierman
Line 17: Line 17:
 
</pre>
 
</pre>
   
This overwrites the original mapping of repeating the last <tt>f</tt> or <tt>t</tt> command.
+
This overwrites the original mapping of repeating the last <code>f</code> or <code>t</code> command.
   
 
==Comments==
 
==Comments==
You can do the following to regain the functionality of <tt>;</tt>
+
You can do the following to regain the functionality of <code>;</code>
 
<pre>
 
<pre>
 
nnoremap ; :
 
nnoremap ; :
Line 34: Line 34:
 
</pre>
 
</pre>
   
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 <tt>;</tt> (making it a colon), which would cause problems if the colon were mapped back to the semicolon. I get around this by this mapping:
+
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 <code>;</code> (making it a colon), which would cause problems if the colon were mapped back to the semicolon. I get around this by this mapping:
 
<pre>
 
<pre>
 
noremap ;; ;
 
noremap ;; ;

Latest revision as of 06:08, July 13, 2012

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.

CommentsEdit

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