Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

vi - Text Editor

It has two modes


1. Command mode (To come from Insert mode to Command mode press esc key)
Its the default mode
2. Insert mode (To come from command mode to insert mode press i)

1. Command mode(Sielence in nature. Typed comands are not visible)


---------------
h j k l
h - move one character towards left
l - move one character towards right
j - move one row down (Jump)
k - move one row up (Kite)

w - move one word in forward direction


b - move one word in backword direction

0(Zero) - move to the very begining of the current row


^ - move to the 1st visible character of the current row
$ - move to the end of the current row

G - Move to the last row's begining


gg - used for move to the begining of the file

------------------------------------------------
Move Multiple units(use a number b4 the below characters)
n h
n j
n k
n l
n w
n b

n - means any number from 1,2,3........


Ex: 4h - 4 character towards left
-----------------------------------------------
Delete / Cut of char or words (d - delete/cut)
d n h
d n j
d n k
d n l
d n w
d n b
d $ delete till end of cur row
d 0 delete till begin of cur row
d ^ delete till begin of cur row (but 1st visible character)
d G - delete / cut till end of file(EOF)
d gg - delete / cut till beginging of file (BOF)

Ex: d4w - delete / cut 4 words in forward direction


After cut use p command for pase
---------------------------------------------------
Copy char or words (y - copy)
y n h
y n j
y n k
y n l
y n w
y n b
y $ - copy row till end of current row
y 0 - Copy till begining of curr row
y ^ - Copy till begining of curr row(but 1st visible character)
y G - Copy row till end of file(EOF) row
y gg - Copy till beginging of file (BOF)

Ex: y4w - copy 4 words in forward direction


After copy use p command for pase
---------------------------------------------------
Mislaneous commands
x - delete one char in forward direction
nx - delete n character
dd - delete cur row
ndd - delete n rows from current row
yy - copy cur row
nyy - copy n rows from curr row
-------------------------------------------------
Insert Mode:
i - insert mode at the current cursor position
I - insert mode at the very begining of current row
a - insert mode at the next character of cursor position
A - insert mode at the end of current row
o - insert a blank row at the next row in insert mode
O - insert a blank row at the upper row in insert mode
----------------------------------------------------
Command mode(Commands will be visible)

:(Colon) mode
:set nu - Show row number
:set nonu - hide the row numbers
:%s/blank/empty/g - It will replace/substitute all the blank spelled words with
blank word
% - All Line
s - substitute
blank - source word to be replaced
empty - target word
g - global - if any line contains multiple source in a line then it will
replace all words else it will replace only the est occurance of the source

----------------------------------------------------
Command mode with (/)

/anyword - It will search any word (n - next word in forward direction. N - next
word in backword direction)

----------------------------------------------------

You might also like