" Source: https://git.hiddenalpha.ch/dotfiles.git/tree/src/vi/_vimrc if has("win32") set diffexpr=MyDiff() function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif if $VIMRUNTIME =~ ' ' if &sh =~ '\ ' . arg3 if exists('l:shxq_sav') let &shellxquote=l:shxq_sav endif endfunction function Formatxml() " @author hiddenalpha.ch if !empty( glob($USERPROFILE."/bin/xmllint.exe") ) echo "xmllint --format" silent %!set xmllint_indent=" " & \%userprofile\%/bin/xmllint --format - else echo "vimscript --format (WARNING: values trimmed)" %j! " ganze Datei auf eine Zeile %s~>\s*<~><~g " Trim content und zwischenraum %s~<~\r<~g " Jeden Tag auf eine neue Zeile %g~^\s*$~d " alle leerZeilen entfernen %g!~>$~j! " überall, wo text (also kein Tag) am ende Steht mach join if line('$') < 500 " einrückung erstellen (filetype muss auf xml sein) " nur bis 500 Zeilen. sonst wirds langsam. norm gg=G endif endif endfunction else " NOT win32 function Formatxml() " @author hiddenalpha.ch if !empty( glob("/usr/bin/xmllint") ) echo "xmllint --format" silent %!XMLLINT_INDENT=" " /usr/bin/xmllint --format - else echo "vimscript --format" %j! " ganze Datei auf eine Zeile %s~>\s*<~><~g " Trim content und zwischenraum %s~<~\r<~g " Jeden Tag auf eine neue Zeile %g~^\s*$~d " alle leerZeilen entfernen %g!~>$~j! " überall, wo text (also kein Tag) am ende Steht mach join if line('$') < 500 " einrückung erstellen (filetype muss auf xml sein) norm gg=G endif endif endfunction endif colorscheme koehler set autoindent set clipboard= set backspace=2 set encoding=utf-8 set fileformat=unix set fileformats=unix, dos set linebreak set nobackup set nowritebackup set noswapfile set fo=jlnroq fo-=t set textwidth=72 set number set hidden " <- Allow to switch buffer even it is not saved. set ruler set hlsearch set scrolloff=1 " <- Keep free lines top/bottom before/after cursor set showcmd set listchars=eol:$,tab:>- set showbreak=↳\ "set wildmenu "set laststatus=2 " 2: Always display filename "set statusline+=%F " '- With full path set spelllang=en,de set sidescroll=8 syntax on " indent ---------------------------------------------------------------------- set expandtab set tabstop=4 set shiftwidth=4 set autoindent set nosmartindent vnoremap > >gv vnoremap >gv vnoremap < <,,0,) command -nargs=? -range=% Tab2Space call IndentConvert(,,1,) " misc ------------------------------------------------------------------------ " Quickly switch windows nnoremap j nnoremap k nnoremap h nnoremap l " Set window title nnoremap :set titlestring= nnoremap :set titlestring= " close buffer nnoremap :bp:bd# " change pwd to current file nnoremap cdc :cd %:p:h:pwd " Execute previous one now :cd %:p:h " Not searchNext. Do only highlight word under cursor. "nmap * *N nnoremap * viw"9yb/9 " save with ctrl-s nmap :up " NERDTree -------------------------------------------------------------------- " Setup instructions see: "https://hiddenalpha.ch/slnk/id/1:6185e48" "set rtp+=/opt/nerdtree "source /opt/nerdtree/plugin/NERD_tree.vim "nnoremap ° :NERDTreeToggle " OS integration -------------------------------------------------------------- if has("win32") " insert current TS inoremap =strftime('%Y%m%d%H%M%S') "inoremap =strftime('%Y-%m-%d_%H:%M:%S%z') command OsTerminal !start cmd.exe command OsFileExplorer !start explorer.exe . else " Insert a hash inoremap =system("head -c32 /dev/urandom\|base64\|tr -d '\n=+/'\|head -c16") " insert current TS inoremap =strftime('%Y-%m-%d_%H:%M:%S%z') command OsTerminal !x-terminal-emulator & command OsFileExplorer !x-file-manager `pwd` & command OsFirefox !firefox `pwd` & command OsChromium !chromium `pwd` & endif " filetype specific ----------------------------------------------------------- autocmd FileType html setl sw=2 ts=2 autocmd FileType xml setl sw=2 ts=2 autocmd BufNewFile,BufRead Makefile setl noexpandtab list autocmd FileType c setl colorcolumn=101 autocmd FileType java setl colorcolumn=101 autocmd FileType lua setl colorcolumn=101 autocmd FileType js setl colorcolumn=101 autocmd FileType text setl ft=awk autocmd BufNew,BufRead *.gnuplot setl ft=gnuplot autocmd BufNew,BufRead *.yaml,*.yml setl ts=2 sw=2 autocmd BufNew,BufRead *.json, setl ts=2 sw=2 autocmd BufNewFile,BufRead *.ts setl ft=javascript autocmd BufNewFile,BufRead *.pom setl ft=xml