Escolar Documentos
Profissional Documentos
Cultura Documentos
11:59 AM
<<<<<<<<<<BASIC VI COMMANDS>>>>>>>>>>>>>>>>>>
esc(twice)
:w
:q!
:wq or ZZ
:w filename => save the current file into an another new file
:e filename => Edit a file within vi
<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>
<<<<<CURSOR CONTROLS>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>
[<<<Moving up/down by line>>>>>>]
j
nL
Linux_VI Page 1
:[n]
<n>l
<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<SCREEN CONTROL>>>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
CTRL + f
=> Creates a new line for text entry below current location
=> Creates a new line for text entry above cursor location
:f
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<DELETING FILES>>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>
x
dw
=> Deletes from the current cursor location till end of that word
d$ or D
=> Deletes from the current cursor location till end of that line
d^
=> Deletes from start of line till one position before current
cursor location
dd
:g/^/+d
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
<<<<<<<<<<COPYING>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
yy
cursor
p
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>
<<<<<<<FIND COMMANDS>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>
?
To perform case insensitive search, add '/c' after the end of the search term.
To scroll through only the search term:
n=Forward scrolling
N=backward scrolling
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>
<<<<<<<MISC. COMMANDS>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>
:s/search/replace/g
:line1,line2s/search/replace/g
:%s/search/replace/g
:s/\<whole word to be
substituted\>/replace/g
:s/^/<string>/g
V~
g~$
:.=
:ab
:abc
=> Undo
CTRL + R
=> Redo
:edit (or) :e
:$-9,$w <file_name>
Linux_VI Page 3
:read <filename> or r
<filename>
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
<<<<<<<MULTIPLE WINDOWS>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
CTRL + w(2 times)
:split filename
:vsplit filename
:hide
10 (+) ^w (+) +
10 (+) ^w (+) -
CTRL + w + up or down
arrow
vi -o multiple_file_names
vi -O multiple_file_names
:wqa
:noh
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<VI TABS>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
vi -p <file1>
<file2> ... <file n>
:tabfir
:tablas
:tabn
:tabp
:tabs
<n>gt
gt
=>Switches to the next tab. Wrap around from last to first tab.
gT
:tabclose <n>
:tabonly
:tabonly
:tabclose
<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>
<<<<<<<USING MARKS>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
Marks allows to record a cursor position and return back to that spot later.
Usually lower case letters (a-z) will be used. If a new mark is made with the same
name as previous one, the previous marker is lost.
m<letter>
`<letter>
'<letter>
vi ~/.vimrc => Can be used for setting the default appearances of vi. For instance, one can set the line
numbers on by default.
Linux_VI Page 5