Nethence Documentation Lab Webmail Your IP BBDock  


Those documents are obsolete, please use the Nethence Documentation instead.

HomeUnixWindowsOracleObsoleteHardwareDIYMechanicsScriptsConfigsPrivate

The 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
 
With VIM only, convert file to UNIX format,
:set ff=unix
Note. as for DOS format,
:set ff=dos
 
 
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
Vim Home
The Traditional Vi
Nvi Home
Levee Home
The One True Editor
 
 
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
 
 
References
http://www.csci.csusb.edu/dick/samples/vi.notes.html
(FR) http://www.epons.org/vi.php
http://www.rants.org/ed.html
http://www.ph.unimelb.edu.au/~ssk/vim/insert.html
http://gergap.wordpress.com/2009/05/29/minimal-vimrc-for-cc-developers/
http://lfs.traduc.org/view/blfs-5.1-fr/postlfs/vimrc.html
http://www.jonlee.ca/hacking-vim-the-ultimate-vimrc/
 

Last update: Apr 16, 2011