VI visual display editor VIM visual display editor improved This is command mode editor for files other editors are emacs,gedit,pico,nano vi editor is the most popular editor it has 3 modes: 1.command mode 2.insert mode (edit mode) 3.execution mode command mode: dd to delete a line (cut) 4dd to delete 4 lines (cut) dw to delete a word dl (or) x to delete a character yy to copy a line (yank) 10yy to copy 10 lines (yank) yw to copy a word yl to copy a character p to paste lines below cursor position 10p to paste line 10 times G to move to the end of the file 10G to move to the 10th line P to past lines above cursor position r to replace a character u to undo ctrl+r to redo / to find a text inside a file To get into insert mode to add the data. i Insert at current cursor position o Insert line below cursor position Execution mode: :w to save the file :wq to save and quit :x to save and quit :q to quit without saving :q! to quit without saving (forcefully) :set nu to set line Number :set nonu to remove line Number :14 to move cursor to line no. 14 :/find word to find for a word :1,$d to delete entire contents of a file How to find and replace in execution mode:- :s/// range can be: ex: :1,$s/this/that % complete file 10,$ from 10th line to last line .s will replace the cursor line only options can be: g to replace all the occurence in same line c to replace with conformation ex. :1,$s/cat/dog/gc To find cat word and replace with dog with interaction. To remove the word (this) from the file. :1,$s/this// head ........ this command is used to see first 10 lines of a file. ex. # head file1 To see the first 'n' lines ex. # head -n file1 # head -15 file1 [lists first 15 lines of a file] tail ....... this command is used to see last 10 lines of a file. ex. # tail file1 to see the last 'n' lines: # tail -n file1 # tail -15 file1 [lists last 15 lines of a file] wc..... word count # wc file1 it will show no. of lines no. of words no. of characters