I realize that the "command" for erasing a letter is x, but if you're seriously just erasing like 3-5 letters, is it really beneficial at all to press ESC + hhhhh + xxxxx?

In vim, is there any reason we can't use the backspace?

  • Backspace works fine for me. Mar 4 '12 at 6:22
  • That depends on what is the context, without any more info Esc + 4Xx would do the same. If you give a sample of the text maybe we could see if there is a shorter way.
    – Raimondi
    Mar 4 '12 at 6:26
  • Is this question about what the point of the x command is, or about how to actually use the backspace key in vim?
    – NReilingh
    Mar 4 '12 at 6:34

Since your your typing sequence starts with <Esc> I assume you are in insert mode, right? If so, you can type <C-w> to delete the word on the left of the cursor without leaving insert mode.

Hitting <bs> works in insert mode as well for single characters, there's no real need to get out of it if you only need to delete a few of the characters you just typed.

x is "the" command to erase a letter in normal mode but it only works alone (x) or with a count (5x), same for X. There are many situations where you need to act on a whole word or two, or what's between a pair of parenthesis, or until a specific pattern forward, or until and including a specific letter backward… In such situations, you should use d in combination with motions.

  • And then there's '<C-o>' in insert mode, which lets you enter a single normal mode command without really leaving.
    – Magnus
    Mar 6 '12 at 17:11

In command mode, Backspace is used to move cursor to left. If you want to use it as expected, use following command in command mode:

:nnoremap <bs> X  

Add it in your .vimrc file if you want permanent change.


Instead of ESC hhhhh xxxxx, try d5h.


You can use the mapping Sachin Shekhar suggested or do it "the Vi way", but there is in my opinion a better way:

The backspace setting controls how the Backspace key works. Putting this in your .vimrc makes the Backspace key work the way most people expect:

set backspace=indent,eol,start

Do :h 'backspace for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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