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.

  • 6
    That's the traditional vi behaviour. If you've got the option to set nocompatibility, then you're already using vim. May 16 '13 at 19:27
  • I am not aware that vi is installed on Ubuntu. vi in Linux world in my experience is just a symbolic link to vim. If you want to learn real vi either install nvi or hairloom project vi. May 18 '13 at 2:11
  1. Checkout whether your are actually using plain vi via

    $ vi --version | head -n 1

    This gives on my machine (Debian 7)

    VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 10 2013 02:27:59)

    vim can be made to behave more like vi. This can be done by giving the command vi instead of vim from the commandline, where vi is only a sym-link to vim, in which case vim is opened in vi mode. You can check this with :set compatible?.

  2. As mentioned by the previous answer, the effect of the backspace becomes only visible after leaving in insert mode when set compatible is enabled.

Note: In vi-compatible mode, you cannot backspace over text which was previously entered (before entered insert mode) or eol's or indentation in insert mode. see :help 'bs'

    'backspace' 'bs'        string  (default "")
                            {not in Vi}
    Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
    mode.  This is a list of items, separated by commas.  Each item allows
    a way to backspace over something:
    value   effect
    indent  allow backspacing over autoindent
    eol     allow backspacing over line breaks (join lines)
    start   allow backspacing over the start of insert; CTRL-W and CTRL-U
            stop once at the start of insert.

    When the value is empty, Vi compatible backspacing is used.
    For backwards compatibility with version 5.4 and earlier:
    value   effect
      0     same as ":set backspace=" (Vi compatible)
      1     same as ":set backspace=indent,eol"
      2     same as ":set backspace=indent,eol,start"

Try out the different settings to understand their meaning: Enter characters/line breaks and indentation in insert mode, exit and reenter insert mode and then try backspacing.

Users who are not familiar with vi behaviour and don't insist on using plain vi (not recommened anyway) should :set backspace=indent,eol,start. Afaik on Debian there is usually a system-wide config file installed with this setting.

You can get the current setting via :set bs?.


Sometimes the vi command is an alias for vim and when called as vi enables its vi-mode.

Even in traditional mode backspace is deleting the character, but does not display it as deleted immediately. (After pressing ESC the characters are gone.)

Guess you have to choose between using vi which comes with the described behavior or using vim which is able to do it the way you expect it.


Create a new file in the user home directory called .vimrc if it's not already there. Here we'll create and edit at the same time with vi

sudo vi ~/.vimrc

Add the following commands, which include turning off compatibility mode and backspace key erase functionality:

set nocp
set backspace=indent,eol,start

Save and exit file using


Turning off compatibility mode allows the use of arrow keys us old vi guys are used to.

Since we sudo'd when creating the file, the ownership of the file will probably be root. You can chown the file to the user.

In my case this was for a raspberry pi, so the user and group is pi:

chown pi:pi ~/.vimrc

Now fire up vi again and enjoy!

  • 1
    set nocp did the trick for me
    – Louis M
    Jun 15 '18 at 8:27

I think the best way would be to look at VI/VIM cheatsheet : http://www.viemu.com/vi-vim-cheat-sheet.gif

Enter normal mode (ESC) and then SHIFT + X.


just place in your ~/.zshrc

bindkey "^?" backward-delete-char

Creating a .vimrc in my home directory that contains only

set nocp

fixed my problem with backspace not removing the character from the screen Dick S.

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.