The original VIsual editor

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
Vim Home : www.vim.org/
The Traditional Vi : ex-vi.sourceforge.net/
Nvi Home : www.kotnet.org/~skimo/nvi/devel/
Levee Home : www.pell.portland.or.us/~orc/Code/levee/
The One True Editor : www.pell.portland.or.us/~orc/Code/vi/


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
Vi Tips and techniques : www.csci.csusb.edu/dick/samples/vi.notes.html
(FR) Aide-mémoire Vi : www.epons.org/vi.php
The True Path : www.rants.org/ed.html
vim doc www.ph.unimelb.edu.au/~ssk/vim/insert.html


Home | UNIX | Oracle | Code | Practical | Private | Donate | Print | html/css
© 2010 Pierre-Philipp Braun