Tuesday, February 9, 2021

Useful Vim Commands/Tips

#Page up:
Ctrl+u
#Page down:
Ctrl+d
#Place curzor to center:
Zz
#select entire line from anywhere
Shift+v
#Visual mode:
Control+v
#To append to end:
Ctrl+v
$
A(capital A)
#Replace mode(similar to insert mode):
R(capital R)
#Change small letters to BIG or vice versa
Select the letters and then press ~
#Move around in vim:
j ==> go down(think of it like fisherman J going down)
k ==> go up(think of it as Kite)
l ==> go right(next to kite)
h ==> go left(next to jack)
#To jump in column
press any number followed by l
#Increment number by 1
ctrl+a
#Decrement number by 1
ctrl+x
#Also increment by x
x+ctrl+a
#use version 8 in linux
module load vim/8.0.0176
#Increment in series(Below works in version 8 or above only):
Ex:
ctrl[0]
ctrl[0]
ctrl[0]
ctrl[0]
ctrl[0]
ctrl[0]
ctrl[0]
ctrl[0]
to
ctrl[1]
ctrl[2]
ctrl[3]
ctrl[4]
ctrl[5]
ctrl[6]
ctrl[7]
ctrl[8]
Go to virtual mode and select vertically
g followed by ctrl+a
#delete word under the cursor
d+w
#go to end of word on the cursor
e
#find out full path of current file, % is replaced by fullpath of current file
!ls %