Vi or Vim Editor
vi/vim editor:-
**************
#vi <filename> --> to create or edit a file using vi editor
ex: #vi f1
#vim <filname>
command not found
#yum install vim -y
#vim <filename>
ex: #vim f2
-> we have 3 modes in vi/vim editor
1) insert mode
2) command mode
3) colon mode
insert mode shortcuts:-
***********************
esc + i ---> to enter into insert mode
esc+shift+i --> moves the cursor position to present line first character.
esc+shift+a ---> moves the cursor position to present line last position.
esc+o --> moves to cursor to below line and creates a new line
esc+shift+o --> moves the cursor to above line and creates a new line
esc --> to exit from insert mode
command mode shortcuts:-
***********************
esc+shift+h --> to move the cursor to first line first position
esc+shift+g --> to move the cursor to last line first position
esc+ j --> moves the cursor downwards in same position
esc+k --> moves the cursor upwards in same position
esc+x --> to delete a sibgle character
esc+Nx --> to delete a N number of characters[N => natural number]
esc + dw -->to delete a complete word from present position
esc+ Ndw --> to delete a N number of words from present position
esc+ dd ---> to delete a complete line where cursor is present
esc+ Ndd --> to delete N number of lines from present line
esc + u --> to undo the deleted things
esc + yw --> to copy a complete word from present position
esc + Nyw --> to copy a complete N number of word from present position
esc+ p --> to paste the copied content
esc+ yy --> to copy a complete line
esc+ Nyy --> to cesc+ p --> to paste the copied content
esc+ w --> to move the cursor to next word first position
esc+b --> to move the cursor to previous word first position
esc+e --> to move the cursor to present word last position
esc+shift+ ~ --> to change the letter or character to uppercase or lowercase & viceversa
colon mode shortcuts:-
**********************
esc+shift+: --> to enter into colon mode
esc+ shift+: set nu --> to set index number for lines
esc+shift+: set nonu --> to remove the index numbers from lines
esc+shift+: /<string> --> to higlight a perticular string or word
esc+ shift+: %s /<replacing word> /<word to replace> --> to replace all the words present in that file
ex: esc+shift+: %s /linux /LINUX
esc+shift+:Nd --> to delete a peritcular line using index number
esc+shift+:n,Nd --> to delete the lines starting from n and ending with N
esc+shift+: n co N --> to copy the line "n" and paste it in "N" line
esc+shift+: 1,4 co 6 ---> to to copy the lines from 1 to 4 and paste it in 6 line
esc+shift+: w --> to save the changes/content
esc+shift+: q --> to quit without saving
esc+shift+: q! --> to quit without saving forcefully
esc+shift+:wq --> to save and quit
esc+shift+:wq! --> to save and quit forcefully
Comments
Post a Comment