Files
dotfiles/vim/vimrc

393 lines
11 KiB
VimL
Raw Normal View History

2015-09-25 16:25:48 +02:00
" vim: set filetype=vim
2013-09-18 15:07:35 +02:00
" 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
2014-09-30 19:55:51 +02:00
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'gmarik/vundle'
2013-09-18 15:07:35 +02:00
2014-06-14 00:26:03 +02:00
" monokai color theme
2014-09-30 19:55:51 +02:00
Plugin 'sickill/vim-monokai'
2014-06-14 00:26:03 +02:00
2013-09-21 23:22:39 +02:00
" display the undo history in a graph
2014-09-30 19:55:51 +02:00
Plugin 'mbbill/undotree'
2013-09-21 23:22:39 +02:00
" tree explorer plugin
2014-09-30 19:55:51 +02:00
Plugin 'scrooloose/nerdtree'
2013-09-21 23:22:39 +02:00
" quoting/parenthesizing made simple
2014-09-30 19:55:51 +02:00
Plugin 'tpope/vim-surround'
2013-09-21 23:22:39 +02:00
" better commenting
2014-09-30 19:55:51 +02:00
Plugin 'tpope/vim-commentary'
2013-09-21 23:22:39 +02:00
" nice auto completion
2014-09-30 19:55:51 +02:00
Plugin 'Valloric/YouCompleteMe'
2013-09-21 23:22:39 +02:00
" nice text alignment
2014-09-30 19:55:51 +02:00
Plugin 'godlygeek/tabular'
2013-09-21 23:22:39 +02:00
" status line plugin
2014-09-30 19:55:51 +02:00
Plugin 'bling/vim-airline'
2013-09-21 23:22:39 +02:00
2013-09-27 05:49:23 +02:00
" date/time support for CTRL-x and CTRL-a
2014-09-30 19:55:51 +02:00
Plugin 'tpope/vim-speeddating'
2013-09-27 05:49:23 +02:00
2013-12-11 23:13:46 +01:00
" git integration
2014-09-30 19:55:51 +02:00
Plugin 'tpope/vim-fugitive'
2013-12-11 23:13:46 +01:00
2014-06-14 00:26:03 +02:00
" python specific stuff
2014-09-30 19:55:51 +02:00
Plugin 'klen/python-mode'
2014-06-14 00:26:03 +02:00
2015-09-25 16:25:48 +02:00
Plugin 'nblock/vim-dokuwiki'
Plugin 'saltstack/salt-vim'
Plugin 'lepture/vim-jinja'
2014-06-14 00:26:03 +02:00
" incremental visual mode
2014-11-07 17:37:04 +01:00
"Plugin 'terryma/vim-expand-region'
"
"Plugin 'wincent/Command-T'
"
"Plugin 'sjl/gundo.vim'
"
2014-09-30 19:55:51 +02:00
Plugin 'kien/ctrlp.vim'
2014-11-07 17:37:04 +01:00
"
"Plugin 'PeterRincker/vim-argumentative'
"
"Plugin 'wellle/targets.vim'
"
"Plugin 'Lokaltog/vim-easymotion'
"
"Plugin 'terryma/vim-multiple-cursors'
"
"Plugin 'flazz/vim-colorschemes'
2014-09-30 19:55:51 +02:00
2015-09-25 16:25:48 +02:00
Plugin 'reedes/vim-pencil'
2014-09-30 19:55:51 +02:00
call vundle#end()
filetype plugin indent on
2014-04-17 19:38:16 +02:00
set t_Co=256
2013-12-11 23:13:46 +01:00
2014-06-14 00:26:03 +02:00
" setup for pymode
let g:pymode_trim_whitespaces = 1
let g:pymode_lint_on_write = 0
let g:pymode_lint_unmodified = 0
let g:pymode_lint_on_fly = 0
2015-09-25 16:25:48 +02:00
let g:pymode_rope = 0
2014-06-14 00:26:03 +02:00
let g:pymode_rope_completion = 0
"let g:pymode_rope_completion_on_dot = 1
let g:pymode_rope_goto_definition_cmd = "new"
let g:pymode_syntax_all = 1
let g:pymode_options = 1
2013-09-18 15:07:35 +02:00
" setup for the solarized color theme
set background=dark
let g:solarized_termcolors=16
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
2013-09-18 15:07:35 +02:00
let g:solarized_visibility="normal"
syntax enable
2014-06-14 00:26:03 +02:00
colorscheme monokai
2013-09-18 15:07:35 +02:00
" setup for vim-airline
2014-06-14 00:26:03 +02:00
let g:airline_theme='powerlineish'
let g:airline_left_sep=''
let g:airline_right_sep=''
2015-09-25 16:25:48 +02:00
let g:airline_section_x = '%{PencilMode()}'
let g:pencil#mode_indicators = {'hard': 'H', 'auto': 'A', 'soft': 'S', 'off': '',}
2014-06-14 00:26:03 +02:00
"let g:airline_section_z=''
" enable tabline at the top showing all buffers
2014-06-14 00:26:03 +02:00
"let g:airline#extensions#tabline#enabled = 1
let g:ycm_complete_in_comments = 0
let g:ycm_complete_in_strings = 1
2015-09-25 16:25:48 +02:00
let g:ycm_collect_identifiers_from_comments_and_strings = 0
2014-06-14 00:26:03 +02:00
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_add_preview_to_completeopt = 1
2015-09-25 16:25:48 +02:00
let g:ycm_autoclose_preview_window_after_completion = 1
2014-06-14 00:26:03 +02:00
let g:ycm_autoclose_preview_window_after_insertion = 1
set colorcolumn=79
2014-07-29 02:11:38 +02:00
"set clipboard=unnamed " enable copying into the clipboard
2013-09-21 23:22:39 +02:00
set esckeys " enable cursor keys in insert mode
set ttimeoutlen=50
set modeline " respect modelines in files
2015-09-25 16:25:48 +02:00
set modelines=5
2013-09-21 23:22:39 +02:00
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
2013-09-18 15:07:35 +02:00
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
2014-09-30 19:55:51 +02:00
set backupcopy=no
2013-09-18 15:07:35 +02:00
2013-09-24 18:40:40 +02:00
set noshowmode " do not show the current mode, as this
" will be handled by vim-airline in the
" statusline
2013-09-18 15:07:35 +02:00
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
2013-09-24 18:40:40 +02:00
set wrapscan " wrap searches at the end of the file
2013-09-18 15:07:35 +02:00
set ignorecase " ignore case when only searching for
2014-11-07 17:37:04 +01:00
set smartcase " lowercase letters, case sensitive
" otherwise
2013-09-18 15:07:35 +02:00
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
2014-04-19 04:19:59 +02:00
set directory=/var/tmp,/tmp
2013-09-18 15:07:35 +02:00
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 smarttab " use shiftwidth when tabbing in front of
" a line instead of tabsstop/softtabstop
2013-09-24 18:40:40 +02:00
set shiftround " round indent to multiples of shiftwidth
2013-09-18 15:07:35 +02:00
set undofile " use an undo file
2013-09-21 23:22:39 +02:00
set undodir=~/.vim/undo " store undo files in a fixed directory
2013-09-18 15:07:35 +02:00
" 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
2013-10-02 18:10:44 +02:00
set scrolloff=5 " show context at the screen edges
2013-09-18 15:07:35 +02:00
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
2013-09-24 18:40:40 +02:00
set matchpairs="(:),{:},[:]" " matching pairs for the '%'-command
set notildeop " do not make '~' behave like an operator
2013-09-27 05:49:23 +02:00
set virtualedit+="block" " allow moving the cursor where there is no
2013-09-24 18:40:40 +02:00
" actual character in virtual block mode
set wildignore=*.swp,*.bak,*.pyc " files to ignore when expanding wildcards
set noerrorbells " do not beep on errors
2013-12-11 23:13:46 +01:00
set colorcolumn=80 " highlight the 80st column
"set list " show specific spectial characters
"set listchars= " no trailing whitespace as '~'
2013-09-24 18:40:40 +02:00
2014-06-14 00:26:03 +02:00
let mapleader = "\<Space>"
nnoremap <Leader>w :w<CR>
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
nmap <Leader><Leader> za
map , :
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
2013-09-18 15:07:35 +02:00
2013-09-24 18:40:40 +02:00
" enable 'very-magic' in regex
2014-06-14 00:26:03 +02:00
"nnoremap / /\v
"vnoremap / /\v
nnoremap <leader>, :nohlsearch<CR>
2013-09-24 18:40:40 +02:00
2014-06-14 00:26:03 +02:00
noremap gV `[v`]
2013-09-18 15:07:35 +02:00
2013-09-24 18:40:40 +02:00
" make Y behave like other capitals, otherwise Y would work like yy
nnoremap Y y$
2013-09-18 15:07:35 +02:00
nnoremap j gj
nnoremap k gk
2014-06-14 00:26:03 +02:00
"function! TrimWhiteSpace()
" %s/\s\+$//e
"endfunction
2013-09-24 18:40:40 +02:00
" automatically reload .vimrc when it's saved
autocmd BufWritePost .vimrc source ~/.vimrc
2014-06-14 00:26:03 +02:00
"autocmd FileWritePre * :call TrimWhiteSpace()
"autocmd FileAppendPre * :call TrimWhiteSpace()
"autocmd FilterWritePre * :call TrimWhiteSpace()
"autocmd BufWritePre * :call TrimWhiteSpace()
" Start NERDTree when starting vim
"autocmd vimenter * NERDTree
2013-12-11 23:13:46 +01:00
"autocmd VimEnter * wincmd p
2014-06-14 00:26:03 +02:00
let NERDTreeQuitOnOpen = 1
" close NERDTree when it's the only window left
2014-06-14 00:26:03 +02:00
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
2013-12-11 23:13:46 +01:00
2014-06-14 00:26:03 +02:00
"call togglebg#map("<F5>")
2013-12-11 23:13:46 +01:00
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <F3> :NERDTreeToggle<CR>
2014-06-14 00:26:03 +02:00
nnoremap <F4> :TagbarToggle<CR>
2013-12-11 23:13:46 +01:00
" Autosave views when closing and restoring when opening again.
2014-09-30 19:55:51 +02:00
set viewdir=~/.vim/view
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
2014-06-14 00:26:03 +02:00
":inoremap <expr> <CR> pumvisible() ? '<C-e><CR>' : '<CR>'
":au WinEnter * :setlocal number relativenumber
":au WinLeave * :setlocal nonumber norelativenumber
2014-11-07 17:37:04 +01:00
""nnoremap <up> <nop>
""nnoremap <down> <nop>
""nnoremap <left> <nop>
""nnoremap <right> <nop>
""inoremap <up> <nop>
""inoremap <down> <nop>
""inoremap <left> <nop>
""inoremap <right> <nop>
nmap <C-n> :bnext<CR>
nmap <C-p> :bprev<CR>
" default emacs movements for command line
cnoremap <C-a> <Home>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-d> <Delete>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
cnoremap <M-d> <S-right><Delete>
cnoremap <Esc>b <S-Left>
cnoremap <Esc>f <S-Right>
cnoremap <Esc>d <S-right><Delete>
cnoremap <C-g> <C-c>
2014-06-14 00:26:03 +02:00
inoremap jj <ESC>
nnoremap <leader>v <C-w>v<C-w>l
2014-11-07 17:37:04 +01:00
nmap ; :CtrlPBuffer<CR>
2014-06-14 00:26:03 +02:00
" no more ex mode
nnoremap Q <nop>
nnoremap <leader>r :%s///<Left><Left>
set virtualedit="onemore,all"
2014-07-21 02:29:37 +02:00
autocmd BufWritePre *.rst silent :%s/\s\+$//e