Home
|
UNIX
|
Oracle
|
Code
|
Practical
|
Private
The original VIsual editor
Tips and tricks
Scroll,
^D scroll down
^U scroll up
Edit several files,
vi *pattern*
write and switch to the next one,
:wn
Substitute,
:%s/lala/lili/
:%s/lala/lili/g
Note. just like with sed
Show all characters,
:set list
Convert file to UNIX format,
:set ff=unix
:wq
VIM configuration
Turn the freacking colors off, and disable the damn ~ backup files,
vi ~/.vimrc
like,
cd ~/
ls -l .vimrc
cat > ~/.vimrc <<EOF9
syn off
set nobackup
set nowritebackup
EOF9
VIM specific usage
Select a block of lines,
V
select a block of text,
v
Indent,
>
deindent,
<
Those ones may help too,
set ai tw=74 et sw=4 sts=4:
Disable UTF-8,
set encoding=iso-8859-15
and for good,
filetype on
autocmd FileType html set fileencoding=iso-8859-1
VI versions
Basics
To enter editing mode,
i insert before
a insert after
A insert end of line
To go back to command mode,
ESC
Cursor
h left
j down (remember: just like J goes down!)
k up
l right
Edit,
x delete
rX replace one caracter by X
ce (de a) replace until the end of the word
c$ replace until the end of the line
Write,
:w filename
:wq
:x
Exit without saving,
:q!
Undo/Redo,
u undo
U redo
Links