Comandos úteis para a ferramenta vi

desfazer refazer

undo: u
redo: ctrl-r

caso ignorando

desactivate case: :set ic
activate
case: :set noic

veja todos os personagens

to see all characters (tab...): :set list

substituição de texto

subsitute X by Y in all file (regex allowed in X and Y): :%s/X/Y/g
subsitute X
by Y from line A to line B only (regex allowed in X and Y): :A,Bs/X/Y/g

use o modo visual para copiar / colar / excluir / substituir

use visual mode to select text: v then use arrows keys
then you can use classic commands on selected text: d to delete, y to copy, :s/X/Y/g to substitute X by Y in the selection

use o comando externo para manipular o texto atual

example: use the external "sort" command to sort all file: :%!sort (can be obviously used on visual selection too)
example
: insert external command output "hostname" at current position: :r!hostname

use diferentes buffers de copiar / colar

list all buffers: :reg
paste content
of buffer number X than the default: "Xp

gerenciar vários arquivos

open multiple files: vi file1 file2 file3
naviguate
from one file to another: :n forward and :N backward
open multiple files
with vertical splitted screen: vi -o file1 file2 file3 then use ctrl-ww to move to next screen

definir opções da linha de comando

use the "+" option when opening files: vi +"set ic" +"set nu" file1 file2" to open files with case ignoring and lines number displayed