Search

Monday, January 17, 2011

Vi or Vim tutorials

vi / vim (Linux) Tutorial by experience, from the very basic. Vi / vim is a Linux' console text editor.

Start
Use command below to open a document. If document not exist, it will create one for temporary until it is manually saved by user (you).
# vi  /path/and/document_name
Command or Insert mode
There are 2 modes in vi / vim : command mode and insert mode. Command mode used to execute vi commands, insert mode is used to edit document. Command mode is the default mode whenever vi / vim is loaded. To use insert mode just press i character. To go back to command mode press Esc button. Whenever you get confused whether you are in command or insert mode just press Esc, this will make go into command mode despite whatever your previous mode is.
All (next) commands is entered in command mode.

Find / Search
To search for string 'document' :
/document
Quit
To save current document :
:w
To quit without saving :
:q!
To quit and save :
:q
Show Line Number
:set number
<< next >>


Futher Readings :
http://www.tech-recipes.com/rx/402/show-line-numbers-in-vi-or-vim/

No comments:

Post a Comment