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.

When I am writing C code on the vi editor, I am not able to use the backspace keys or my arrow keys to delete or navigate through lines. Some unexpected special characters occur on the screen that is on middle of my code and I am not able to delete them also. If I use my delete key, the whole code gets deleted. I have tried both insert mode using 'i' and 'a'. I am able to manage this situation for C programming by using the text editors but when I am creating LeX and yacc programs, I find this awkward.

Can you please help me with this?

share|improve this question
    
If you have made a mistake, press the Escape to get into navigation mode, and use the Delete key. After that you can press i to get in insert mode again. –  Aaditya Bagga Aug 15 '13 at 8:50
4  
Also, if you can, install vim (if not installed already): sudo apt-get install vim. Vi will become a bit easier to use (you won't have problems with the delete and arrow keys) and it will add other things like syntax-highlighting. –  Bruno Nova Aug 15 '13 at 9:14

3 Answers 3

Help with the vi editer and its commands-

Vi Editor Commands

How to use the vi editor

share|improve this answer

When in command mode (Esc) you can delete character/word/lines and paragraphes using several keystrokes. Below a some examples.:

Characters:

  • x Delete char under cursor
  • Shift+x Delete char before cursor

Word

  • dd Delete line under cursor
  • diw Delete inner word under cursor. E.g pressing this stroke when on "delete" will endup in "".
  • daw Delete whole word under cursor, including parenthesis etc. E.g. pressing this stroke on "delete" will delete every character.

Paragraphs

  • dip Delete inner paragraph under cursor.
  • dap Delete whole paragraph under cursor, including parenthesis etc.

Putting a number in front of the modifier key strokes will repeat the action those amount of times. E.g. 3x will delete 3 characters.

share|improve this answer

You can do it easily by typing the following command:

$ vi .vimrc

After creating the file you add the below lines in to it:

set backspace=2
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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