set nohls "set ic " ignore case on searching set is set showmatch set textwidth=70 set smartindent " determine termencoding from locale and fix encoding to Unicode let &termencoding=&encoding set encoding=utf-8 "set encoding=iso-8859-15 set wildmenu let mapleader = ',' "set mouse=a " syntax highlightning syntax enable hi Comment ctermfg=darkgreen hi Statement ctermfg=blue hi Type ctermfg=darkyellow hi Identifier ctermfg=darkmagenta hi clear Special hi link Special Constant hi SpellErrors ctermfg=red " Enable and disable paste mode set pastetoggle= noremap gqap "-- Programming languages ------------------------------------------- function PreviewWord() if &previewwindow " don't do this in the preview window return endif let w = expand("") " get the word under cursor if w != "" " if there is one ":ptag" to it " Delete any existing highlight before showing another tag silent! wincmd P " jump to preview window if &previewwindow " if we really get there... match none " delete existing highlight wincmd p " back to old window endif " Try displaying a matching tag for the word under the cursor let v:errmsg = "" exe "silent! ptag " . w if v:errmsg =~ "tag not found" return endif silent! wincmd P " jump to preview window if &previewwindow " if we really get there... if has("folding") silent! .foldopen " don't want a closed fold endif call search("$", "b") " to end of previous line let w = substitute(w, '\\', '\\\\', "") call search('\<\V' . w . '\>') " position cursor on match " Add a match highlight to the word at this position hi previewWord term=bold ctermbg=green guibg=green exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' wincmd p " back to old window endif endif endfunction function s:ProgLangSettings() set shiftwidth=4 set softtabstop=4 set formatoptions=tcq set expandtab set wildignore=*.exe,*.o,*~ set textwidth=79 noremap :update :make "noremap :Tlist "noremap :TlistUpdate set updatetime=500 "au! CursorHold * nested call PreviewWord() "set previewheight=3 endfunction autocmd FileType c,cpp,java,html,xml,wml,php,tex,vim,perl,sh,changelog,prolog,ocaml,cs,yacc,python :call ProgLangSettings() autocmd BufNewFile,BufRead *.jay set filetype=yacc autocmd FileType python :set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class autocmd FileType debchangelog :set nofoldenable autocmd FileType debchangelog :setlocal comments=bf:* "-- Set markers for compiler errors -------------------------------------------- autocmd QuickFixCmdPost make call SetErrorMarkers() function s:SetErrorMarkers() let &balloonexpr = "" . s:SID() . "_ErrorMessageBalloons()" set ballooneval sign define errorsign text=EE linehl=Todo sign unplace * let l:i = 1 for d in getqflist() if (d.bufnr == 0 || d.lnum == 0) continue endif execute ":sign place " . l:i . " line=" . d.lnum . \ " name=errorsign file=" . bufname(d.bufnr) let l:i = l:i + 1 endfor endfunction function s:ErrorMessageBalloons() for d in getqflist() if (d.bufnr == v:beval_bufnr && d.lnum == v:beval_lnum) return d.text endif endfor return "" endfunction function s:SID() return matchstr (expand (''), '\zs\d\+\ze_SID$') endfun "-- LaTeX --------------------------------------------------------------------- function! s:TexQuotes() let insert = '"'."'" let left = getline(line("."))[col(".")-2] if left =~ '^\(\|\s\)$' let insert = '"`' elseif left == '\' let insert = '"' endif return insert endfunction function! s:RunLatex() update exe "silent ! elatex \\\\nonstopmode \\\\input\\{%\\} > /dev/null" call NextTexError() endfunction function! s:RunPDFLatex() update exe "silent ! pdflatex \\\\nonstopmode \\\\input\\{%\\} > /dev/null" call NextTexError() endfunction function! s:RunBibtex() update exe "silent ! bibtex %<" endfunction function! s:NextTexError() silent only split +1 %<.log if search('^l\.\d') == 0 bwipeout call input("\nNo (More) Errors Found\n\nPress 'enter' to go on.") else syntax clear syntax match err /! .*/ syn match err /^ l\.\d.*\n.*$/ highlight link err ToDo let linenumber = matchstr(getline('.'), '\d\+') let errorposition = col("$") - strlen(linenumber) - 5 if errorposition < 1 let command = "normal " . linenumber . "Gzz\wzz\w" else let command = "normal " . linenumber . "G" . errorposition . "lzz\wzz\w" endif "Put a space in the .log file so that you can see where you were, "and move on to the next latex error. s/^/ / write wincmd x exe command endif endfunction function s:TexItem() if getline(".") =~ '^\s*$' return '\item ' else return "\\\item " endif endfunction " Delete two characters if an umlaut is last character function s:TexBackspace() if getline(".")[col(".")-3] =~ '"' return "\\" else return "\" endif endfunction " ask for an environment to insert and to that function s:TexEnv() let e = input( "Environment: " ) if e != "" exe "normal a\\begin{" . e . "}\\\end{" . e . "}\k$" endif startinsert! endfunction " document templates function s:TexTemplate1() normal a\documentclass[DIV12,halfparskip]{scrartcl} normal o\usepackage[utf8]{inputenc} normal o\usepackage[ngerman]{babel} normal o normal o\begin{document} normal o\end{document} normal 5GO startinsert! endfunction function s:TexTemplate2() normal a\documentclass[11pt,a4paper]{dinbrief} normal o\usepackage{a4wide} normal o\usepackage{ngerman} normal o normal o\begin{document} normal o normal o\Absender{ Martin Pitt\\ normal o Baluschekstr. 5\\ normal o01159 Dresden\\ normal oTel. (0351) 4 24 15 58} normal o normal o\Retouradresse{Martin Pitt, Baluschekstr. 5, 01159 Dresden} normal o normal o\subject{\textbf{}} normal o normal o\signature{Martin Pitt} normal o normal o\Datum{Dresden, \today} normal o normal o\begin{letter}{ \\ normal o \par normal o } normal o normal o\opening{Sehr geehrte Damen und Herren,} normal o normal o% \encl{} normal o\closing{Mit freundlichen Gr"u"sen} normal o\end{letter} normal o\end{document} normal 20G2f{l startinsert endfunction function s:LaTeXSettings() set textwidth=79 set encoding=utf-8 " Template and environment hotkeys noremap :call TexTemplate1() noremap :call TexTemplate2() imap i \begin{itemize}\end{itemize}Oa imap e \begin{enumerate}\end{enumerate}Oa inoremap t \begin{tabular}{}\end{tabular}kkf{li inoremap d \begin{description}\end{description}O inoremap v :call TexEnv() " Smart quotes inoremap " =TexQuotes() " Shortcuts inoremap a =TexItem() inoremap inoremap -> $\to $ inoremap <- $\leftarrow $ inoremap <-> $\leftrightarrow $ inoremap =TexBackspace() " Compiling and viewing noremap p :call RunPDFLatex() noremap e NextTexError() noremap b :call RunBibtex() noremap v :update :exe "! evince %<.pdf 2>&1 >/dev/null&" "noremap รค :update :exe "! xdvi -display :0 %< 2>&1 > /dev/null&" endfunction autocmd FileType tex :call LaTeXSettings() autocmd FileType plaintex :call LaTeXSettings() " -- XML ------------------------------------------------------------- function s:XMLTemplate1() normal a normal o normal o normal o normal o normal o normal o normal o normal o normal o normal o normal o normal o normal 12G startinsert! endfunction function s:XMLSettings() set encoding=utf-8 noremap :call XMLTemplate1() let b:unaryTagsStack="" source ~/.vim/closetag.vim endfunction autocmd FileType xml,xsl,wml,html,xhtml,php :call XMLSettings()