VIM Text Editor

VIM is a defecto standard for Redhat / CentOS and other Unix like operating systems, and it is THE favorite choice of sysadmins as well. Here are my quick notes on using VIM.

Key /Key combination   #Description

^                                       #Begining of Line/File
$                                       #End of Line/File
w                                      #Move cursor to the begining of next word
b                                       #Move cursor back to begining of preceeding word
:0 <Enter> or 1G            #Move cursor to first line in file
:n<Enter> or nG             #Move cursor to line n
:$<Enter> or G               #Move cursor to last line in file
Ctrl+F                               #Page forward
Ctrl+B                              #Page back
DD                                   #Delete line
Shift+Y                            #Copy corrent line
Shift+P                            #Paste
number+G                     #Goto line number
$+G                                  #Goto end of file
x                                       #Delete right to the cursor
X                                       #Delete left to the cursor
5+D+up                           #Will delete 5 lines up
5+D+down                      #Will delete 5 lines down
shift+~                             #Change the upper to lower and wise verse
?                                        #Search up
/                                        #Search down
:set number                    #Show line numbers
:set num                          #The same as above
vi -r filename                   #Recover the file that was being edited when system crashed
:1,$s/word1/word2        #Search/Replace from first line to the end of file (Only first word found in each line)
:1,$s/word1/word2/g     #Search/Replace from first line to the end of file (All found matching)
:1,$s/^-A/word1/g
:r filename                        #Will read/open the file when editing

Leave a Reply

Your email address will not be published. Required fields are marked *