Created
September 24, 2012 12:57
-
-
Save anonymous/3775816 to your computer and use it in GitHub Desktop.
vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" vim: foldmethod=marker textwidth=0 fillchars=fold\:\ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"set runtimepath+=,/home/wu/.vim/latex-suite/ | |
set noswapfile | |
"" Systemabhängig {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Suchen die folgenden Begriffe in der Datei und kalibrieren sie | |
"" bei jedem neuen Einsatz in einem Fremdsystem | |
" | |
" set guifont | |
" set termencoding | |
" set helplang | |
" set spelllang | |
" set mouse | |
" | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" GUI Allgemeine Einstellung {{{ | |
" set guifont=AR\ PL\ UMing\ CN\ Light\ 13 | |
" set guifont=文泉驿等宽正黑\ Medium\ 13 | |
" set guifont=DejaVu\ Sans\ Mono\ Book\ 12 | |
set guioptions+=a | |
set guioptions+=t " Popup menu | |
" set guioptions-=m " Menü | |
set guioptions-=T " Toolbar | |
set winaltkeys=no | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Allgemeine Einstellung {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible | |
set nobackup " do not keep a backup file, use versions instead | |
set whichwrap+=<,> | |
" set showbreak= | |
"" set off the time out for nmap, imap, cmap | |
set notimeout | |
set ttimeout | |
"" Tags | |
set tags+=../tags,../../tags | |
if has("gui_running") | |
set mouse=a | |
else | |
set mouse= | |
endif | |
set backspace=indent,eol,start | |
set history=50 " keep 50 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
"set incsearch " do incremental searching | |
if has("autocmd") | |
filetype plugin indent on | |
endif | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" encoding {{{ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"set fileencodings=utf-8,cp936,gb18030,gbk,big5,iso8859-1,ucs-2,ucs-bom,latin1 | |
set fileencodings=utf-8,cp936,big5,ucs-bom,latin1,gbk,ucs-2,iso8859-1 | |
set encoding=utf8 | |
set fileformats=unix,dos | |
set termencoding=utf-8 | |
"set termencoding=gbk | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Locale und Sprachen {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"setlocal spelllang=de | |
set spelllang=de ",en_us | |
set helplang=cn | |
"language en | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Aussehen {{{ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Mein Farbenthma {{{ | |
if has("gui_running") | |
"{{{ | |
set background=light | |
if version > 580 | |
highlight clear | |
if exists("syntax_on") | |
syntax reset | |
endif | |
endif | |
if v:version >= 700 | |
highlight CursorColumn guibg=Grey90 gui=NONE | |
highlight CursorLine guibg=Grey90 gui=NONE | |
highlight Pmenu guibg=LightMagenta gui=NONE | |
highlight PmenuSel guibg=Grey gui=NONE | |
highlight PmenuSbar guibg=Grey gui=NONE | |
highlight PmenuThumb gui=NONE | |
highlight TabLine guibg=LightGrey gui=underline | |
highlight TabLineFill gui=reverse | |
highlight TabLineSel gui=bold | |
if has('spell') | |
highlight SpellBad guifg=#FFFFFF guibg=#FF0000 gui=undercurl | |
highlight SpellCap guifg=#FFFFFF guibg=#0000FF gui=undercurl | |
highlight SpellLocal gui=undercurl | |
highlight SpellRare gui=undercurl | |
endif | |
endif | |
highlight Cursor guifg=bg guibg=fg gui=NONE | |
highlight CursorIM gui=NONE | |
highlight DiffAdd guibg=LightBlue gui=NONE | |
highlight DiffChange guibg=LightMagenta gui=NONE | |
highlight DiffDelete guifg=Blue guibg=LightCyan gui=bold | |
highlight DiffText guibg=Red gui=bold | |
highlight Directory guifg=Blue gui=NONE | |
highlight ErrorMsg guifg=White guibg=Red gui=NONE | |
highlight FoldColumn guifg=#000AFF guibg=#0013FF gui=NONE | |
highlight Folded guifg=#000AFF guibg=#FF6A00 gui=NONE | |
highlight IncSearch gui=reverse | |
highlight LineNr guifg=#0C00B4 guibg=#FF9D3B gui=NONE | |
highlight MatchParen guifg=#FFFFFF guibg=#0400FF gui=NONE | |
highlight ModeMsg gui=bold | |
highlight MoreMsg guifg=SeaGreen gui=bold | |
highlight NonText guifg=Blue gui=bold | |
highlight Normal guifg=#000000 guibg=#FFB469 gui=NONE | |
highlight Question guifg=#1100FF guibg=#12F303 gui=bold | |
highlight Search guifg=#000000 guibg=Yellow gui=NONE | |
highlight SignColumn guifg=DarkBlue guibg=Grey gui=NONE | |
highlight SpecialKey guifg=Blue gui=NONE | |
highlight StatusLine guifg=#0029FF gui=bold,reverse | |
highlight StatusLineNC guifg=#000000 gui=reverse | |
highlight Title guifg=Magenta gui=bold | |
highlight VertSplit guifg=#E78D24 guibg=bg gui=reverse | |
highlight Visual guibg=#FD6B5B gui=underline | |
highlight VisualNOS gui=bold,underline | |
highlight WarningMsg guifg=Red gui=NONE | |
highlight WildMenu guifg=Black guibg=Yellow gui=NONE | |
highlight link Boolean Constant | |
highlight link Character Constant | |
highlight Comment guifg=#0C9800 gui=NONE | |
highlight link Conditional Statement | |
highlight Constant guifg=#FF0003 gui=NONE | |
highlight link Debug Special | |
highlight link Define PreProc | |
highlight link Delimiter Special | |
highlight Error guifg=White guibg=Red gui=NONE | |
highlight link Exception Statement | |
highlight link Float Number | |
highlight link Function Identifier | |
highlight Identifier guifg=DarkCyan gui=NONE | |
highlight Ignore guifg=#0600FF gui=NONE | |
highlight link Include PreProc | |
highlight link Keyword Statement | |
highlight link Label Statement | |
highlight link Macro PreProc | |
highlight link Number Constant | |
highlight link Operator Statement | |
highlight link PreCondit PreProc | |
highlight PreProc guifg=#159E00 gui=bold,reverse | |
highlight link Repeat Statement | |
highlight Special guifg=#E100B8 gui=NONE | |
highlight link SpecialChar Special | |
highlight link SpecialComment Special | |
highlight Statement guifg=#0600FF gui=bold | |
highlight link StorageClass Type | |
highlight link String Constant | |
highlight link Structure Type | |
highlight link Tag Special | |
highlight Todo guifg=#FFFFFF guibg=#EE6B29 gui=bold | |
highlight Type guifg=#0097B3 gui=bold | |
highlight link Typedef Type | |
highlight Underlined guifg=#888888 gui=underline | |
"}}} | |
else | |
colorscheme desert | |
endif | |
"" }}} | |
"set shiftwidth=4 | |
"set tabstop=4 | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
set hlsearch | |
endif | |
set nu | |
"set cursorline | |
"set nowrap | |
set textwidth=0 | |
"set fillchars=fold:\ | |
set fillchars=fold:~ | |
set foldtext=getline(v:foldstart).'\ \ <'.(v:foldend-v:foldstart).'>' | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Match Overline {{{ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" kontrollieren, dass eine Zeile innerhalb 80 Zeichen hat. | |
highlight OverLength ctermbg=red ctermfg=white guibg=#592929 | |
function! MatchOverLength() | |
call UnmatchOverLength() | |
let w:m_overlength = matchadd("OverLength", "\\%81v.\\+") | |
endfunction | |
function! UnmatchOverLength() | |
if exists("w:m_overlength") | |
call matchdelete(w:m_overlength) | |
unlet w:m_overlength | |
endif | |
endfunction | |
"" Match Overline as default? | |
" call MatchOverLength() | |
autocmd FileType c call MatchOverLength() | |
autocmd FileType cpp call MatchOverLength() | |
autocmd FileType perl call MatchOverLength() | |
autocmd FileType haskell call MatchOverLength() | |
autocmd FileType vim call MatchOverLength() | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" kontrollieren, dass kein leerzeichen am ende einer Zeile steht {{{ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"match ERROR /\s\+$/ | |
call matchadd("ERROR", "\\s\\+$") | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Abkürzungen {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
ab inlcude include | |
ab cosnt const | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Allgemeine Bindungen {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
noremap <silent><C-L> :nohlsearch<CR><C-L> | |
map <F2> :help function-list<CR> | |
map <F9> :make<CR> | |
map <silent><F10> :call ToggleQuickfix()<CR> | |
" map ><F11> :cclose<CR> | |
"map <F11> :cnext<CR> | |
map Y y$ | |
command! -nargs=* W w <args> | |
command! -nargs=0 Wsudo w !sudo tee % | |
if has("gui_running") | |
map <silent><C-Z> :shell<CR> | |
endif | |
"" für klapp | |
map <silent><F8> :call Change_fold_method()<CR> | |
function! Change_fold_method() | |
if &foldmethod == "manual" | |
set foldmethod=syntax | |
echo "set fold by syntax" | |
elseif &foldmethod == "syntax" | |
set foldmethod=indent | |
echo "set fold by indent" | |
elseif &foldmethod == "indent" | |
set foldmethod=marker | |
echo "set fold by marker" | |
elseif &foldmethod == "marker" | |
set foldmethod=manual | |
echo "set fold by manual" | |
endif | |
endfunction | |
"" für die nicht-deutsche Tastatur mit deutschem Layout | |
map W < | |
map W < | |
map E > | |
map <C-X>W <C-X>< | |
map <C-X>E <C-X>> | |
map <C-X>w <C-X>< | |
map <C-X>e <C-X>> | |
inoremap <C-F> <C-R>=ListZeichen()<CR> | |
function! ListZeichen() | |
call complete(col('.'), ['<', '>', '|', '^', '!', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', "'", '°', '{', '[', ']', '}', '#', '+', '~', '*', 'ß', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü']) | |
return '' | |
endfunction | |
map <UP> gk | |
map <DOWN> gj | |
map <C-W><C-M> <C-W><C-_> | |
"" Manche VI-Version hat Problem bei K, deshalb bind ich eine alternative: | |
"map K wbywo<ESC>pI:!man <ESC>"zdd@z | |
"" für die neue Tab-Eigenschaft in Vim7 | |
map <C-W>0 :tabnew<CR> | |
map <C-W>1 :tabnext 1<CR> | |
map <C-W>2 :tabnext 2<CR> | |
map <C-W>3 :tabnext 3<CR> | |
map <C-W>4 :tabnext 4<CR> | |
map <C-W>5 :tabnext 5<CR> | |
map <C-W>6 :tabnext 6<CR> | |
map <C-W>7 :tabnext 7<CR> | |
map <C-W>8 :tabnext 8<CR> | |
map <C-W>9 :tabnext 9<CR> | |
"" für Emacs kompatibel | |
map <C-X><C-S> :w<CR> | |
"map <C-X><C-C> :q<CR> | |
map <C-X><C-B> :buffers<CR> | |
map <C-X>b :buffer | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Autocmd: FileType {{{ | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" vim / vimhelp {{{ | |
autocmd FileType help set nu | |
" }}} | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Tex / LaTeX {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:use_latex_suite = 0 | |
if g:use_latex_suite | |
"{{{ | |
autocmd FileType tex call s:LatexSuiteMode() | |
function! s:LatexSuiteMode() | |
"" Für Latex Suite | |
set shiftwidth=2 | |
set grepprg=grep\ -nH\ $* | |
set shellslash | |
filetype plugin on | |
filetype indent on | |
let g:tex_flavor='pdflatex' | |
let g:Tex_DefaultTargetFormat = 'pdf' | |
let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode $*' | |
" let &l:makeprg = 'pdflatex --interaction=nonstopmode $*' | |
" let g:tex_ignore_makefile = 1 | |
endfunction | |
"}}} | |
else | |
" My Latex Mode {{{ | |
autocmd FileType tex call s:LatexMode() | |
function! s:LatexMode() "{{{ | |
setlocal spell | |
" call Hunspell_Enable() | |
" call Hunspell_Buffer() | |
setlocal expandtab | |
setlocal shiftwidth=2 | |
setlocal autoindent | |
setlocal iskeyword+=: | |
setlocal iskeyword+=_ | |
imap <buffer><silent><TAB> <C-R>=HaskellTab()<CR> | |
call UnmatchOverLength() | |
let g:tex_flavor='pdflatex' | |
" let g:tex_ignore_makefile = 1 | |
compiler tex | |
"" if use this, can not use `make clean` any more | |
" let &l:makeprg = 'pdflatex --interaction=nonstopmode ' . expand("%:p") | |
let &l:makeprg = 'make' | |
noremap <buffer><silent><C-J> <ESC>:call LatexGotoNextMark()<CR> | |
inoremap <buffer><silent><C-J> <C-R>=LatexGotoNextMark()<CR> | |
imap <buffer><F7> <C-R>=LatexInsert()<CR> | |
" call LatexSuiteMode() | |
" Falten Latex Ohne LatexSuite | |
" runtime ftplugin/tex/TexFold.vim | |
" runtime ftplugin/tex/TexSyntaxFold.vim | |
" call MakeTexFolds(1) | |
set omnifunc=LatexRefComplete | |
" Shortkeys {{{ | |
"" Environment for Table and Figure {{{ | |
" FIXME: sollte in die <F7> Funktion eingebaut. | |
"""""""""""""""""""" | |
"" without smart indent: | |
" inoremap <buffer> EFI \begin{figure}[<++>]<CR> \centering<CR>\includegraphics*[<++>]{<++>}<CR>\caption{<++>}<CR>\label{<++>}<CR><BS><BS>\end{figure}<CR>%<ESC>6k0:call LatexGotoNextMark()<CR> | |
"""""""""""""""""""" | |
"" with smart indent: | |
inoremap <buffer> EFI \begin{figure}[<++>]<CR>\centering<CR>\includegraphics*[<++>]{<++>}<CR>\caption{<++>}<CR>\label{<++>}<CR><BS><BS>\end{figure}<CR>%<ESC>6k0:call LatexGotoNextMark()<CR> | |
"""""""""""""""""""" | |
"" without smart indent: | |
" inoremap <buffer> ET \begin{table}[<++>]<CR> \begin{center}<CR>\begin{tabular}{<++>}<CR> <++><CR><BS><BS>\end{tabular}<CR>\caption{<++>}<CR>\label{<++>}<CR>\end{center}<CR><BS><BS>\end{table}<CR>%<ESC>9k0:call LatexGotoNextMark()<CR> | |
"""""""""""""""""""" | |
"" with smart indent: | |
inoremap <buffer> ET \begin{table}[<++>]<CR>\centering<CR>\begin{tabular}{<++>}<CR><++><CR><BS><BS>\end{tabular}<CR>\caption{<++>}<CR>\label{<++>}<CR><BS><BS>\end{table}<CR>%<ESC>9k0:call LatexGotoNextMark()<CR> | |
"" }}} | |
"" tja, mit den folgenden Zeilen habe ich viele Varianten versucht, | |
"" aber für Kompatibilität mit der Gewöhnlichkeit von C oder anderen | |
"" Sprachen, nutze ich die automatische $$ [] und {} nicht | |
inoremap <buffer> $$ $<++>$<++><ESC>2F$:call LatexGotoNextMark()<CR> | |
inoremap <buffer> {} {<++>}<++><ESC>F{:call LatexGotoNextMark()<CR> | |
inoremap <buffer> [] [<++>]<++><ESC>F[:call LatexGotoNextMark()<CR> | |
inoremap <buffer> () (<++>)<++><ESC>F(:call LatexGotoNextMark()<CR> | |
inoremap <buffer> \[\] \[ <++> \]<++><ESC>F[:call LatexGotoNextMark()<CR> | |
inoremap <buffer> ,, {,} | |
inoremap <buffer> ,0 {,}0 | |
inoremap <buffer> ,1 {,}1 | |
inoremap <buffer> ,2 {,}2 | |
inoremap <buffer> ,3 {,}3 | |
inoremap <buffer> ,4 {,}4 | |
inoremap <buffer> ,5 {,}5 | |
inoremap <buffer> ,6 {,}6 | |
inoremap <buffer> ,7 {,}7 | |
inoremap <buffer> ,8 {,}8 | |
inoremap <buffer> ,9 {,}9 | |
"}}} | |
setlocal indentexpr=TeXIndent() | |
setlocal nosmartindent | |
setlocal indentkeys+=},=\\item,=\\bibitem | |
endfunction "}}} | |
let s:LatexRefTable = [] | |
function! LatexGetRefTable(code) "{{{ | |
" erzeugen die Tabelle von \label | |
for line in a:code | |
" rekursiv in die \include & \input Dateien | |
if line =~ '\\\label{[^}]\+}' | |
" TODO: jetzt wird nur das erste \label in der Zeile | |
let line = substitute(line, '^.\{-}\label{\s*\([^}]\{-1,}\)\s*}.*$', '\1', '') | |
call add(s:LatexRefTable, line) | |
elseif line =~ '^.\{-}\%(\input\|\include\)\s*{\s*[^}]\{-1,}\s*}.*$' | |
"" in andere Dateien | |
let line = substitute(line, '^.\{-}\%(\input\|\include\)\s*{\s*\([^}]\{-1,}\s*\)}.*$', '\1', "") | |
if line !~ '\.tex$' | |
let line .= '.tex' | |
endif | |
call LatexGetRefTable(readfile(line)) | |
endif | |
endfor | |
endfunction "}}} | |
function! LatexRefComplete(findstart, base) "{{{ | |
if a:findstart | |
let line = getline('.') | |
let line = strpart(line, 0, col('.') - 1) | |
" vorsicht! \\\( muss 3 \ haben | |
" $ ist hier kein Zeileende | |
if line =~ '^.\{-}\\\%(page\)\?ref\s*{\s*[^}]*$' | |
let length = strlen( substitute(line, '^\(.\{-}\\\%(page\)\?ref\s*{\)\s*[^}]*$', '\1', "")) | |
let key = substitute(line, '^.\{-}\\\%(page\)\?ref\s*{\s*\([^}]*\)$', '\1', "") | |
" TODO: fill the RefTable | |
call LatexGetRefTable(getline(1,'$')) | |
let i = 0 | |
while i < len(s:LatexRefTable) | |
if stridx(s:LatexRefTable[i], key) != 0 " oder == -1 | |
call remove(s:LatexRefTable, i) | |
else | |
let i += 1 | |
endif | |
endwhile | |
return length | |
else | |
let s:LatexRefTable = [] | |
return -1 | |
endif | |
else | |
return s:LatexRefTable | |
endif | |
endfunction "}}} | |
" Tabelle für <F7>-Insert-Funktion {{{ | |
"" nur für die Ausdrücke mit mehrer "{}" | |
let s:LatexInsertTabList = [ | |
\ ["\multicolumn", "\\multicolumn{Anzahl<++>}{Format<++>}{<++>}<++>"], | |
\ ["\multirow", "\\multirow{zeilen<++>}*{<++>}<++>"], | |
\ ["align", "\\begin{align}<++>"], | |
\ ["array", "\\begin{array}{<++>}<++>"], | |
\ ["begin", "\\begin{<++>}<++>"], | |
\ ["block", "\\begin{block}{<++>}<++>"], | |
\ ["caption", "\\caption{<++>}<++>"], | |
\ ["center", "\\begin{center}<++>"], | |
\ ["cfrac", "\\cfrac{<++>}{<++>}<++>"], | |
\ ["cite", "\\cite{<++>}<++>"], | |
\ ["comment", "\\begin{comment}<++>"], | |
\ ["dfrac", "\\dfrac{<++>}{<++>}<++>"], | |
\ ["displaymath", "\\begin{displaymath}<++>"], | |
\ ["document", "\\begin{document}<++>"], | |
\ ["end", "\\end{<++>}<++>"], | |
\ ["enumerate", "\\begin{enumerate}<++>"], | |
\ ["eqnarray", "\\begin{eqnarray}<++>"], | |
\ ["equation", "\\begin{equation}<++>"], | |
\ ["exampleblock", "\\begin{exampleblock}{<++>}<++>"], | |
\ ["figure", "\\begin{figure}[<++>]<++>"], | |
\ ["flushleft", "\\begin{flushleft}[<++>]"], | |
\ ["footnote", "\\footnote{<++>}<++>"], | |
\ ["footnotetext", "\\footnotetext{<++>}<++>"], | |
\ ["frac", "\\frac{<++>}{<++>}<++>"], | |
\ ["frame", "\\begin{frame}{<++>}<++>"], | |
\ ["framebox", "\\framebox{<++>}<++>"], | |
\ ["frametitle", "\\frametitle{<++>}<++>"], | |
\ ["hat", "\\hat{<++>}<++>"], | |
\ ["hspace", "\\hspace{<++>}<++>"], | |
\ ["include", "\\include{<++>}<++>"], | |
\ ["includegraphics", "\\includegraphics[clip<++>]{<++>}<++>"], | |
\ ["index", "\\index{<++>}<++>"], | |
\ ["input", "\\input{<++>}<++>"], | |
\ ["invisible", "\\invisible<<++>>{<++>}"], | |
\ ["itemize", "\\begin{itemize}<++>"], | |
\ ["label", "\\label{<++>}<++>"], | |
\ ["lstinline", "\\lstinline!<++>!<++>"], | |
\ ["lstlisting", "\\begin{lstlisting}<++>"], | |
\ ["mathbf", "\\mathbf{<++>}<++>"], | |
\ ["mathrm", "\\mathrm{<++>}<++>"], | |
\ ["mbox", "\\mbox{<++>}<++>"], | |
\ ["minipage", "\\begin{minipage}[tbcs<++>]{0.49\\textwidth}<++>"], | |
\ ["onslide", "\\onslide<<++>>{<++>}"], | |
\ ["overline", "\\overline{<++>}<++>"], | |
\ ["paragraph", "\\paragraph{<++>}<++>"], | |
\ ["ref", "\\ref{<++>}<++>"], | |
\ ["section", "\\section{<++>}<++>"], | |
\ ["sqrt", "\\sqrt{<++>}<++>"], | |
\ ["stackrel", "\\stackrel{<++>}{<++>}<++>"], | |
\ ["subequations", "\\begin{subequations}<++>"], | |
\ ["subparagraph", "\\subparagraph{<++>}<++>"], | |
\ ["subsection", "\\subsection{<++>}<++>"], | |
\ ["subsubsection", "\\subsubsection{<++>}<++>"], | |
\ ["table", "\\begin{table}[<++>]<++>"], | |
\ ["tabular", "\\begin{tabular}{<++>}<++>"], | |
\ ["uncover", "\\uncover<<++>>{<++>}"], | |
\ ["underline", "\\underline{<++>}<++>"], | |
\ ["verbatim", "\\begin{verbatim}<++>"], | |
\ ["vspace", "\\vspace{<++>}<++>"], | |
\] | |
"" }}} | |
function! LatexGotoNextMark() " {{{ | |
" if search('<+[^+]*+>') != 0 | |
if search('<++>') != 0 | |
let pos = getpos(".") | |
let col = pos[2] | |
let text_akt_zeile = getline(".") | |
let text_vor = strpart(text_akt_zeile, 0, col - 1) | |
" lösch 4 zeichen: | |
let text_nach = strpart(text_akt_zeile, col + 3) | |
let text_akt_zeile = text_vor . text_nach | |
call setline(".", text_akt_zeile) | |
startinsert | |
call setpos(".", pos) | |
endif | |
return "" | |
endfunction " }}} | |
function! LatexInsertTabListComplete(ArgLead, CmdLine, CursorPos) "{{{ | |
" prepare the insert table completion for <F7> | |
let list_ret = [] | |
for [abk, ersatz] in s:LatexInsertTabList | |
if stridx(abk, a:ArgLead) == 0 | |
let list_ret += [abk] | |
endif | |
endfor | |
return list_ret | |
endfunction "}}} | |
function! LatexInsert() "{{{ | |
let eingabe = input("einzufügen: ","","customlist,LatexInsertTabListComplete") | |
for [abk, ersatz] in s:LatexInsertTabList | |
if eingabe == abk | |
let text_akt_zeile = getline(".") | |
let col = col(".") | |
let text_vor = strpart(text_akt_zeile, 0, col - 1) | |
let text_nach = strpart(text_akt_zeile, col - 1) | |
let text_akt_zeile = text_vor . ersatz . text_nach | |
call setline(".", text_akt_zeile) | |
" call append(".", text_akt_zeile) | |
call LatexGotoNextMark() | |
return "" | |
endif | |
endfor | |
" echo "Die Abkürzung \"".eingabe."\" ist leider nicht definiert" | |
return "" | |
endfunction "}}} | |
" "" Fold Debug FIXME: {{{ | |
" map <silent><F4> :call LatexFakeSyntaxFoldScan()<cr> | |
" | |
" function! LatexFakeSyntaxFoldScan() | |
" call LatexFakeSyntaxFoldWithSubstitution(0, line("$"), "^\\([^%]\|\\\\%\\)*\\\\begin{\\s*\\([^}]\\+\\)\\s*}", "\\\\\\\\end\\\\s*{\\\\s*\\2\\\\s*}") | |
" endfunction | |
" | |
" function! LatexFakeSyntaxFoldWithSubstitution(line_start, line_end, pat_start, pat_end) | |
" let line_current=a:line_start | |
" | |
" echo "line_start \t".a:line_start | |
" | |
" while line_current <= a:line_end | |
" let text_current = getline(line_current) | |
" | |
" if match(text_current, a:pat_start) != -1 | |
" let line_fold_start = line_current | |
" "" find match end | |
" let pat_end_expand = substitute(text_current, a:pat_start, a:pat_end, "") | |
" let text_current = getline(line_current) | |
" | |
" "" Debug | |
" " echo "line_current: ". line_current." text_current: ".text_current | |
" " if stridx(text_current,"end") != -1 | |
" " echo "pat_start: ".a:pat_start." pat_end:".pat_end_expand | |
" " echo "text_current: ".text_current | |
" " endif | |
" | |
" while match(text_current, pat_end_expand) == -1 && (line_current <= a:line_end) | |
" let line_current = line_current + 1 | |
" let text_current = getline(line_current) | |
" if match(text_current, a:pat_start) != -1 | |
" "" recurse | |
" let line_current = LatexFakeSyntaxFoldWithSubstitution(line_current + 1, a:line_end, a:pat_start, a:pat_end) | |
" endif | |
" endwhile | |
" | |
" if line_current > a:line_end | |
" "return -1 | |
" return line_current | |
" endif | |
" | |
" echo "Falten von ".line_fold_start. " bis ".line_current | |
" | |
" exec "normal ".line_fold_start."G".(1 + line_current - line_fold_start)."zF" | |
" endif | |
" let line_current = line_current + 1 | |
" endwhile | |
" return line_current | |
" endfunction | |
"" Debug end }}} | |
function! TexTab() "{{{ | |
"" zurzeit gleich wie HaskellTab | |
if line(".") == 1 | |
return "" | |
endif | |
let letzte_zeile = getline(line(".") - 1) | |
let cursor_spalt = virtcol(".") | |
let springen_nach = matchend(letzte_zeile, "[ \\t]\\+", cursor_spalt) | |
if springen_nach <= cursor_spalt | |
"" schon am rechten Rand | |
return "" | |
else | |
return repeat(" ", 1 + springen_nach - cursor_spalt) | |
endif | |
endfunction " }}} | |
function! TeXIndent() "{{{ | |
" Find a non-blank line above the current line. | |
let lnum = prevnonblank(v:lnum - 1) | |
" At the start of the file use zero indent. | |
if lnum == 0 | return 0 | |
endif | |
let ind = indent(lnum) | |
let line = getline(lnum) " last line | |
let cline = getline(v:lnum) " current line | |
" Do not change indentation of commented lines. | |
if line =~ '^\s*%' | |
return ind | |
endif | |
" Add a 'shiftwidth' after beginning of environments. | |
" Don't add it for \begin{document} and \begin{verbatim} | |
""if line =~ '^\s*\\begin{\(.*\)}' && line !~ 'verbatim' | |
" LH modification : \begin does not always start a line | |
if line =~ '\\begin{\(.*\)}' && line !~ 'verbatim' | |
\ && line !~ 'document' | |
let ind = ind + &sw | |
if g:tex_indent_items == 1 | |
" Add another sw for item-environments | |
if line =~ 'itemize\|description\|enumerate\|thebibliography' | |
let ind = ind + &sw | |
endif | |
endif | |
endif | |
" Subtract a 'shiftwidth' when an environment ends | |
if cline =~ '^\s*\\end' && cline !~ 'verbatim' | |
\&& cline !~ 'document' | |
if g:tex_indent_items == 1 | |
" Remove another sw for item-environments | |
if cline =~ 'itemize\|description\|enumerate\|thebibliography' | |
let ind = ind - &sw | |
endif | |
endif | |
let ind = ind - &sw | |
endif | |
" Special treatment for 'item' | |
" ---------------------------- | |
if g:tex_indent_items == 1 | |
" '\item' or '\bibitem' itself: | |
if cline =~ '^\s*\\\(bib\)\=item' | |
let ind = ind - &sw | |
endif | |
" lines following to '\item' are intented once again: | |
if line =~ '^\s*\\\(bib\)\=item' | |
let ind = ind + &sw | |
endif | |
endif | |
return ind | |
endfunction "}}} | |
" My Latex Mode End}}} | |
endif | |
"" Für Filetype Latex }}} | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" C++ {{{ | |
autocmd FileType cpp set expandtab | |
autocmd FileType cpp set tabstop=2 | |
autocmd FileType cpp set tabstop=2 | |
autocmd FileType cpp set shiftwidth=2 | |
"" }}} | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" perl {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" do not fold as syntax, to make it possible editing large perl code | |
autocmd FileType perl setlocal foldmethod=indent | |
let perl_fold = 1 | |
let perl_extended_vars = 1 | |
"" }}} | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Haskell {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
autocmd FileType haskell call s:HaskellMode() | |
function! s:HaskellMode() | |
set iskeyword+=' | |
set shiftwidth=4 | |
set autoindent | |
set expandtab | |
set tabstop=4 | |
imap <buffer><silent><TAB> <C-R>=TexTab()<CR> | |
inoremap <buffer><silent><C-X><C-X> {- -}<ESC>2hi | |
"map o o<TAB> | |
"map O O<TAB> | |
call matchadd("ERROR", "\\t") | |
" '\' in {-comments-} would cause a wrong highlight. fixed with: | |
syntax sync fromstart | |
"" Third party scripts | |
" source ~/.vim/scripts/haskellcomplete.vim | |
" set omnifunc=haskellcomplete#CompleteHaskell | |
endfunction | |
function! HaskellTab() | |
if line(".") == 1 | |
return "" | |
endif | |
let letzte_zeile = getline(line(".") - 1) | |
let cursor_spalt = virtcol(".") | |
let springen_nach = matchend(letzte_zeile, "[ \\t]\\+", cursor_spalt) | |
if springen_nach <= cursor_spalt | |
"" schon am rechten Rand | |
return "" | |
else | |
return repeat(" ", 1 + springen_nach - cursor_spalt) | |
endif | |
endfunction | |
"" }}} Haskell | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" gnuplot {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
autocmd FileType gnuplot call s:GnuplotMode() | |
function! s:GnuplotMode() | |
let &l:makeprg = 'gnuplot ' . expand("%:p") | |
endfunction | |
"" }}} | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" html {{{ | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
autocmd FileType html call s:HtmlMode() | |
highlight InsertFlag ctermbg=green ctermfg=red guibg=green guifg=red | |
function! s:HtmlMode() | |
let b:R = '→++←' " Place Holder | |
let b:m_InsertFlag = matchadd("InsertFlag", b:R) | |
noremap <buffer><silent><C-J> <ESC>:call HtmlGotoNextMark()<CR> | |
inoremap <buffer><silent><C-J> <C-R>=HtmlGotoNextMark()<CR> | |
imap <buffer><F7> <C-R>=HtmlInsert()<CR> | |
inoremap <buffer><silent><F4> <C-R>=HtmlInsertGeneralFlag()<CR> | |
inoremap <buffer><silent><F5> <→++←>→++←<ESC>9h:call HtmlGotoNextMark()<CR> | |
inoremap <buffer><silent><F6> </→++←>→++←<ESC>10h:call HtmlGotoNextMark()<CR> | |
endfunction | |
" Tabelle für <F7>-Insert-Funktion {{{ | |
"" nur für die Ausdrücke mit mehrer "{}" | |
let s:HtmlInsertTabList = [ | |
\ ["table", "<table →++←>→++←</table>→++←"], | |
\ ["td", "<td →++←>→++←</td>→++←"], | |
\ ["tr", "<tr →++←>→++←</tr>→++←"], | |
\ ["font", "<font →++←>→++←</font>→++←"], | |
\ ["li", "<li>→++←</li>→++←"], | |
\ ["ul", "<ul →++←>→++←</ul>→++←"], | |
\ ["ol", "<ol →++←>→++←</ol>→++←"], | |
\ ["h1", "<h1>→++←</h1>→++←"], | |
\ ["h2", "<h2>→++←</h2>→++←"], | |
\ ["h3", "<h3>→++←</h3>→++←"], | |
\ ["h4", "<h4>→++←</h4>→++←"], | |
\ ["h5", "<h5>→++←</h5>→++←"], | |
\ ["h6", "<h6>→++←</h6>→++←"], | |
\ ["br", "<br>→++←"], | |
\ ["hr", "<hr →++←>→++←"], | |
\ ["p", "<p>→++←</p>→++←"], | |
\ ["a", "<a →++←>→++←</a>→++←"], | |
\ ["b", "<b>→++←</b>→++←"], | |
\ ["i", "<i>→++←</i>→++←"], | |
\ ["em", "<em>→++←</em>→++←"], | |
\ ["comment", "<!--→++←-->→++←"], | |
\ ["body", "<body→++←</body>→++←"], | |
\ ["head", "<head→++←</head>→++←"], | |
\ ["html", "<html→++←</html>→++←"], | |
\] | |
"" }}} | |
function! HtmlInsertTabListComplete(ArgLead, CmdLine, CursorPos) "{{{ | |
" prepare the insert table completion for <F7> | |
let list_ret = [] | |
for [abk, ersatz] in s:HtmlInsertTabList | |
if stridx(abk, a:ArgLead) == 0 | |
let list_ret += [abk] | |
endif | |
endfor | |
return list_ret | |
endfunction "}}} | |
function! HtmlInsertGeneralFlag() "{{{ | |
let str = '<'. b:R . '>' . b:R . '</' . b:R . '>' | |
let text_akt_zeile = getline(".") | |
let col = col(".") | |
let text_vor = strpart(text_akt_zeile, 0, col - 1) | |
let text_nach = strpart(text_akt_zeile, col - 1) | |
let text_akt_zeile = text_vor . str . text_nach | |
call setline(".", text_akt_zeile) | |
call HtmlGotoNextMark() | |
return "" | |
endfunction "}}} | |
function! HtmlInsert() "{{{ | |
let eingabe = input("einzufügen: ","","customlist,HtmlInsertTabListComplete") | |
for [abk, ersatz] in s:HtmlInsertTabList | |
if eingabe == abk | |
let text_akt_zeile = getline(".") | |
let col = col(".") | |
let text_vor = strpart(text_akt_zeile, 0, col - 1) | |
let text_nach = strpart(text_akt_zeile, col - 1) | |
let text_akt_zeile = text_vor . ersatz . text_nach | |
call setline(".", text_akt_zeile) | |
" call append(".", text_akt_zeile) | |
call HtmlGotoNextMark() | |
return "" | |
endif | |
endfor | |
" echo "Die Abkürzung \"".eingabe."\" ist leider nicht definiert" | |
return "" | |
endfunction "}}} | |
function! HtmlGotoNextMark() " {{{ | |
" if search('<+[^+]*+>') != 0 | |
if search(b:R) != 0 | |
let pos = getpos(".") | |
let col = pos[2] | |
let text_akt_zeile = getline(".") | |
let text_vor = strpart(text_akt_zeile, 0, col - 1) | |
" lösch 4 zeichen: | |
let text_nach = strpart(text_akt_zeile, col + len(b:R) - 1) | |
let text_akt_zeile = text_vor . text_nach | |
call setline(".", text_akt_zeile) | |
startinsert | |
call setpos(".", pos) | |
endif | |
return "" | |
endfunction " }}} | |
"" }}} | |
"" }}} von FileType | |
""============================================================================= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Kommentar umsetzen {{{ | |
" b:comment_prefix is the variable, contains the comment mark for the current | |
" language, | |
" for C++ / java, it is // | |
" for tex, it is % | |
" for haskell, it is -- | |
" for perl / sh , it is # | |
" " default with # | |
function! Set_default_comment_prefix() | |
if exists('b:comment_prefix') == 0 | |
let b:comment_prefix='#' | |
let b:comment_prefix_inregex='#' | |
endif | |
endfunction | |
" autocmd BufNewFile * call Set_default_comment_prefix() | |
" autocmd BufNew * call Set_default_comment_prefix() | |
autocmd BufEnter * call Set_default_comment_prefix() | |
autocmd BufReadPre * call Set_default_comment_prefix() | |
" FIXME: b:comment_prefix 可能含转义 !! | |
autocmd FileType tex let b:comment_prefix='%' | let b:comment_prefix_inregex='%' | |
autocmd FileType matlab let b:comment_prefix='%' | let b:comment_prefix_inregex='%' | |
autocmd FileType vim let b:comment_prefix='"' | let b:comment_prefix_inregex='"' | |
autocmd FileType haskell let b:comment_prefix='--' | let b:comment_prefix_inregex='--' | |
autocmd FileType c let b:comment_prefix='//' | let b:comment_prefix_inregex='//' | |
autocmd FileType cpp let b:comment_prefix='//' | let b:comment_prefix_inregex='//' | |
autocmd FileType dosini let b:comment_prefix=';' | let b:comment_prefix_inregex=';' | |
autocmd FileType dosbatch let b:comment_prefix='rem' | let b:comment_prefix_inregex='rem' | |
autocmd FileType xdefaults let b:comment_prefix='!' | let b:comment_prefix_inregex='!' | |
autocmd FileType feko let b:comment_prefix='**' | let b:comment_prefix_inregex='\*\*' | |
autocmd FileType mp let b:comment_prefix='%' | let b:comment_prefix_inregex='%' | |
autocmd FileType bib let b:comment_prefix='%' | let b:comment_prefix_inregex='%' | |
autocmd FileType postscr let b:comment_prefix='%' | let b:comment_prefix_inregex='%' | |
" FIXME: fehler bei wiederhohlen | |
nmap <silent><C-X>> :call Nmap_line_comment()<CR> | |
nmap <silent><C-X>< :call Nmap_line_uncomment()<CR> | |
vmap <silent><C-X>> :call Vmap_block_comment()<CR> | |
vmap <silent><C-X>< :call Vmap_block_uncomment()<CR> | |
iabbrev fixme <C-R>=b:comment_prefix<CR> FIXME: | |
iabbrev todo <C-R>=b:comment_prefix<CR> TODO: | |
function! Nmap_line_comment() | |
call Vmap_block_comment() | |
endfunction | |
function! Nmap_line_uncomment() | |
call Vmap_block_uncomment() | |
endfunction | |
function! Vmap_block_comment() | |
let pat = '^\(\s*\)' | |
let sub = '\1'.b:comment_prefix_inregex.' ' | |
"" Extra Leerzeichen ist für die Sprachen wie Haskell, | |
"" in der '--|' ist ein sonderfall für haddock, | |
"" so lass es '-- |' | |
"" aber sollte keine Leerzeichen am Ende einer Zeile bleiben | |
let line = getline('.') | |
if len(line) != 0 | |
let line = substitute(line, pat, sub, '') | |
call setline('.',line) | |
" else | |
"" leere Zeile | |
" call setline('.',b:comment_prefix) | |
endif | |
endfunction | |
function! Vmap_block_uncomment() | |
let pat = '^\(\s*\)'.b:comment_prefix_inregex.'\s*' | |
let sub = '\1' | |
let line = getline('.') | |
let line = substitute(line, pat, sub, '') | |
call setline('.',line) | |
endfunction | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Automatische Ergänzung beim Druck der Retrun-Taste {{{ | |
let g:ExternReturn = 1 | |
if g:ExternReturn != 0 | |
autocmd FileType c inoremap <buffer> <CR> <SPACE><ESC>:call ExtendReturn_c()<CR>a<BS><CR> | |
autocmd FileType cpp inoremap <buffer> <CR> <SPACE><ESC>:call ExtendReturn_c()<CR>a<BS><CR> | |
autocmd FileType perl inoremap <buffer> <CR> <SPACE><ESC>:call ExtendReturn_c()<CR>a<BS><CR> | |
autocmd FileType tex inoremap <buffer> <CR> <SPACE><ESC>:call ExtendReturn_tex()<CR>a<BS><CR> | |
endif | |
function! ExtendReturn_c() | |
if g:ExternReturn != 0 | |
let pos = getpos(".") | |
let line = getline(".") | |
if pos[2] == len(line) | |
if line =~ '{\s*$' | |
" call append(".", "}") | |
let recht_klammer = substitute (line, '^\(\s*\).*$', '\1}', '') | |
call append(".", recht_klammer) | |
endif | |
endif | |
if line =~ '^[\t ][\t ]*$' | |
call setline(".", "\n") | |
normal $ | |
endif | |
endif | |
endfunction | |
function! ExtendReturn_tex() | |
if g:ExternReturn != 0 | |
let pos = getpos(".") | |
let line = getline(".") | |
if pos[2] == len(line) | |
"" automatisch ergänzen \end{etwas} für \begin{} Befehl in Latex | |
"if line =~ '\\begin\s*{[^}]\+}\(\s*\[[^]]\+\]\|\s*{[^}]\+}\)*\s*' | |
if line =~ '\\begin\s*{[^}]\+}\(\s*\[[^]]*\]\|\s*{[^}]*}\)*\s*' | |
"let end_statement = substitute(line, '^\(\s*\).*\\begin\(\s*\){\([^}]\+\)}\(\s*\[[^]]\+\]\|\s*{[^}]\+}\)*\s*$', '\1\\end\2{\3}', '') | |
let end_statement = substitute(line, '^\(\s*\).*\\begin\(\s*\){\([^}]\+\)}\(\s*\[[^]]*\]\|\s*{[^}]*}\)*\s*$', '\1\\end\2{\3}', '') | |
if end_statement != line | |
let status = append(".", end_statement) | |
endif | |
endif | |
endif | |
if line =~ '^[\t ][\t ]*$' | |
call setline(".", "\n") | |
normal $ | |
endif | |
endif | |
endfunction | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" GUI Change Directory {{{ | |
command! CD call CD() | |
function! CD() | |
if strlen(@%) > 0 | |
cd %:h | |
endif | |
endfunction | |
"" automatisch Arbeitspfade wechseln, bei vim neu starten | |
if has ("gui_running") | |
CD | |
endif | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" toggle qucikfix window {{{ | |
" TODO: a function, that toggle the quickfix window | |
function! ToggleQuickfix () | |
let opened = 0 | |
let buflist = tabpagebuflist() | |
for bufnum in buflist | |
if getbufvar(bufnum, '&buftype') == "quickfix" | |
let opened = 1 | |
endif | |
endfor | |
if opened == 1 | |
cclose | |
else | |
" cwindow | |
copen | |
endif | |
endfunction | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" match Todo , Fixme .... {{{ | |
function! GrepTodo() | |
if exists('b:comment_prefix_inregex') == 0 | |
let b:comment_prefix_inregex = '' | |
endif | |
let todo_pattern = '\c' . b:comment_prefix_inregex . '\s*' . 'TODO' | |
let cmd = 'vimgrep /' . todo_pattern . '/g %' | |
exec cmd | |
endfunction | |
function! GrepFixme() | |
if exists('b:comment_prefix_inregex') == 0 | |
let b:comment_prefix_inregex = '' | |
endif | |
let todo_pattern = '\c' . b:comment_prefix_inregex . '\s*' . 'FIXME' | |
let cmd = 'vimgrep /' . todo_pattern . '/g %' | |
exec cmd | |
endfunction | |
nmap <silent><C-X><C-T> :call GrepTodo()<CR>:cwindow<CR> | |
nmap <silent><C-X><C-F> :call GrepFixme()<CR>:cwindow<CR> | |
"" }}} | |
"" metapost | |
autocmd FileType mp call s:mp_mode() | |
function s:mp_mode() | |
setlocal makeprg=mpost\ % | |
set shiftwidth=2 | |
set tabstop=2 | |
set expandtab | |
endfunction | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Feko {{{ | |
autocmd BufNewFile,BufRead *.pre set filetype=feko | |
autocmd filetype feko call Feko() | |
function! Feko() | |
"" Syntax Highlight | |
set syntax=feko | |
" if exists("b:current_syntax") | |
" finish | |
" endif | |
syn case ignore | |
syn match fekoComment '^\*\*.*$' | |
syn match fekoNumber '\<[+-]\?\d\+\(\.\d\+\)\?\([eE][+-]\?\d\+\)\?\|\<[+-]\?\.\(\d\+\)\?\([eE][+-]\?\d\+\)\?' | |
syn region fekoString start=+L\="+ end=+"+ | |
syn match fekoError '^\s\+.*$' | |
syn match fekoMacro '^!!\s*\w\S\+' | |
syn match fekoCard '^\w\S' | |
syn keyword fekoFunction then sin cos tan cot arcsin arccos | |
\ atan2 arccot sinh cosh tanh besj besy besi | |
\ besk sqrt log ln exp abs deg rad step ceil | |
\ floor max min fmod x_coord y_coord z_coord | |
\ fileread and or not defined | |
syn match fekoCompare '[<>]=\?\|=\|<>' | |
syn match fekoVar '#\w\+' | |
syn match fekoConstant '\#\(pi\|eps0\|mu0\|c0\|zf0\|true\|false\)' | |
hi def link fekoComment Comment | |
hi def link fekoString String | |
hi def link fekoError Error | |
hi def link fekoNumber Number | |
hi def link fekoMacro Macro | |
hi def link fekoCard Statement | |
hi def link fekoFunction Operator | |
hi def link fekoCompare Operator | |
hi def link fekoConstant Constant | |
hi def link fekoVar Identifier | |
let b:current_syntax = "feko" | |
" setlocal makeprg=runfeko\ %\ --run-from-gui | |
setlocal makeprg=runfeko\ % | |
let b:current_compiler = "feko" | |
autocmd filetype qf call HighlightFekoLog() | |
endfunction | |
function! HighlightFekoLog () | |
syn case ignore | |
syn match fekoLogError '^\W*error.*$' | |
syn match fekoLogWarning '^\W*WARNING.*$' | |
syn match fekoLogNote '^\W*NOTE.*$' | |
syn match fekoLogPrint '^\W*PRINT.*$' | |
hi def link fekoLogError Error | |
hi def link fekoLogWarning Macro | |
hi def link fekoLogNote Comment | |
hi def link fekoLogPrint Comment | |
endfunction | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Hunspell {{{ | |
let g:language = "de_DE" | |
let g:hunspell_prog = "hunspell" | |
"" hook the space key and check the word before space | |
function! Hunspell_Enable () | |
if ! exists('b:missspell_id') | |
let b:missspell_id = [] | |
endif | |
if ! exists('b:missspell') | |
let b:missspell = [] | |
endif | |
inoremap <silent><buffer><SPACE> | |
\<ESC>:call | |
\ Hunspell_Cursor(expand("<cword>"))<CR>a<SPACE> | |
endfunction | |
"" stop to hook the space key | |
function! Hunspell_Disable () | |
call Hunspell_Clear() | |
iunmap <buffer><SPACE> | |
endfunction | |
"" check a word | |
function! Hunspell_Cursor (word) | |
if strlen(a:word) == 0 | |
return | |
elseif strlen(matchstr(a:word, '^[a-zA-zäöüÄÖÜß]\+$')) == 0 | |
return | |
endif | |
let missspell_word = system('echo ' . a:word . ' | ' | |
\ . g:hunspell_prog\ | |
\ . ' -l -t -d ' | |
\ . g:language) | |
let missspell_word = s:chomp(missspell_word) | |
if index(b:missspell, missspell_word) < 0 | |
let pattern = '\<'. missspell_word .'\>' | |
call add(b:missspell, pattern) | |
call add(b:missspell_id, matchadd('Error', pattern)) | |
endif | |
endfunction | |
"" check the whole buffer | |
function! Hunspell_Buffer () | |
if exists('b:missspell_id') | |
call map(b:missspell_id, 'matchdelete(v:val)') | |
let b:missspell_id = [] | |
endif | |
let missspell = system('hunspell -l -t -d ' | |
\ . g:language . ' ' | |
\ . expand("%:p")) | |
let b:missspell = s:unique(split(missspell)) | |
let b:missspell_id = deepcopy(b:missspell) | |
call map(b:missspell_id, 'matchadd("Error", "\\<".v:val."\\>")') | |
endfunction | |
"" clear the spell errors | |
function! Hunspell_Clear () | |
if exists('b:missspell_id') | |
call map(b:missspell_id, 'matchdelete(v:val)') | |
let b:missspell_id = [] | |
endif | |
if exists('b:missspell') | |
let b:missspell = [] | |
endif | |
endfunction | |
map <silent><F5> <ESC>:call Hunspell_Buffer()<CR> | |
map <silent><C-F5> <ESC>:call Hunspell_Clear()<CR> | |
map <silent><F6> <ESC>:call Hunspell_Enable()<CR> | |
map <silent><C-F6> <ESC>:call Hunspell_Disable()<CR> | |
"" }}} | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"" Help Functions {{{ | |
function! s:unique (list) | |
let result = [] | |
for i in a:list | |
if index(result, i) < 0 | |
call add(result, i) | |
endif | |
endfor | |
return result | |
endfunction | |
function! s:chomp (var) | |
return substitute(a:var, '[\s\r\n]*$', '', '') | |
endfunction | |
"" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment