Vim is a clone, with additions, of Bill Joy’s vi text editor program for Unix. Vim’s author, Bram Moolenaar, based it upon the source code for a port of the Stevie editor to the Amiga and released a version to the public in 1991.

Check and make sure you have Vim in your machine, vim
–version
If you don’t have Download Vim from here, https://www.vim.org/download.php
Open file in vim terminal, vim [location of
path/filename]
vim usr/bin/testfile.txt
Arrows Keys:
h -> left
l -> right
j -> down
k ->
up
Navigation:
gg -> Go to top
G -> Go to the last
nG -> Go to the nth
line
w -> goes next first character of the
word
nw -> goes next nth character of the word
10w -> goes after next 10
words first character
b -> goes back first
character of the word
nb -> goes back nth character of the word
10b ->
goes back before 10 words first character
e -> goes last character of the
word
f -> forward
F -> backward
ft ->
goes to the forward t
Ft -> goes to the backward
t
t -> forward until
T -> backward
until
tt -> goes to the forward until t
Tt -> goes to the back until
t
Quit From Vim:
First Make sure you are in normal mode
:q
:quit
:
x
:exit
ZZ
:q! -> void changes and exit
:wq -> save changes and
exit
Modes in Vim
Normal
Insert
Visual
Normal Mode Commands
Delete
x -> delete character
dw ->
delete the word
dd -> delete the line
nthdd -> delete the next nth
number of words
10dd -> delete the next 10
words
d$ / D -> delete from cursor to the end of the
line
Copy
yw
-> copy the word
yy -> copy the line
y$ -> copy the line from cursor
to the end of the line
p -> put/paste the
deleted word/line
r -> replace the word
u -> undo
ctrl +r -> redo
Insert Mode
i -> Change to the Insert Mode
I -> Change to the insert mode at
the first character of the line
a -> insert mode
A -> insert mode
at the end character of the line
s -> delete the character and change to
the insert mode
S -> delete the line and change to the insert mode
o ->
insert the new line into next line and change to the insert mode
O -> insert
the new line into previous line and change to the insert mode
c -> change
ce / cw -> change and delete the word and replace the word
c$ / C ->
delete the whole line and insert
esc -> come out from edit mode to normal
mode
Visual Mode
v -> change to the visual mode
esc -> to come out from visual
mode to normal mode
Search In Vim
First change to vim to normal mode
/search_word
?search_word
n
-> go to the next matched word
ctrl + o -> go back to found word
ctrl +
i -> go to next matched word
Replace in Vim
First change vim to normal mode
syntax ->
s/word/new_word/g
%/word/new_word/g -> all words
3,20 s/word/new_word/g ->
– replace from line 3-20
%s/word/new_word/gc -> – replace with
confirmation
Execute commands inside vim
First change vim to normal mode
syntax -> !command
!pwd -> current
path
!ls -> list of path