Openstuff Wiki : VIRef

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Quick reference for VI text editor

Display commands

:colorscheme <colors>   change color scheme (ex: default)
:set cursorline         marks the entire current line
:set cursorcolumn       marks the entire column
:set number             adding line numbers
:set list               display unprintable characters (:set nolist to stop this)


:abbreviate            abbreviation for all modes
:iabbrev               abbreviation for insert mode
:cabbrev               abbreviation for command line mode
:source $VIM/abb.vim   load abbreviation from a file

Move Commands

In normal mode:
g,        go to previous changes location
g;        moves forward through changes
( or )    beginning or end of the sentence
{ or }    beginning or end of the paragraph
gd       goto declaration (or first occurrence) of the variable

To navigate line by line on wrapped text:
g up/down arrow   up/down one screen lines

Or whith mapping: press Up and Down on a wrapped line, get you to the next line on the screen instead of the next physical line
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk 


Text markers:
 ma             marks a location with marker "a"
 'a             go to marker "a" (go to the beginning of the line)
 :marks         list current marks
 :delmarks a    delete mark "a"

Visible markers:
:sign define piet text=>> texthl=Search

:map <F7> :exe ":sign place 123 line=" . line(".") ." name=piet file=" . expand("%:p")<CR>
:map <F8> :exe ":sign unplace 123 file=" . expand("%:p")<CR>
:map <F9> :exe ":sign jump 123 file=" . expand("%:p")<CR>

Undo, Redo

u            undo
control-r    redo


/mystring      search for "mystring"
:%s/aaa/AAA/gc replace each "aaa" occurrence by "AAA" (ask confirmation)
:%s/aaa/AAA/g  replace each "aaa" occurrence by "AAA" (no confirmation)


]p                indent paste
<<                left shift
>>                right shift
<visual mode> =   ident selected text
1G=G              ident all file
:set ai           autoident


qa        record keystrokes into register a
q         stop keystroke recording
@a        execute keystrokes from register a


:set foldmethod=indent


:map h1 yypVr=0

This is a test


control-p         word completion in insert mode

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0585 seconds