Active6 months ago
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.
Using the Delete Key on a Mac & Adding a Forward Delete Button Apr 26, 2013 - 10 Comments The delete key on a Mac keyboard functions like a backspace key on a Windows/PC keyboard, deleting a character a time backwards from where the cursor is located. Backspace is the keyboard key that originally pushed the typewriter carriage one position backwards, and in modern computer systems moves the display cursor one position backwards, deletes the character at that position, and shifts back the text after that position by one position.
Sparhawk5,26866 gold badges3232 silver badges6666 bronze badges
Saprativa Bhattacharjee![Delete key mac map to backspace for vi editor tutorial Delete key mac map to backspace for vi editor tutorial](/uploads/1/2/4/7/124798867/310101967.jpg)
56733 gold badges66 silver badges1010 bronze badges
4 Answers
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
:ifooBackspaceEsc
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)![Delete key mac map to backspace for vi editor linux Delete key mac map to backspace for vi editor linux](/uploads/1/2/4/7/124798867/373852479.png)
33.4k1010 gold badges5858 silver badges6262 bronze badges
Here is the simplest solution.
Open a terminal, go to home directory and type
Open a terminal, go to home directory and type
a new file open now add these lines to the file and exit by saving
Zanna53.1k1414 gold badges149149 silver badges250250 bronze badges
Adithya ChakilamAdithya Chakilam90411 gold badge88 silver badges1212 bronze badges
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
= RightOnce you have your cursor positioned you can delete text as follows:
x
Deletes the character under the cursorX
Deletes the character before the cursordw
Deletes from the cursor to the next worddd
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 cursorA
Adds text to the end of the current linei
Adds text to the left of the cursorI
Adds test to the beginin of the current lineo
Opens a new line below the current line and places you in text entry modeO
Opens a new line Above the current line and places you in text entry modeTo exit Text entry mode, and return to the Command mode, use
Esc
.To Undo changes: (A student favorite)
u
Undo the last command enteredU
Undo all changes to the ** current line**To Save/Quit:
Argusvision: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 changesZZ
Writes (Saves) the file and exits VI (same as :wq
)Mac Map To Network Drive
Argusvision1,44233 gold badges1010 silver badges2727 bronze badges
Install the full vim package to get the backspace and arrow key functionality
Zanna53.1k1414 gold badges149149 silver badges250250 bronze badges
Ratnala JagadeeshRatnala Jagadeesh