Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking for the opposite of x. I want to insert just one character and stay in command mode.

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

You could map a key(-sequence) to a command sequence, f.e.:

:map <C-i> i_<Esc>r

Ctrl-i takes one character and returns afterwards.

To make it persistent, add the same line to the local or global vimrc file:

~/.vimrc
/etc/vim/vimrc
share|improve this answer
5  
To put in a vimrc file one should leave out the : –  phunehehe Dec 17 '10 at 2:05
    
I don't get it.. whether you do i {char} Esc or CTRL-i {char}, it's still three keystrokes. I'd say if you are going to customize your setup, just make Esc more readily available, e.g. by mapping CapsLock to it. –  intuited Apr 4 '11 at 7:24
add comment

In some situations you can just use r. From :help r:

Replace the character under the cursor with {char}.

If you want more than one char, use R. (When used it enters in Replace mode. As usual, for more info, :help Replace).

Remember to run vimtutor at least once to learn some commands. The r command is used in Lesson 3.2.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.