Vim Tips Wiki

Insert one character only

Revision as of 08:45, September 29, 2008 by JohnBot (Talk | contribs)

1,619pages on
this wiki

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.


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