" Vim configuration " Author: Mad " Last Revision: Saturday, 19. December 2015 17:51 set nocompatible filetype off " --- init vundle {{{ set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " --- Let Vundle manage Vundle Plugin 'VundleVim/Vundle.vim' " }}} " --- My plugins {{{ Plugin 'scrooloose/nerdtree' " FileBrowser on the left side Plugin 'ervandew/supertab' "Auto completion Plugin 'ap/vim-templates' "File templates Plugin 'godlygeek/tabular' "Tabularize Plugin 'MarcWeber/vim-addon-mw-utils' " Dependency for snipmate Plugin 'tomtom/tlib_vim' "Dependency for snipmate Plugin 'garbas/vim-snipmate' "Snippets Plugin 'easymotion/vim-easymotion' "Easy Motion Plugin 'kana/vim-textobj-user' "User defined text objects Plugin 'kana/vim-textobj-indent' "Indent based text objects Plugin 'benmills/vimux' "Tmux integration Plugin 'vim-scripts/argtextobj.vim' "function argument textobj Plugin 'rstacruz/sparkup' "quick html writing Plugin 'ap/vim-buftabline' "Buffer as tabline Plugin 'vim-scripts/L9' "dependency for FuzzyFinder Plugin 'vim-scripts/FuzzyFinder' "Fuzzy finding Plugin 'cohama/lexima.vim' "Auto pairs Plugin 'tpope/vim-surround' "Vim surround Plugin 'vim-scripts/rfc-syntax' " RFC Syntax highlight " }}} " --- End init vundle {{{ call vundle#end() filetype plugin indent on " }}} " --- General configurations {{{ set whichwrap+=<,>,[,] set autoread "auto read file if changed set wildmenu "Command completion set gdefault " substitute all by default set noruler set laststatus=2 " Add Status line always set number "Show linenumbers set backspace=eol,start,indent "Make backspace behave like it's supposed to set incsearch "Search while typing pattern set lazyredraw "No redrawing while running macros set magic "Allow magic modelines set showmatch set mat=2 set noerrorbells "No visual nuisance set novisualbell set t_vb= set tm=500 set encoding=utf8 "Always use utf8 set ffs=unix,dos,mac " Auto use EOL according to file set noswapfile set noexpandtab " No spaces just Tabs set smarttab " Deleting and creating spaces representing tabs set ai "auto indent set si "smart indent set wrap "wrap lines set shiftwidth=4 set tabstop=4 set lbr " Smart line breaking set tw=500 set t_Co=256 set hidden set scrolloff=1000 set shortmess+=I syntax enable "Syntax highlighting colorscheme madtheme "Colorscheme " Backups in different folder set backup set writebackup set backupdir=~/.vim/backup// set directory=~/.vim/backup// set undofile set undodir=$HOME/.vim/undo set undolevels=1000 set undoreload=10000 " Split behaviour set splitright set splitbelow " we dont need to show the mode set noshowmode set listchars=eol:↲,tab:▶▹,nbsp:␣,extends:…,trail:• " }}} " --- Latex {{{ au BufRead,BufNewFile *.tex set ft=tex au FileType tex inoremap " " au FileType tex inoremap ä "a au FileType tex inoremap ö "o au FileType tex inoremap ü "u au FileType tex inoremap Ä "A au FileType tex inoremap Ö "O au FileType tex inoremap Ü "U au FileType tex inoremap ß "s au FileType tex inoremap "" \quot{}i " }}} " --- Abbreviations {{{ iab _date =strftime("%A, %d. %B %Y %H:%M") iab _zmail madmaurice@zom.bi iab _tumail valentin.gehrke@mailbox.tu-dresden.de " }}} " --- Autoload when saving vimrc {{{ au! BufWritePost .vimrc source ~/.vimrc " }}} " --- Vim file easyfolding {{{ augroup ft_vim au! au FileType vim setlocal foldmethod=marker augroup END " }}} " --- Own functions {{{ function! AddSemicolon() normal m'A; normal `' endfunction function! RunCmdVimux() let l:cmd = input("Run: ") if l:cmd !~ '\s\+' call VimuxRunCommand("clear && " . l:cmd) endif endfunction function! IsModified() if &modified return '* ' endif return '' endfunction function! s:tig_status() !~/.vim/findgitroot.sh "tig status" endfunction command! TigStatus call s:tig_status() " }}} " --- ModeColor {{{ function! ModeColor(mode) if a:mode == 'i' if &paste hi link ModeLine ModeLineInsertPaste else hi link ModeLine ModeLineInsert endif elseif a:mode == 'r' hi link ModeLine ModeLineReplace else hi link ModeLine ModeLineNormal endif endfunction au InsertEnter * call ModeColor(v:insertmode) au InsertChange * call ModeColor(v:insertmode) au InsertLeave * call ModeColor('n') call ModeColor('n') " }}} " --- Bindings {{{ let mapleader = "," " word movement with tab nnoremap W nnoremap B " Close and write buffers nnoremap q :b#bd# nnoremap w :w " Insert empty line before and after nnoremap okO " Fuzzy Finder nnoremap f :FufFile " nnoremap <> ?^$ " evil spaces nnoremap c m':%s/\s\+$//e`' " double empty lines nnoremap v m':%s/\n\{3,}/\r\r/e`' " Toggle paste nnoremap p :set invpaste paste? " Quick tabularize nnoremap a :Tabularize / vnoremap a :'<,'>Tabularize / " VimRC nnoremap oc :e ~/.vimrc nnoremap sc :so ~/.vimrc " Toggle invisble chars nnoremap i :set list! " Vimux nnoremap rr :call RunCmdVimux() nnoremap rq :call VimuxCloseRunner() nnoremap t :g/TODO/ nnoremap :TigStatus " 0 should find first non blank nmap 0 ^ " " Easy buffer switching " nnoremap M :bnext " nnoremap N :bprev " Moving through windows nnoremap l nnoremap h nnoremap j nnoremap k inoremap l inoremap h inoremap j inoremap k " Quick macroing nnoremap Q @@ " --- Don't need a help inoremap nnoremap vnoremap " -- Make Y behave correctly map Y y$ " -- Quick adding of spaces nnoremap il " Showing and hiding special characters nnoremap l :set nolist! " Equally resize windows nnoremap = :wincmd = " Automatic running autocmd filetype python nnoremap :w:!python % " Sudo to write cnoremap w!! w !sudo tee % >/dev/null " --- Just a nuisance map q: " --- No moving in insert mode allowed ino ino ino ino " --- Different use of undo nnoremap U " }}} " --- Useless whitespaces {{{ highlight WhitespaceEOL ctermbg=Red guibg=Red match WhitespaceEOL /\s\+$/ " }}} " --- Rice {{{ set statusline=\ %#Modified#%{IsModified()}%* set statusline+=%f set statusline+=\ %#ModeLine#%=%* set statusline+=\ L%l set statusline+=\ C%c hi Modified ctermfg=red hi StatusLine cterm=None ctermfg=green ctermbg=none hi Search cterm=NONE ctermfg=none ctermbg=none hi IncSearch cterm=underline ctermbg=none ctermfg=green " }}} " --- Supertab {{{ let g:SuperTabNoCompleteAfter = ['^',',','\s'] " }}} " --- NERDTree config {{{ nmap e :NERDTreeToggle " Open NERDTree when vim is started without files to open autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif " Auto refresh NERDTree when focus autocmd WinEnter * if exists('b:NERDTree') | execute 'normal R' | endif let NERDTreeWinSize = 30 let NERDChristmasTree = 0 let NERDTreeChDirMode = 2 let NERDTreeIgnore=['\~$','\.pyc$','\.swp$'] let NERDTreeWinPos="left" let NERDTreeMinimalUI = 1 let NERDTreeQuitOnOpen = 1 " }}} " --- EasyMotion config {{{ let g:EasyMotion_do_mapping = 0 " Disable default mappings map / (easymotion-sn) omap / (easymotion-tn) map ? (easymotion-bd-jk) map f (easymotion-fl) map F (easymotion-Fl) "map n (easymotion-next) "map N (easymotion-prev) " }}} " --- Auto pairs config {{{ let g:lexima_enable_basic_rules = 1 " }}} set ts=4 set noet