Pages

Friday, June 25, 2010

vi editor

What is vi?
It's a text editor works under the command line environment in Linux OS, that is used to edit system files.

How to use vi?
can run vi editor in command line by typing vi them the name of file you want to edit.

Example :
vi new_file // to create new file with name new_file
vi existing_file // to edit exist file with name existing_file

How to use it ?
  1. After entering file editing mode, you can transfer between the lines of the file using keyboard arrows keys
  2. vi has two modes:(1)command mode (2)edit mode: when you enter the editor , the command mode is activated by default.
  3. To enter edit mode, you have to press i key from the keyboard , then a comment appears in the bottom of the window present the current mode. If you want to back to command mode you have to press "Esc" key.
  4. Before writing any command - such as edit or quit command- in the command line you need to press "shift" and ";" together.
  5. To save and edited or new created file you have to write this command (save file_name), where file_name is name of file your are working on, then press "Enter".It's important to remember that it saves the file in the current path !
  6. To exit you have to write "quit" and then press "Enter".
  7. To force the program to execute the command we need to add "!" mark, so the command will be like this : save! file_name.

No comments:

Post a Comment