Files
dotfiles/vim/vimrc

235 lines
8.0 KiB
VimL

" 01 important
" 02 moving around, searching and patterns
" 03 tags
" 04 displaying text
" 05 syntax, highlighting and spelling
" 06 multiple windows
" 07 multiple tab pages
" 08 terminal
" 09 using the mouse
" 10 printing
" 11 messages and info
" 12 selecting text
" 13 editing text
" 14 tabs and indenting
" 15 folding
" 16 diff mode
" 17 mapping
" 18 reading and writing files
" 19 the swap file
" 20 command line editing
" 21 executing external commands
" 22 running make and jumping to errors
" 23 language specific
" 24 multi-byte characters
" 25 various
set nocompatible
" setup of vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" solarized color theme
Bundle 'altercation/vim-colors-solarized'
" display the undo history in a graph
Bundle 'mbbill/undotree'
" tree explorer plugin
Bundle 'scrooloose/nerdtree'
" quoting/parenthesizing made simple
Bundle 'tpope/vim-surround'
" better commenting
Bundle 'scrooloose/nerdcommenter'
" nice auto completion
Bundle 'Shougo/neocomplcache.vim'
" nice text alignment
Bundle 'godlygeek/tabular'
" status line plugin
Bundle 'bling/vim-airline'
" date/time support for CTRL-x and CTRL-a
Bundle 'tpope/vim-speeddating'
filetype plugin indent on
" setup for the solarized color theme
set background=dark
let g:solarized_termcolors=16
let g:solarized_termtrans=1
let g:solarized_contrase="normal"
let g:solarized_visibility="normal"
syntax enable
colorscheme solarized
set clipboard=unnamed " enable copying into the clipboard
set esckeys " enable cursor keys in insert mode
set ttimeoutlen=50
set modeline " respect modelines in files
set modelines=4
set laststatus=2 " always show a status line
"set nostartofline " do not reset the cursor into the first
" " column when moving
set shortmess=rti " shorten some messages
set mouse=a " enable mouse support
set mousehide " hide the mouse when typing
set history=1000 " history length for commands, defaults to
" 20
set nobackup " do not create a backup
set nowritebackup
set noshowmode " do not show the current mode, as this
" will be handled by vim-airline in the
" statusline
set cursorline " highlight the current line
set number " enable linenumbers
set numberwidth=2 " only use as many columns for the line
" numbers as necessary
set relativenumber " show file numbers relative to the current
" line instead of absolute ones, but still
" the absolute linenumber on the current
" line due to 'number' being set
set showmatch " show matching brackets/parentheses
set incsearch " show matches while typing in a search
set hlsearch " highlight matches in a search
set wrapscan " wrap searches at the end of the file
set ignorecase " ignore case when only searching for
" lowercase
set smartcase " letters, case sensitive otherwis
set foldenable " auto-fold code
set wrap " wrap text
set linebreak
set backspace=indent,eol,start " allowing backspacing over autoindent,
" line breaks and start of insert
set encoding=utf-8 " set the encoding
set showmode " show current mode in the status line
set swapfile " use a swapfile
set updatecount=200 " default, number of characters that have
" to be typed before the swapfile is
" written to disk
set updatetime=10000 " time in milliseconds after the swapfile
" is written to disk
set title " let vim set the title of the window
set titlestring="" " use default titlestring
set autoread " automatically reload a file when it was
" changed outside of vim
set gdefault " apply replace patterns to the whole line
" by default
set tabstop=4 " one tab equals 4 spaces
set softtabstop=4 " makes the spaces feel like real tabs
set shiftwidth=4 " one indent level equals 4 spaces
set expandtab " expand tabs to spaces
set autoindent " copy indent from current line when
" starting a new one
set smartindent " smart indenting for C-like languages
set smarttab " use shiftwidth when tabbing in front of
" a line instead of tabsstop/softtabstop
set shiftround " round indent to multiples of shiftwidth
set undofile " use an undo file
set undodir=~/.vim/undo " store undo files in a fixed directory
" instead of the current directory
set undolevels=1000 " undo a maximum of 1000 changes
set undoreload=10000 " save the whole buffer for undo when
" reloading it
set foldmethod=indent " fold according to indet
set foldnestmax=2 " fold a maximum of 2 levels
set nofoldenable " unfold everything by default
set scrolloff=5 " show context at the screen edges
set showcmd " show (partial) command in the command line
set hidden " buffers can exist without a window
set ttyfast " enhance smoothness
set ruler " show position in status line
set wildmenu " show a menu when autocompleting
set wildmode=list:longest " automatically complete up to the level
" of ambiguity
set autochdir " automatically change to the directory that
" contains the file that is edited
set matchpairs="(:),{:},[:]" " matching pairs for the '%'-command
set notildeop " do not make '~' behave like an operator
set virtualedit+="block" " allow moving the cursor where there is no
" actual character in virtual block mode
set wildignore=*.swp,*.bak,*.pyc " files to ignore when expanding wildcards
set noerrorbells " do not beep on errors
"set list " show specific spectial characters
"set listchars= " no trailing whitespace as '~'
let mapleader = ","
" enable 'very-magic' in regex
nnoremap / /\v
vnoremap / /\v
nnoremap <leader><space> :nohlsearch<CR>
nnoremap <tab> %
vnoremap <tab> %
" make Y behave like other capitals, otherwise Y would work like yy
nnoremap Y y$
nnoremap j gj
nnoremap k gk
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
" automatically reload .vimrc when it's saved
autocmd BufWritePost .vimrc source ~/.vimrc
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
" Start NERDTree when starting vim
"autocmd vimenter * NERDTree
" close NERDTree when it's the only window left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif