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
27 inoremap <Right> <NOP>
33 set nostartofline " don't move the cursor to the first non-blank char of a line
34 set path=.,** " current + subdirectory search for :find, :grep:, ...
36 " displaying text {{{1
37 set scrolloff=5 " number of screen lines to show around the cursor
38 set wrap " long lines wrap
39 set linebreak " wrap long lines at a character in 'breakat'
40 set showbreak=▒▒ " show these chars for wrapped lines
42 set lazyredraw " don't redraw while executing macros
44 set list " show chars defined in 'listchars'
45 set listchars=tab:»·,trail:· " list of strings used for list mode
47 set number " show the line number for each line
48 set relativenumber " show the relative line number for each line
49 " toggle relativenumber
50 nnoremap <silent> <Leader>u :exe "set relativenumber!"<CR>
53 " When editing a file, always jump to the last known cursor position.
54 " Don't do it when the position is invalid or when inside an event handler
55 " (happens when dropping a file on gvim).
56 " Also don't do it when the mark is in the first line, that is the default
57 " position when opening a file.
58 " blacklist certain filetype, you can get a file type with :echo &ft
59 let blacklist = ['gitcommit']
61 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
62 \ exe "normal! g`\"" |
67 " syntax, highlighting and spelling {{{1
68 set background=dark " Dark background, d'uh!
71 set spelllang=en,de,fr " list of accepted languages
72 set dictionary=spell " list of dictionary files for keyword completion
73 " toggle spell-checking
74 map <silent><F10> :set nospell!<CR>:set nospell?<CR>
78 \ if &omnifunc == "" | setl omnifunc=syntaxcomplete#Complete | endif
81 " multiple windows {{{1
82 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
84 set previewheight=20 " default height for the preview window
86 set splitright " a new window is put right of the current one
93 map <F1> :ls<CR>:b<space>
95 " using the mouse {{{1
96 set mouse=rnv " list of flags for using the mouse
97 set ttymouse=xterm " type of mouse
99 "xterm mouse with middleclick paste
100 nnoremap <MiddleMouse> i<MiddleMouse>
101 vnoremap <MiddleMouse> s<MiddleMouse>
103 " messages and info {{{1
104 set showcmd " Show (partial) command in status line.
105 set ruler " show the cursor position all the time
106 set confirm " Ask what to do when closing unsaved documents
109 set backspace=indent,eol,start " allow backspacing over everything in insert mode
111 set showmatch " Show matching brackets.
113 set nojoinspaces " don't use two spaces after '.' when joining a line
114 set formatoptions+=j " remove comment leader when joining lines
116 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
118 " whether to use a popup menu for Insert mode completion
119 set completeopt=longest,menuone,preview
121 " Indent if we're at the beginning of a line. Else, do completion.
122 function! InsertTabWrapper()
123 let col = col('.') - 1
124 if !col || getline('.')[col - 1] !~ '\k'
130 inoremap <Tab> <C-R>=InsertTabWrapper()<CR>
131 inoremap <S-Tab> <C-P>
133 " fix legacy vi inconsistency
136 " allow repeat operator on visual
137 vnoremap . :normal .<CR>
139 " add line without changing position or leaving mode
140 map <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
141 map <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
143 " Don't use Ex mode, use Q for formatting
146 " allow undoing in insert-mode
147 inoremap <C-U> <C-G>u<C-U>
148 inoremap <C-W> <C-G>u<C-W>
150 " tabs and indent {{{1
151 set shiftwidth=4 " number of spaces used for each step of (auto)indent
152 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
153 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
154 set shiftround " round to 'shiftwidth' for "<<" and ">>"
155 set expandtab " expand <Tab> to spaces in Insert mode
157 set cindent " use smart C indenting (see :h C-indenting)
158 set cinoptions=l1,c4,(0,U1,w1,m1,j1,J1
160 set pastetoggle=<F11> " key sequence to toggle paste mode
162 nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
163 nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
164 nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
165 nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
168 set foldmethod=marker " folding type
169 set foldlevelstart=99 " value for 'foldlevel' when starting to edit a file
171 " space will toggle current fold in normal mode
172 nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
173 " create folds around visual selection
176 " save and restore folds
177 autocmd BufWinLeave *.* mkview
178 autocmd BufWinEnter *.* silent loadview
180 " reading and writing files {{{1
181 set writebackup " write a backup file before overwriting a file
182 set backup " keep a backup after owerwriting a file
183 set backupdir=$HOME/.vim/backupdir
185 set undofile " persistent undo history
186 set undodir=$HOME/.vim/backupdir
188 set autowrite " automatically write a file when leaving a modified buffer
190 " command line editing {{{1
191 set history=500 " how many command lines are remembered
192 set wildmode=longest:full " specifies how command line completion works
193 set wildmenu " command-line completion shows a list of matches
196 set virtualedit=block " let cursor move past last char in <C-V> mode
197 set viminfo='100,<50,s10,h,n~/.vim/viminfo " viminfo defaults but save file in .vim
201 let g:airline_detect_whitespace=2
202 let g:airline_whitespace_symbol = 'Ξ'
203 let g:airline_linecolumn_prefix = '␊ '
204 let g:airline_left_sep = '▶'
205 let g:airline_right_sep = '◀'
206 let g:airline#extensions#tabline#enabled = 1
209 nnoremap <F7> :GundoToggle<CR>
211 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
214 " open/close NERDTree with \e
215 nmap <Leader>e :NERDTreeToggle<CR>
216 nmap <F6> :NERDTreeToggle<CR>
217 " <space> to open files/dirs
218 let NERDTreeMapActivateNode='<space>'
219 " open NERDTree if no files were selected
220 autocmd vimenter * if !argc() | NERDTree | endif
221 " close vim if only NERDTree is open
222 autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
225 let g:syntastic_enable_highlighting = 0
226 let g:syntastic_error_symbol='E'
227 let g:syntastic_style_error_symbol='S'
228 let g:syntastic_warning_symbol='W'
229 let g:syntastic_style_warning_symbol='S'
230 let g:syntastic_always_populate_loc_list=1
231 nmap <silent> <leader>y :SyntasticCheck<cr>
234 let g:syntastic_check_on_open=1
238 map <F5> :TagbarToggle<cr>
239 let g:tagbar_sort = 0
240 let g:tagbar_compact = 1
241 let g:tagbar_autoshowtag = 1
242 let g:tagbar_width = 25
243 let g:tagbar_iconchars = ['+', '-']
246 let g:ycm_extra_conf_globlist = ['/mnt/data/src/*']
249 " Convenient command to see the difference between the current buffer and the
250 " file it was loaded from, thus the changes you made.
251 " Only define it when not defined already.
252 if !exists(":DiffOrig")
253 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
254 \ | wincmd p | diffthis