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?
To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap.
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.
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. :)
The shortest sequence that I know is also the obvious one:
Type "l x h" in command mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With