3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
6 filetype plugin indent on
8 " pathogen.vim runtime path manipulation
9 silent! call pathogen#infect()
11 " moving around, searching and patterns {{{1
12 set incsearch " show match for partly typed search command
13 set ignorecase " ignore case when using a search pattern
14 set smartcase " override 'ignorecase' when pattern has upper case characters
15 set hlsearch " highlight all matches for the last used search pattern
17 " use leader-n to unhighlight search
18 nmap <silent> <Leader>n :silent nohl<CR>
19 " use leader-# to display the number of matches for the last search
20 nmap <Leader># :%s:<C-R>/::gn<CR>
21 " center cursor after search
24 set nostartofline " don't move the cursor to the first non-blank char of a line
25 set path=.,** " current + subdirectory search for :find, :grep:, ...
27 " displaying text {{{1
28 set scrolloff=5 " number of screen lines to show around the cursor
29 set wrap " long lines wrap
30 set linebreak " wrap long lines at a character in 'breakat'
31 set showbreak=▒▒ " show these chars for wrapped lines
33 set lazyredraw " don't redraw while executing macros
35 set list " show chars defined in 'listchars'
36 set listchars=tab:»·,trail:· " list of strings used for list mode
38 set number " show the line number for each line
39 set relativenumber " show the relative line number for each line
40 " toggle relativenumber
41 nnoremap <silent> <Leader>u :exe "set relativenumber!"<CR>
44 " When editing a file, always jump to the last known cursor position.
45 " Don't do it when the position is invalid or when inside an event handler
46 " (happens when dropping a file on gvim).
47 " Also don't do it when the mark is in the first line, that is the default
48 " position when opening a file.
49 " blacklist certain filetype, you can get a file type with :echo &ft
50 let blacklist = ['gitcommit']
52 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
53 \ exe "normal! g`\"" |
58 " syntax, highlighting and spelling {{{1
59 set background=dark " Dark background, d'uh!
62 set spelllang=en,de,fr " list of accepted languages
63 set dictionary=spell " list of dictionary files for keyword completion
64 " toggle spell-checking
65 map <silent><F10> :set nospell!<CR>:set nospell?<CR>
69 \ if &omnifunc == "" | setl omnifunc=syntaxcomplete#Complete | endif
72 " multiple windows {{{1
73 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
75 set previewheight=20 " default height for the preview window
77 set splitright " a new window is put right of the current one
84 map <F1> :ls<CR>:b<space>
86 " using the mouse {{{1
87 set mouse=rnv " list of flags for using the mouse
88 set ttymouse=xterm " type of mouse
90 "xterm mouse with middleclick paste
91 nnoremap <MiddleMouse> i<MiddleMouse>
92 vnoremap <MiddleMouse> s<MiddleMouse>
94 " messages and info {{{1
95 set showcmd " Show (partial) command in status line.
96 set ruler " show the cursor position all the time
97 set confirm " Ask what to do when closing unsaved documents
100 set backspace=indent,eol,start " allow backspacing over everything in insert mode
102 set showmatch " Show matching brackets.
104 set nojoinspaces " don't use two spaces after '.' when joining a line
105 set formatoptions+=j " remove comment leader when joining lines
107 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
109 " whether to use a popup menu for Insert mode completion
110 set completeopt=longest,menuone,preview
112 " Indent if we're at the beginning of a line. Else, do completion.
113 function! InsertTabWrapper()
114 let col = col('.') - 1
115 if !col || getline('.')[col - 1] !~ '\k'
121 inoremap <Tab> <C-R>=InsertTabWrapper()<CR>
122 inoremap <S-Tab> <C-P>
124 " fix legacy vi inconsistency
127 " allow repeat operator on visual
128 vnoremap . :normal .<CR>
130 " add line without changing position or leaving mode
131 map <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
132 map <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
134 " Don't use Ex mode, use Q for formatting
137 " allow undoing in insert-mode
138 inoremap <C-U> <C-G>u<C-U>
139 inoremap <C-W> <C-G>u<C-W>
141 " tabs and indent {{{1
142 set shiftwidth=4 " number of spaces used for each step of (auto)indent
143 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
144 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
145 set shiftround " round to 'shiftwidth' for "<<" and ">>"
146 set expandtab " expand <Tab> to spaces in Insert mode
148 set cindent " use smart C indenting (see :h C-indenting)
149 set cinoptions=l1,c4,(0,U1,w1,m1,j1,J1
151 set pastetoggle=<F11> " key sequence to toggle paste mode
153 nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
154 nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
155 nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
156 nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
159 set foldmethod=marker " folding type
160 set foldlevelstart=99 " value for 'foldlevel' when starting to edit a file
162 " space will toggle current fold in normal mode
163 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
164 " create folds around visual selection
167 " save and restore folds
168 autocmd BufWinLeave *.* mkview
169 autocmd BufWinEnter *.* silent loadview
171 " reading and writing files {{{1
172 set writebackup " write a backup file before overwriting a file
173 set backup " keep a backup after owerwriting a file
174 set backupdir=$HOME/.vim/backupdir
176 set undofile " persistent undo history
177 set undodir=$HOME/.vim/backupdir
179 set autowrite " automatically write a file when leaving a modified buffer
181 " command line editing {{{1
182 set history=500 " how many command lines are remembered
183 set wildmode=longest:full " specifies how command line completion works
184 set wildmenu " command-line completion shows a list of matches
187 set virtualedit=block " let cursor move past last char in <C-V> mode
188 set viminfo='100,<50,s10,h,n~/.vim/viminfo " viminfo defaults but save file in .vim
192 let g:airline_detect_whitespace=2
193 let g:airline_whitespace_symbol = 'Ξ'
194 let g:airline_linecolumn_prefix = '␊ '
195 let g:airline_left_sep = '▶'
196 let g:airline_right_sep = '◀'
197 let g:airline#extensions#tabline#enabled = 1
200 nnoremap <F7> :GundoToggle<CR>
202 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
205 " open/close NERDTree with \e
206 nmap <Leader>e :NERDTreeToggle<CR>
207 nmap <F6> :NERDTreeToggle<CR>
208 " <space> to open files/dirs
209 let NERDTreeMapActivateNode='<space>'
210 " open NERDTree if no files were selected
211 autocmd vimenter * if !argc() | NERDTree | endif
212 " close vim if only NERDTree is open
213 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
216 let g:syntastic_enable_highlighting = 0
217 let g:syntastic_error_symbol='E'
218 let g:syntastic_style_error_symbol='S'
219 let g:syntastic_warning_symbol='W'
220 let g:syntastic_style_warning_symbol='S'
221 let g:syntastic_always_populate_loc_list=1
222 nmap <silent> <leader>y :SyntasticCheck<cr>
225 let g:syntastic_check_on_open=1
229 map <F5> :TagbarToggle<cr>
230 let g:tagbar_sort = 0
231 let g:tagbar_compact = 1
232 let g:tagbar_autoshowtag = 1
233 let g:tagbar_width = 25
234 let g:tagbar_iconchars = ['+', '-']
237 " Convenient command to see the difference between the current buffer and the
238 " file it was loaded from, thus the changes you made.
239 " Only define it when not defined already.
240 if !exists(":DiffOrig")
241 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
242 \ | wincmd p | diffthis