Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:

  • for I get B,
  • for I get A,
  • for I get D,
  • for I get C.

Please help me in resolve this problem.

share|improve this question
add comment

marked as duplicate by Radu Rădeanu, Mitch, guntbert, Warren Hill, aquaherd Oct 5 '13 at 21:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

If you dont already have a .vimrc file in your home directory, create one using this:

vim $HOME/.vimrc

Add this line to the top of the file:

set nocompatible

save the file and this should fix the problem for you :)

share|improve this answer
I tried the vim $HOME/.vimrc command but it has displayed the following message. –  bvb Oct 5 '13 at 14:42
@bvb Can you please help us with what message vim $HOME/.vimrc displayed? –  Gaurav Manchanda Oct 5 '13 at 15:09
add comment

The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:

  1. use vim instead of vi
  2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)
share|improve this answer
add comment

With vi, when clicking on i you activate the command to Insert text.
This command allows you to insert text in your file.
And right, when clicking :

  • on it will insert a "A",
  • on it will insert a "B",
  • ...

Till you deactivate this command.
To deactivate a command in vi : just click on Esc
And then you will get back normal use of your arrow keys:

  • to go up,
  • to go down,
  • ...
share|improve this answer
add comment

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