" =========== " VARIABLES " =========== runtime bundle/vim-pathogen/autoload/pathogen.vim execute pathogen#infect('bundle-active/{}') set nocompatible "Disable bell set vb set t_vb= set ttimeoutlen=10 let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#branch#enabled = 1 let g:airline#extensions#whitespace#enabled = 1 let g:airline_powerline_fonts = 1 let g:completor_clang_binary = '/usr/bin/clang' "All things cursor set guicursor+=a:blinkon0 "disable blinking if &term =~ "xterm\\|rxvt" " 1 or 0 -> blinking block " 2 -> solid block " 3 -> blinking underscore " 4 -> solid underscore " 5 -> blinking vertical bar " 6 -> solid vertical bar let &t_SI .= "\[6 q" " Normal let &t_EI .= "\[2 q" " Insert endif "show line endings and tabs set listchars=tab:>\ ,trail:~,extends:>,precedes:< set list " Use todo#Complete as the omni complete function for todo files au filetype todo setlocal omnifunc=todo#Complete " Auto complete projects au filetype todo imap + + " Auto complete contexts au filetype todo imap @ @ " leader let mapleader = "-" let leader = "-" let maplocalleader = "-" syntax on filetype plugin indent on "Line number Highlight set nu rnu highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE set foldmethod=syntax " ============== " SHORTCUTS " ============== "Switch windows with keys "nmap :wincmd k "nmap :wincmd j "nmap :wincmd h "nmap :wincmd l nmap :vsplit:e . nmap :e . nnoremap @=(foldlevel('.')?'za':"\") vnoremap zf au filetype c* nmap :Make au filetype sh nmap :Runbuffer au filetype python nmap :Runbuffer au filetype *tex nmap :Makelatex au filetype *tex nmap :Openpdf nmap :Newterm nmap :NERDTreeToggle nmap :TlistToggle "Tab mgmt nmap gc :tabclose nmap gn :tabnew:e . "tmap " Smart brackets inoremap "" "" inoremap '' '' inoremap () () inoremap [] [] inoremap {} {} inoremap { {}O inoremap {; {};O " completor inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap Tab_Or_Complete() " =========== " COMMANDS " =========== command -bar Suw :w !SUDO_ASKPASS="/usr/lib/ssh/ssh-askpass" sudo -A tee % " Command HEXMODE command -bar Hexmode call ToggleHex() "^] Jump to tag, ^t jump back command! MakeTags !ctags -R . command -bar Newterm call Run_in_terminal("") command -bar Runbuffer call Run_in_terminal(expand("%:p")) command -bar Make call Run_in_terminal("make run") command -bar Fileheader call Insert_Header(expand("%")) command -bar Makelatex silent! execute "!(pdflatex % > /dev/null 2>&1 && killall -s SIGHUP mupdf)&" | redraw! command Openpdf silent! execute "!mupdf " . (join(split(expand("%"), '\.')[:-2], ".") . ".pdf") . " > /dev/null 2>&1 &" | redraw! " =========== " FUNCTIONS " =========== function Insert_Header(name) let l:name=systemlist("git config --global --get user.name")[0] let l:mail=systemlist("git config --global --get user.email")[0] call append("0", ["/*", " * ".a:name, " * (c) ".strftime("%Y")." ".l:name." <".l:mail.">", " * License: All rights reserved.", " */"]) startinsert endfunction function Run_in_terminal(prog) if !has('terminal') return endif tabnew execute "terminal ++curwin " . a:prog startinsert endfunction " Use TAB to complete when typing words, else inserts TABs as usual. Uses " dictionary, source files, and completor to find matching words to complete. " Note: usual completion is on but more trouble to press all the time. " Never type the same word twice and maybe learn a new spellings! " Use the Linux dictionary when spelling is in doubt. function! Tab_Or_Complete() abort " If completor is already open the `tab` cycles through suggested completions. if pumvisible() return "\" " If completor is not open and we are in the middle of typing a word then " `tab` opens completor menu. elseif col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^[[:keyword:][:ident:]]' return "\=completor#do('complete')\" else " If we aren't typing a word and we press `tab` simply do the normal `tab` " action. return "\" endif endfunction " helper function to toggle hex mode function ToggleHex() " hex mode should be considered a read-only operation " save values for modified and read-only for restoration later, " and clear the read-only flag for now let l:modified=&mod let l:oldreadonly=&readonly let &readonly=0 let l:oldmodifiable=&modifiable let &modifiable=1 if !exists("b:editHex") || !b:editHex " save old options let b:oldft=&ft let b:oldbin=&bin " set new options setlocal binary " make sure it overrides any textwidth, etc. silent :e " this will reload the file without trickeries "(DOS line endings will be shown entirely ) let &ft="xxd" " set status let b:editHex=1 " switch to hex editor %!xxd else " restore old options let &ft=b:oldft if !b:oldbin setlocal nobinary endif " set status let b:editHex=0 " return to normal editing %!xxd -r endif " restore values for modified and read only state let &mod=l:modified let &readonly=l:oldreadonly let &modifiable=l:oldmodifiable endfunction