I am new to vi, actually I have started learning vi from today and I have got stuck at the behavior of the backspace key.

Actually when I fired up vi on my Ubuntu 12.04 for the first time my backspace key was working normally but after that it has started behaving strangely. Whenever I press the backspace in the insert mode it just moves one place to the left instead of erasing the character.

How can I get back the default backspace functionality? Please note that I don't want to install vim or set nocompatibilty.

4 Answers 4


Here is the simplest solution.
Open a terminal, go to home directory and type

vi .vimrc

a new file open now add these lines to the file and exit by saving

$ set nocompatible
$ set backspace=2
  • 10
    The OP mentioned that they don't want to use nocompatibility
    – kiri
    Nov 3, 2013 at 12:47
  • 1
    there is no need for no compatability u can also do it just by addig the second line Nov 3, 2013 at 12:49
  • 2
    Second line only works for me if I also add the first line.
    – djjeck
    Apr 2, 2014 at 21:03
  • Started from an empty .vimrc and wondered why backspace didn't work on mac in iTerm2. Thanks a lot!
    – Igor Malyk
    Oct 23, 2015 at 11:55
  • @minerz029 add yet this is the answer most people are here for, since there was no such qualification in the page title.
    – Muhd
    Feb 27, 2017 at 5:51

That's correct behavior for vi, and it does erase the character, it just doesn't show it by replacing it with a blank like in vim. It will be apparent when you overwrite the erased character with another character, or switch back to command mode.

E.g. starting with command mode on an empty line, the following will result in the line containing fo:


Before you hit the Esc key, the line will read foo, but the last o has been tagged as an "erase-column". See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_88 (mainly point 4 under that heading, and also browse a little further down to read about <Control>-H)

  • I spent at least couple of hours trying to figure this out (at times cursing my Windows terminal app too), finally it worked. Thank you! 💡 May 30, 2020 at 6:24

You need to change to the "insert" mode by moving the cursor with i. There are other ways to delete characters directly. You can download a powerpoint that I use when teaching a class on VI here.

It sounds like you are in the "Command" mode. To move your cursor:
H = Left, J = Up, K = Down, L = Right

Once you have your cursor positioned you can delete text as follows:
x Deletes the character under the cursor
X Deletes the character before the cursor
dw Deletes from the cursor to the next word
dd Deletes the line the cursor is on.

To enter text, you can use one of the text entry modes.
a Adds text to the right of the cursor
A Adds text to the end of the current line
i Adds text to the left of the cursor
I Adds test to the beginin of the current line
o Opens a new line below the current line and places you in text entry mode
O Opens a new line Above the current line and places you in text entry mode

To exit Text entry mode, and return to the Command mode, use Esc.

To Undo changes: (A student favorite)
u Undo the last command entered
U Undo all changes to the ** current line**

To Save/Quit: :w Writes (Saves) the file and remains open
:wq Writes (Saves) the file and exits VI
:q Quits (Exits) if you've made no changes
:q! Quits (Exits) without saving changes
ZZ Writes (Saves) the file and exits VI (same as :wq)

  • 12
    The OP mentioned that the mysterious behavior occurs in insert mode. So this is not the answer to the question asked.
    – LarsH
    May 16, 2013 at 20:50
  • Actually the OP did not state in insert mode. The question was edited. May 16, 2013 at 21:04
  • 1
    Ok. You're correct. It looks like I made an assumption. It's been my experience that most people new to VI run into issues with switching modes, and navigating when in the command mode. My students often complain and blame VI for a having erratic behaviour when it's simply user error, or not having a grasp of the command set. May 17, 2013 at 12:28
  • 1
    Understandable. I agree that is the common reaction to non-insert-mode.
    – LarsH
    May 17, 2013 at 13:43
  • Argus, "in insert mode" was added to the question title in an edit, but it was in the body of the question from the beginning.
    – LarsH
    Sep 9, 2015 at 19:35

Install the full vim package to get the backspace and arrow key functionality

sudo apt-get update
sudo apt-get install vim
  • 3
    It's working as expected.. Best answer
    – Vicky
    Jul 24, 2018 at 16:09
  • 1
    That is the perfect answer. No need to edit any config files, just install the vim-runtime package and everything works as I am used to. Thanks!
    – olidem
    Oct 5, 2018 at 7:56

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.