Pages

Tuesday, February 14, 2012

Linux VI editor


The most powerful and most used editor in linux/unix is vi. In a Unix like operating system you can start with vi <filename>
example: vi test
It will create a file, named test. 

To save the file:
Press esc key and type :q
It wil create a empty file in linux. 

Keep in mind that vi editor has two modes: command mode and insert mode.

To edit a file:
vi test (enters command mode)
press i or insert button (Insert Mode) and start typing.

After editing save with the changes:
Press esc and then 
:wq (write and quit)   or
:x      or
:wq!     or
:x!       or
:ZZ

Now check the file in current directory "ls test". You can check the contents through "cat test" or "more test".

No comments:

Post a Comment