vim

To start with vim, go through the tutorial using command : vimtutor

Basic vim commands

TaskCommand
start editing the file content:i[enter]
save the file and exit the editor:x[return]
quit vim without saving the file:q![return]
Save:w
save and exit:wq
exit:q
copy a line:yy
copy:y
Pastep
cutd
cut a linedd
Undou
go to the end of the file::$ and press Enter
Move to the beginning of a linetype 0
Move to the end of a linetype $
Go to beginning of filegg
Go to end of fileG (shift + g)

How to search and replace

%s/text/replacement/g

How to search and replace with confirmation

%s/text/replacement/gc  

Forward Search : /
Backward Search : ?
Search Next : n
Search back : N

Configure vim editor

# ~./vimrc 

set bg=dark 
set ai ts=4 sw=4 et 

# et -> expand tab 
# sw - > shift width 
# ts -> tab space

Last modified July 16, 2024: code refactored (add6d20)