Monday, October 7, 2013

Some VI editor tips...

since Linux commands are case-sensitive, you have to write commands carefully.
VI Editor: 

VI editor plays very important role when you use any Linux distributions.

       Because If we need any modification of any file when we connect to any linux server / machine remotely,  This time everybody definitely go for  this VI editor, But some people go for other editor / tools  like nano..etc.

So, Learning this VI will provide us flexibility on any linux machine.


vi is legacy.  to check - just type vi in command line

so Install vim, using the command 'sudo apt-get install vim '

vim is very flexible text editor. It is very advanced.



Generally VI editor has two modes

1) command mode
2) Insert mode

- If we want to modify/customize any content of a file like delete a line, copy, search a pattern ..etc, we must enter into command mode by pressing 'Esc' button.
- Any text we want to enter to a file, we must enter into insert mode,
     If we are in command mode, press 'i' to enter to insert mode.






Below are some tips to work with VI..

$ vi + file    open file at last line
$ vi +n file  open directly at line number n
$ vi +/pattern file  open file directly at pattern

command mode commands
------------------------------------
dd         to remove a line
/pattern search forward for pattern
?pattern search backward for pattern
n           Repeat last search in same
N          Repeat last search in opposite direction

No comments:

Post a Comment