UP | HOME

vim

Vim

http://majorursa.net/hide_vi.jpg

Vi Commands

vi key combocommand
:q!quit without saving
:wqwrite and quit
:qquit
:%s/oldword/newword/gsubstitute all oldword occurences with newword in entire file
:lslist buffers
:b1switch to buffer 1
:bnswitch to buffer n
:vsvertically split window (create side by side windows)
dwdelete word
d$delete to end of line
dddelete current line
.repeat last change
yycopy, yank line into buffer
ppaste the line in buffer after cursor position
cwchange word
uundo!
iinsert mode
<Esc>escape, exit insert mode
/VirtualHostsearch file for phrase "VirtualHost"
nmove to next occurence of search phrase
100Gmove to 100th line
1Gmove to first line
Gmove to last line

add to .screenrc to get Color Schemes working

attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
term screen-256color-bce

.vimrc

" Colors!!
set t_Co=256

" color theme
" colors zenburn
colors calmar256-dark

set showmode "show current mode down the bottom

"Setting the status line...

set statusline=%f       "tail of the filename

"display a warning if the file format isn't Unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*

"display a warning if file encoding isn't UTf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*

set statusline+=%h      "help file flag
set statusline+=%y      "filetype
set statusline+=%r      "read only flag
set statusline+=%m      "modified flag
syntax on

Window Commands

C-w sSplit window horizontally
C-w vSplit window vertically
C-w xExchange windows
C-w wjump to next window
:onlykill all windows but current
C-w =equalize all window sizes

Edit Keys: used with argument

c change

  • cw = change word

d delete

  • d$ delete til end of line

r replace

  • r5 replace 5 chars

y yank

  • yy yank entire line