<<<<<< Basics Options for VI/VIM editor >>>>>>

Note: In below given examples "/etc/passwd" is the target file for testing.

1. Go to the 14th line of file

"[root@desktop10 ~]# vim +13 /etc/passwd "

2. Go to the first match of the specified string;

"[root@desktop10 ~]# vim +/root /etc/passwd

3. Open the file in read only mode.

"[root@desktop10 ~]# vim -R /etc/passwd"

4. Go to the last line of any file.

"[root@desktop10 ~]# vim /etc/passwd "

Then type G(upper case) without inserting into the file.

5. Go the desired line of any file.

"[root@desktop10 ~]# vim /etc/passwd "

For going into any line if you are already in file

i) First press Esc button if you are in insert mode

ii) then type :13 here 13 is the line number.

6. Copy the single line from and paste

i) open any file

"[root@desktop10 ~]# vim /etc/passwd "

ii) press yy in Esc mode(non insert mode) for copy then use key 'p' for paste

iii) For copy more than one line just press ny and use p for paste.

7. Delete a single line.

i) open any file as given below

"[root@desktop10 ~]# vim /etc/passwd "

ii) press dd in Esc mode ( without going into insert mode ) . it will delete
the current line where currently cursurer is.

8. Open more than one file at a time

'[root@desktop10 Desktop]# vim -d file1 file2'

By default the curser will be in first file and to swith between/among the files use key {cont + w}
two times to switch the into the files.

9. You can also encrypt the file using vim editor

'[root@desktop10 Desktop]# vim -x email.txt'
it will automatically ask for password.