i have ubuntu 10.10 installed on a box. and i ssh to it from another computer.

when i do sudo vi /var/www/page.php

i enter a text editor. when when i try to type i hear that ding noise as in i cant type. what do i press to allow me to start typing? when i type :q that works and it quits it. but what allows me to start typing? thanks

link|improve this question

80% accept rate
2  
Matt Jenkin's list is a good primer but if things work out too difficult, use 'nano' instead. Its probably a lot closer to the text editors your used to. Instead of writing 'vi file', write 'nano file'. – PriceChild Apr 8 '11 at 8:28
feedback

2 Answers

up vote 2 down vote accepted

Vi is what is known as a modal editor - that means it has a number of modes in which it operates.

When you first start vi it is in command mode. Some common command mode key sequences:

  • :q - Quit
  • :q! - Force quit
  • :w - Write file
  • :wq! - Forced write file and exit
  • :w /path/to/my/new/file - Write to a new file
  • :r /path/to/file - read file and insert into buffer

To switch into one of the editing modes:

  • i - Enter insert mode infront of the current character
  • r - Replace single character
  • R - Enter replace mode
  • a - Enter insert mode after the current character
  • A - Enter insert mode at the end of the current line
  • o - Open a new line below cursor and enter insert mode
  • O - Open a new line above cursor and enter insert mode

To return to command mode just press Esc

There are a huge number of other keypresses in command mode - this list is pretty useful.

link|improve this answer
feedback

type a to append or i to insert
Refer this document for more commands

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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