Mercurial > dotfiles.old
annotate vimrc @ 19:4ee5a11d8355
Improvements
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 16 Mar 2014 10:37:24 +0100 |
parents | fdff344860ef |
children | bf5c5093bad9 |
rev | line source |
---|---|
0 | 1 set nocompatible |
2 set laststatus=2 | |
3 set noshowmode | |
4 | |
5 execute pathogen#infect() | |
6 | |
7 set backspace=2 | |
8 set autowrite | |
9 | |
10 set vb | |
11 set guioptions-=r | |
12 set guioptions-=l | |
13 set guioptions-=R | |
14 set guioptions-=L | |
15 | |
16 syntax on | |
17 set expandtab | |
18 set number | |
19 set ruler | |
20 set nocursorline | |
21 set showmatch | |
22 set title | |
23 set wrap | |
24 set wrapmargin=2 | |
25 set linebreak | |
26 set lbr | |
27 set tabstop=2 shiftwidth=2 | |
28 color hybrid | |
29 set guifont=Inconsolata\ for\ Powerline:h12 | |
30 set autowrite | |
31 set hidden | |
32 set hlsearch | |
33 set incsearch | |
34 set ignorecase | |
35 set smartcase | |
36 set smartindent | |
37 set autoindent | |
38 set scrolloff=4 | |
39 set textwidth=80 | |
40 | |
41 set history=100 | |
42 set wildmenu | |
19 | 43 set wildmode=full |
0 | 44 |
45 set diffopt+=iwhite | |
46 | |
47 set formatoptions= | |
48 set formatoptions+=c " Format comments | |
49 set formatoptions+=r " Continue comments by default | |
50 set formatoptions+=o " Make comment when using o or O from comment line | |
51 set formatoptions+=q " Format comments with gq | |
52 set formatoptions+=n " Recognize numbered lists | |
53 set formatoptions+=2 " Use indent from 2nd line of a paragraph | |
54 set formatoptions+=l " Don't break lines that are already long | |
55 set formatoptions+=1 " Break before 1-letter words | |
56 | |
57 set splitright | |
58 set virtualedit=block | |
59 set conceallevel=0 | |
60 | |
61 set cryptmethod=blowfish | |
62 | |
63 filetype plugin indent on | |
64 autocmd FileType ruby set tabstop=2|set shiftwidth=2 | |
65 | |
66 set clipboard=unnamed | |
67 | |
16 | 68 set viminfo='10,\"100,:20,%,n~/.viminfo |
69 | |
70 " When editing a file, always jump to the last known cursor position. | |
71 " Don't do it for commit messages, when the position is invalid, or when | |
72 " inside an event handler (happens when dropping a file on gvim). | |
73 autocmd BufReadPost * | |
74 \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | | |
75 \ exe "normal g`\"" | | |
76 \ endif | |
0 | 77 |
78 map <Leader>d :bp<bar>sp<bar>bn<bar>bd<CR> | |
79 | |
80 " See long lines as line breaks | |
81 map j gj | |
82 map k gk | |
83 | |
84 " remap tag-search to better place | |
85 nmap <C-$> <C-]> | |
86 | |
87 " Jump to end of line in insert mode | |
88 inoremap <C-e> <C-o>A | |
89 | |
90 " Jump one character in insert mode | |
91 inoremap <C-f> <C-o>l | |
92 | |
4
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
93 " Switch between the last two files |
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
94 nnoremap <SPACE><SPACE> <C-^> |
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
95 |
0 | 96 " Very Magic search patterns |
97 nmap / /\v | |
98 cmap s/ s/\v | |
99 | |
100 | |
101 inoremap £ \ | |
102 | |
4
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
103 " nnoremap <SPACE> <C-e> |
0 | 104 |
105 " Close Quickfix window (,qq) | |
5 | 106 " map <leader>qq :cclose<CR> |
0 | 107 |
108 nnoremap <silent> n n:call HLNext(0.4)<cr> | |
109 nnoremap <silent> N N:call HLNext(0.4)<cr> | |
110 | |
111 function! HLNext (blinktime) | |
112 highlight WhiteOnRed ctermfg=white ctermbg=red guifg=white guibg=red | |
113 let [bufnum, lnum, col, off] = getpos('.') | |
114 let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/)) | |
115 let target_pat = '\c\%#'.@/ | |
116 let ring = matchadd('WhiteOnRed', target_pat, 101) | |
117 redraw | |
118 exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' | |
119 call matchdelete(ring) | |
120 redraw | |
121 endfunction | |
122 | |
123 " Swap v and CTRL-V | |
124 nnoremap v <C-V> | |
125 nnoremap <C-V> v | |
126 | |
127 vnoremap v <C-V> | |
128 vnoremap <C-V> v | |
129 | |
130 " Use backspace as delete in visual mode | |
131 vmap <BS> x | |
132 | |
133 " Keep selection when shifting | |
134 vmap <expr> > KeepVisualSelection(">") | |
135 vmap <expr> < KeepVisualSelection("<") | |
136 | |
137 function! KeepVisualSelection(cmd) | |
138 set nosmartindent | |
139 if mode() ==# "V" | |
140 return a:cmd . ":set smartindent\<CR>gv" | |
141 else | |
142 return a:cmd . ":set smartindent\<CR>" | |
143 endif | |
144 endfunction | |
145 | |
146 let g:indent_guides_auto_colors = 0 | |
147 let g:indent_guides_guide_size = 1 | |
148 highlight IndentGuidesEven guibg=background | |
149 highlight IndentGuidesOdd guibg='#282a2e' | |
150 | |
151 " Show trailing whitespaces | |
152 " exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~" | |
153 " set list | |
154 | |
155 " Vim Math plugin; make simple calculations | |
156 vmap <expr> ++ VMATH_YankAndAnalyse() | |
157 nmap ++ vip++ | |
158 | |
159 " Airline configuration | |
160 let g:airline_inactive_collapse=0 | |
161 let g:airline_powerline_fonts=1 | |
162 | |
163 let g:airline_left_sep = '' | |
164 let g:airline_right_sep = '' | |
165 | |
166 let g:airline_theme = 'tomorrow' | |
167 | |
168 let g:airline#extensions#syntastic#enabled = 0 | |
169 | |
170 nnoremap <F5> :buffers<CR>:buffer<Space> | |
171 noremap <C-TAB> <C-w><C-w> | |
172 | |
173 " Set leader to , | |
174 let mapleader = "," | |
175 | |
176 " Custom key mappings | |
177 | |
178 let g:yankring_replace_n_pkey = 'cp' | |
179 | |
180 " Nerdtree | |
181 map <F2> :NERDTreeToggle<CR> | |
182 map <Leader>e :NERDTreeToggle<CR> | |
183 let NERDTreeIgnore = ['\.aux$', '\.log$', '\.out$'] | |
184 | |
185 " Vim - Rspec | |
186 map <leader>t :call RunCurrentSpecFile()<CR> | |
187 map <leader>s :call RunNearestSpec()<CR> | |
188 map <leader>l :call RunLastSpec()<CR> | |
189 map <leader>r :call RunAllSpecs()<CR> | |
190 | |
191 " Cucumber | |
192 map <leader>f :call RunAllFeatures()<CR> | |
193 map <leader>k :call RunCurrentFeature()<CR> | |
194 | |
195 " Autocomplete | |
196 inoremap <C-Space> <C-N> | |
197 | |
198 " Single char insertion | |
199 " nmap <Space> i_<Esc>r | |
200 | |
201 " Clear highlight | |
202 nnoremap <silent> <leader>n :nohlsearch<CR> | |
203 | |
204 " ctrl p - Fuzzy file finder | |
205 noremap <C-p> :CtrlP<CR> | |
206 let g:ctrl_map = '<c-p>' | |
207 let g:ctrl_cmd = 'CtrlP' | |
208 | |
209 map <C-l> :CtrlPBuffer<CR> | |
210 map <C-m> :CtrlPTag<CR> | |
211 | |
5 | 212 if executable('ag') |
213 let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
214 let g:ctrlp_use_caching = 0 | |
215 endif | |
216 | |
0 | 217 " ctrl p - Commands |
218 map <leader>p :CtrlPCmdPalette<CR> | |
219 | |
220 " Markdown | |
221 let g:vim_markdown_folding_disabled=1 | |
222 | |
223 " tComment remap | |
224 nmap <leader>c <C-_><C-_> | |
225 | |
226 " Neo Complete | |
227 let g:acp_enableAtStartup=0 | |
228 let g:neocomplete#enable_at_startup=1 | |
229 let g:neocomplete#enable_smart_case=1 | |
230 let g:neocomplete#sources#syntax#min_keyword_length=3 | |
231 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' | |
232 | |
233 " Define dictionary. | |
234 let g:neocomplete#sources#dictionary#dictionaries = { | |
235 \ 'default' : '', | |
236 \ 'vimshell' : $HOME.'/.vimshell_hist', | |
237 \ 'scheme' : $HOME.'/.gosh_completions' | |
238 \ } | |
239 " Recommended key-mappings. | |
240 " <CR>: close popup and save indent. | |
241 inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> | |
242 function! s:my_cr_function() | |
243 return neocomplete#close_popup() . "\<CR>" | |
244 " For no inserting <CR> key. | |
245 "return pumvisible() ? neocomplete#close_popup() : "\<CR>" | |
246 endfunction | |
247 " <TAB>: completion. | |
248 inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
249 " <C-h>, <BS>: close popup and delete backword char. | |
250 inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>" | |
251 | |
252 autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
253 autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
254 autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS | |
255 autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
256 autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | |
257 autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete | |
258 if !exists('g:neocomplete#sources#omni#input_patterns') | |
259 let g:neocomplete#sources#omni#input_patterns = {} | |
260 endif | |
261 | |
262 " Neo Snippets | |
263 imap <C-k> <Plug>(neosnippet_expand_or_jump) | |
264 smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
265 xmap <C-k> <Plug>(neosnippet_expand_target) | |
266 | |
267 imap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
268 \ "\<Plug>(neosnippet_expand_or_jump)" | |
269 \: pumvisible() ? "\<C-n>" : "\<TAB>" | |
270 smap <expr><TAB> neosnippet#expandable_or_jumpable() ? | |
271 \ "\<Plug>(neosnippet_expand_or_jump)" | |
272 \: "\<TAB>" | |
273 let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' | |
274 | |
275 let g:neosnippet#snippets_directory='~/.vim/snippets' | |
276 | |
277 " Tabular | |
278 inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a | |
279 | |
280 function! s:align() | |
281 let p = '^\s*|\s.*\s|\s*$' | |
282 if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) | |
283 let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) | |
284 let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) | |
285 Tabularize/|/l1 | |
286 normal! 0 | |
287 call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) | |
288 endif | |
289 endfunction | |
290 | |
291 " Align Migration files | |
292 vmap <c-a> :Tabularize /:/l1l0l0<CR> | |
293 | |
294 nmap <Leader>a= :Tabularize /=<CR> | |
295 vmap <Leader>a= :Tabularize /=<CR> | |
296 nmap <Leader>a=> :Tabularize /=><CR> | |
297 vmap <Leader>a=> :Tabularize /=><CR> | |
298 nmap <Leader>a: :Tabularize /:\zs/l0l1<CR> | |
299 vmap <Leader>a: :Tabularize /:\zs/l0l1<CR> | |
300 nmap <Leader>a, :Tabularize /,\zs/l0l1<CR> | |
301 vmap <Leader>a, :Tabularize /,\zs/l0l1<CR> | |
302 vmap <Leader>a- :Tabularize /-<CR> | |
303 | |
304 | |
305 | |
306 augroup markdown | |
307 au! | |
308 au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown | |
309 augroup END | |
310 | |
311 | |
312 " Latex plugin | |
313 au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb | |
314 au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0 | |
315 au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb | |
316 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 | |
317 | |
318 let g:tex_conseal = "" | |
319 | |
320 let g:tex_comment_nospell=1 | |
321 let g:Tex_DefaultTargetFormat = 'pdf' | |
322 let g:tex_flavor = 'latex' | |
323 let g:Tex_TreatMacViewerAsUNIX = 1 | |
324 let g:Tex_ExecuterUNIXViewerInForeground = 1 | |
325 let g:Tex_ViewRule_pdf = 'open -a Preview' | |
326 let g:Tex_ViewRule_ps = 'open -a Preview' | |
327 | |
328 " Tagbar mapping | |
329 nmap <F8> :TagbarToggle<CR> | |
330 | |
331 " The silver searcher | |
332 " let g:ackprg = 'ag --nogroup --nocolor --column' | |
333 | |
334 " Multiple cursor insert | |
335 let g:multi_cursor_next_key='<C-n>' | |
336 let g:multi_cursor_prev_key='<C-m>' | |
337 let g:multi_cursor_skip_key='<C-x>' | |
338 let g:multi_cursor_quit_key='<Esc>' | |
339 | |
340 " Gundo tree | |
341 nnoremap <leader>u :GundoToggle<CR> | |
342 | |
343 " Yank ring | |
344 nnoremap <silent> <leader>y :YRShow<CR> | |
345 | |
13 | 346 " Open pdf in Preview |
0 | 347 let g:livepreview_previewer = 'open -a Preview' |
3
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
348 |
13 | 349 |
350 " Smalls | |
351 nmap s <Plug>(smalls) | |
352 omap s <Plug>(smalls) | |
353 xmap s <Plug>(smalls) | |
354 | |
14
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
355 " Textmanip |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
356 xmap <C-j> <Plug>(textmanip-move-down) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
357 xmap <C-k> <Plug>(textmanip-move-up) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
358 xmap <C-h> <Plug>(textmanip-move-left) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
359 xmap <C-l> <Plug>(textmanip-move-right) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
360 xmap <F10> <Plug>(textmanip-toggle-mode) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
361 |
13 | 362 " Load local vimrc |
3
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
363 if filereadable($HOME . "/.vimrc.local") |
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
364 source ~/.vimrc.local |
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
365 endif |