" {{{ General settings set nocompatible " Forget about (N)VI set noerrorbells " No annoying bells set vb t_vb= set hidden " allow buffer switching without saving " Highlight search results set hlsearch " Type-ahead find set incsearch " Use to clear the highlighting of :set hlsearch. " Taken from https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim if maparg('', 'n') ==# '' nnoremap :nohlsearch=has('diff')?'diffupdate':'' endif " Indent of 8, but no spaces set shiftwidth=8 set tabstop=8 " Allow backspacing over indentation, end-of-line and start-of-line set backspace=2 " smart autoindenting set smartindent " Paste toggle (a.k.a set paste/set nopaste) set pastetoggle= " Enable folding by fold markers set foldmethod=marker " Don't wrap line longer than the display set nowrap " Textwidth of 100 set textwidth=100 " Number of undo operations to store set undolevels=50 set laststatus=2 " Always show the statusline set ruler " Display ruler with cursor positions set cursorline " Highlight the cursor line and column " Buffer, filename, line, total lines, column, ASCII value "set statusline=[%n]\ %f\ %m\ %l/%L,%c\ ASCII:\ %3b "set statusline+=[%{strlen(&fenc)?&fenc:'none'}, " file encoding "set statusline+=%{&ff}] " file format " Always show at least one line above/below the cursor. " See https://github.com/tpope/vim-sensible if !&scrolloff set scrolloff=1 endif if !&sidescrolloff set sidescrolloff=5 endif set display+=lastline " maximum number of tabs to open set tabpagemax=20 set showmode set modeline set backupcopy=auto,breakhardlink filetype on " Enable filetype detection filetype indent on " Enable filetype specific indenting filetype plugin on " Enable filetype specific plugins let g:git_diff_spawn_mode=2 " }}} " {{{ Colors and fonts set background=dark let g:solarized_termtrans=1 colorscheme solarized " Syntax highlighting if &t_Co > 2 || has("gui_running") syntax on endif " Highlight trailing whitespaces let c_space_errors=1 highlight WhitespaceEOL ctermbg=red guibg=red match WhitespaceEOL /\s\+$/ " }}} " {{{ Completion autocmd FileType c set omnifunc=ccomplete#Complete autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType php set omnifunc=phpcomplete#CompletePHP " }}} " {{{ Mappings let mapleader="," " Line numbering toggle nmap n :set invnumber "highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE map s ^iSigned-off-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL>^ map! s Signed-off-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL> map a ^iAcked-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL>^ map! a Acked-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL> map r ^iReviewed-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL>^ map! r Reviewed-by: =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL> map y ^iCopyright (C) =strftime("%Y") =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL>^ map! y Copyright (C) =strftime("%Y") =$GIT_AUTHOR_NAME <=$GIT_AUTHOR_EMAIL> map c i=strftime("%F %R") Tobias Klauser * map! c =strftime("%F %R") Tobias Klauser * map f ^iFrom: Tobias Klauser ^ map! f From: Tobias Klauser map :let &background = ( &background == "dark" ? "light" : "dark" ) map :! make map!   map :Files map :NERDTreeFind map tl :TlistToggle " Remove all trailing whitespaces in file map w :%s/\s\+$//^ map! w :%s/\s\+$// " Remove Mac/DOS line-breaks map lb :%s/ //^ map! lb :%s/ // " Navigate non-breaking lines more easily " from http://zinformatik.de/tipps-tricks/vim-tipps/einige-tipps-und-tricks-fur-vim/ noremap gj noremap gk " Thanks mikap! http://michael-prokop.at/computer/config/.vimrc map !f !perl -MText::Autoformat -e'autoformat' map ;0 :'<,'>!boxes map ;1 :'<,'>!boxes -d boxquote map ;2 :'<,'>!boxes -d peek -a c -s 40x5 map ;3 :'<,'>!boxes -d c-cmt map ;4 :'<,'>!boxes -d dog -a c map ;5 :'<,'>!boxes -d simple -a jr map ;6 :'<,'>!boxes -d headline map hon :%!xxd map hof :%!xxd -r " delete the text until start of the mail signature with ,k map k d/^-- $ " line numbering map ln :%s/^/\=line('.')/ " add a comment map mkc i/* */ " greet to the person you write a mail map a G/^\* /e+1ye1G}oHallo ", " }}} " {{{ VIM LaTeX let g:Imap_UsePlaceHolders = 0 " }}} " {{{ Always use tabs in Makefiles autocmd BufEnter ?akefile* set noet ts=8 sw=8 nocindent " }}} " {{{ NERDTree autocmd vimenter * if !argc() | NERDTree | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif let NERDTreeShowHidden=1 let NERDTreeIgnore=['\.o$', '\~$', '\.swp'] map nt :NERDTreeToggle " }}} " {{{ airline let g:airline_theme='solarized' let g:airline_solarized_bg='dark' " }}} " {{{ vim-plug (https://github.com/junegunn/vim-plug) call plug#begin('~/.vim/plugged') Plug 'vim-airline/vim-airline' " status line Plug 'vim-airline/vim-airline-themes' Plug 'scrooloose/nerdtree' " NERDTree file browser Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " Go support Plug 'rust-lang/rust.vim' " Rust support Plug 'airblade/vim-gitgutter' " git status gutter Plug 'tpope/vim-fugitive' " git commands Plug 'tpope/vim-rhubarb' " GitHub integration Plug 'tpope/vim-commentary' " comment out stuff Plug 'joestringer/cscope_maps' " cscope maps Plug 'google/vim-searchindex' " show how many times a search pattern occurs " fzf (https://github.com/junegunn/fzf.vim) Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' call plug#end() " }}} " {{{ commands :command -nargs=+ Ggr execute 'silent Ggrep!' | cw | redraw!" " }}}