Wikia

Vim Tips Wiki

Changes: Insert one character only

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 17: Line 17:
 
<pre>
 
<pre>
 
"insert one character
 
"insert one character
noremap &lt;somekey&gt; i&lt;Space&gt;&lt;Esc&gt;r
+
noremap <somekey> i<Space><Esc>r
 
</pre>
 
</pre>
   
Line 27: Line 27:
 
Therefore I define
 
Therefore I define
   
nnoremap &lt;somekey&gt; :exec "normal i".nr2char(getchar())."\e"&lt;cr&gt;
+
nnoremap <somekey> :exec "normal i".nr2char(getchar())."\e"<CR>
nnoremap &lt;someother&gt; :exec "normal a".nr2char(getchar())."\e"&lt;cr&gt;
+
nnoremap <someother> :exec "normal a".nr2char(getchar())."\e"<CR>
   
 
----
 
----

Latest revision as of 08:45, September 29, 2008

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 466 Printable Monobook Previous Next

created April 30, 2003 · complexity basic · author johnmaxa · version 5.7


I have not yet seen this idea yet. But early in my use and love of Vim, I got frustrated in command mode when I wanted to insert just one character of text. So I put this in my vimrc:

"insert one character
noremap <somekey> i<Space><Esc>r

I think it has been one of the most time saving mappings -- and I have remapped most of my keyboard.

CommentsEdit

This won't be repeated by the . command.

Therefore I define

nnoremap <somekey> :exec "normal i".nr2char(getchar())."\e"<CR>
nnoremap <someother> :exec "normal a".nr2char(getchar())."\e"<CR>

Around Wikia's network

Random Wiki