PlanetXML

VIM Konfiguration

Hier einige Ausschnitte aus meiner .vimrc:

Toolbar und Menüs abschalten für mehr Platz

set guioptions-=t
set guioptions-=T
set guioptions-=m
set guioptions+=M

Farbschema und Größe einstellen

Helles Farbschema in der GUI, dunkles Schema in der Konsole. Die GUI auf Vollbildgröße bringen (Zeilen und Spalten müssten je nach Schriftart angepast werden).

if has("gui_running")
    winpos 0 0
    set lines=47
    set columns=141
    colorscheme jhlight
else
    colorscheme jhdark
endif

XML-Tags vervollständigen

Statt der schließenden spitzen Klammer einfach ALT und '.' oder ',' drücken.

" add -.: to iskeyword
autocmd FileType xml,xsd,xslt,xhtml setlocal iskeyword+=45,46,58
" complete block tag
autocmd FileType xml,xsd,xslt,xhtml,html,php inoremap <buffer> <M-.> ><ESC>T<yiwf>a<CR>>/<C-R>"><C-O>O
" complete inline tag
autocmd FileType xml,xsd,xslt,xhtml,html,php inoremap <buffer> <M-,> ><ESC>T<yiwf>a</<C-R>"><ESC>F<i

XML-Entities einfacher eingeben

autocmd FileType xml,xsd,xslt,xhtml,html,php,aspvbs inoremap <buffer> <M-&> &amp;
autocmd FileType xml,xsd,xslt,xhtml,html,php,aspvbs inoremap <buffer> <M-<> &lt;
autocmd FileType xml,xsd,xslt,xhtml,html,php,aspvbs inoremap <buffer> <M->> &gt;
autocmd FileType xml,xsd,xslt,xhtml,html,php,aspvbs inoremap <buffer> <M-'> &apos;
autocmd FileType xml,xsd,xslt,xhtml,html,php,aspvbs inoremap <buffer> <M-"> &quot;

Mappings für einfache Schleifen

Eingabe von fori<10 in einer Java-Datei ergibt:
for (int i=0; i<10; i++) {
    |
}

autocmd FileType c,cs,cpp,java,javascript inoreab <buffer> fori for (int i=0; i; i++) {<CR>}<UP><END><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>

autocmd FileType c,cs,cpp,java,javascript inoreab <buffer> forj for (int j=0; j; j++) {<CR>}<UP><END><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>

autocmd FileType python inoreab <buffer> fori for i in range():<LEFT><LEFT>
autocmd FileType python inoreab <buffer> forj for j in range():<LEFT><LEFT>

Vervollständigen von Klammern und Anführungszeichen

autocmd FileType c,cs,cpp,java,javascript,php inoremap <buffer> { {<CR>}<C-O>O
autocmd FileType python,tex,bib,antlr inoremap <buffer> { {}<LEFT>
autocmd FileType c,cs,cpp,java,javascript,php,python,text,html,xml,xslt,antlr inoremap <buffer> [ []<LEFT>

autocmd FileType c,cs,cpp,java,javascript,php,python,text,html,xml,xslt,antlr inoremap <buffer> ( ()<LEFT>
autocmd FileType c,cs,cpp,java,javascript,php,python,text,html,xml,xslt,antlr inoremap <buffer> " ""<LEFT>
autocmd FileType c,cs,cpp,java,javascript,php,python,text,html,xml,xslt,antlr inoremap <buffer> ' ''<LEFT>

" Typographische Anführungszeichen für Latex
autocmd FileType tex inoremap <buffer> " „“<LEFT>
autocmd FileType tex inoremap <buffer> ' ‚‘<LEFT>

Explorer oder Konsole in aktuellem Verzeichnis


if (has("netbeans_intg") || has("sun_workshop"))
    set autochdir
endif

nmap <leader>e :silent !start explorer %:p:h:gs?\/?\\\\\\?<CR>
nmap <leader>c :silent !start cmd %:p:h:gs?\/?\\\\\\?<CR>

Angepasste Statuszeile

" Always show statusline
set laststatus=2
set noruler
" Show buffer number, filetype, fileformat and fileencoding in statusline
set statusline=[%n]\ [%f]\ %w%y%r%m[%{&fileformat}][%{&fileencoding}]\ %=\ %l/%L,%-5c\ %P\