AatG
AatG

Reputation: 725

How to delete next character (not current!) in vim?

I often find myself needing to delete the character after the cursor, but not the current character. What's the shortest way to do this in normal mode in vim?

Upvotes: 13

Views: 9476

Answers (4)

paxdiablo
paxdiablo

Reputation: 882596

lx will do the trick, or lxh if you want to return your cursor to the original position.

It simply moves the cursor forward and deletes the character under it.

If that's not short enough, you can map it to a single keypress:

:map <f5> lxh

Then just use the f5 function key.

Upvotes: 15

Kent
Kent

Reputation: 195239

I believe there are many ways to do that, there is another 3-strokes way:

xpX

note that, either xpX or lxh would fail if your cursor on the EOL. :)

Upvotes: 3

remudada
remudada

Reputation: 3791

There are commands to delete the character before the cursor Shift-X, but not after it. I tend to do lxh to get this done. . .

Upvotes: 1

Ken Anderson
Ken Anderson

Reputation: 2403

The shortest sequence that I know is also the obvious one:

Type "l x h" in command mode.

Upvotes: 1

Related Questions