comparison vimrc @ 0:36a9b3a28861

Add all dotfiles
author zegervdv <zegervdv@me.com>
date Sun, 23 Feb 2014 17:20:32 +0100
parents
children 44d3af8838f8
comparison
equal deleted inserted replaced
-1:000000000000 0:36a9b3a28861
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
43
44 set diffopt+=iwhite
45
46 set formatoptions=
47 set formatoptions+=c " Format comments
48 set formatoptions+=r " Continue comments by default
49 set formatoptions+=o " Make comment when using o or O from comment line
50 set formatoptions+=q " Format comments with gq
51 set formatoptions+=n " Recognize numbered lists
52 set formatoptions+=2 " Use indent from 2nd line of a paragraph
53 set formatoptions+=l " Don't break lines that are already long
54 set formatoptions+=1 " Break before 1-letter words
55
56 set splitright
57 set virtualedit=block
58 set conceallevel=0
59
60 set cryptmethod=blowfish
61
62 filetype plugin indent on
63 autocmd FileType ruby set tabstop=2|set shiftwidth=2
64
65 set clipboard=unnamed
66
67
68 map <Leader>d :bp<bar>sp<bar>bn<bar>bd<CR>
69
70 " See long lines as line breaks
71 map j gj
72 map k gk
73
74 " remap tag-search to better place
75 nmap <C-$> <C-]>
76
77 " Jump to end of line in insert mode
78 inoremap <C-e> <C-o>A
79
80 " Jump one character in insert mode
81 inoremap <C-f> <C-o>l
82
83 " Very Magic search patterns
84 nmap / /\v
85 cmap s/ s/\v
86
87
88 inoremap £ \
89
90 nnoremap <SPACE> <C-e>
91
92 " Close Quickfix window (,qq)
93 map <leader>qq :cclose<CR>
94
95 nnoremap <silent> n n:call HLNext(0.4)<cr>
96 nnoremap <silent> N N:call HLNext(0.4)<cr>
97
98 function! HLNext (blinktime)
99 highlight WhiteOnRed ctermfg=white ctermbg=red guifg=white guibg=red
100 let [bufnum, lnum, col, off] = getpos('.')
101 let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
102 let target_pat = '\c\%#'.@/
103 let ring = matchadd('WhiteOnRed', target_pat, 101)
104 redraw
105 exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
106 call matchdelete(ring)
107 redraw
108 endfunction
109
110 " Swap v and CTRL-V
111 nnoremap v <C-V>
112 nnoremap <C-V> v
113
114 vnoremap v <C-V>
115 vnoremap <C-V> v
116
117 " Use backspace as delete in visual mode
118 vmap <BS> x
119
120 " Keep selection when shifting
121 vmap <expr> > KeepVisualSelection(">")
122 vmap <expr> < KeepVisualSelection("<")
123
124 function! KeepVisualSelection(cmd)
125 set nosmartindent
126 if mode() ==# "V"
127 return a:cmd . ":set smartindent\<CR>gv"
128 else
129 return a:cmd . ":set smartindent\<CR>"
130 endif
131 endfunction
132
133 let g:indent_guides_auto_colors = 0
134 let g:indent_guides_guide_size = 1
135 highlight IndentGuidesEven guibg=background
136 highlight IndentGuidesOdd guibg='#282a2e'
137
138 " Visual Block Dragging
139 vmap <expr> H DVB_Drag('left')
140 vmap <expr> L DVB_Drag('right')
141 vmap <expr> J DVB_Drag('down')
142 vmap <expr> K DVB_Drag('up')
143 vmap <expr> D DVB_Duplicate()
144 let g:DVB_TrimWS = 1
145
146 " Show trailing whitespaces
147 " exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
148 " set list
149
150 " Vim Math plugin; make simple calculations
151 vmap <expr> ++ VMATH_YankAndAnalyse()
152 nmap ++ vip++
153
154 " Airline configuration
155 let g:airline_inactive_collapse=0
156 let g:airline_powerline_fonts=1
157
158 let g:airline_left_sep = ''
159 let g:airline_right_sep = ''
160
161 let g:airline_theme = 'tomorrow'
162
163 let g:airline#extensions#syntastic#enabled = 0
164
165 nnoremap <F5> :buffers<CR>:buffer<Space>
166 noremap <C-TAB> <C-w><C-w>
167
168 " Set leader to ,
169 let mapleader = ","
170
171 " Custom key mappings
172
173 let g:yankring_replace_n_pkey = 'cp'
174
175 " Nerdtree
176 map <F2> :NERDTreeToggle<CR>
177 map <Leader>e :NERDTreeToggle<CR>
178 let NERDTreeIgnore = ['\.aux$', '\.log$', '\.out$']
179
180 " Vim - Rspec
181 map <leader>t :call RunCurrentSpecFile()<CR>
182 map <leader>s :call RunNearestSpec()<CR>
183 map <leader>l :call RunLastSpec()<CR>
184 map <leader>r :call RunAllSpecs()<CR>
185
186 " Cucumber
187 map <leader>f :call RunAllFeatures()<CR>
188 map <leader>k :call RunCurrentFeature()<CR>
189
190 " Autocomplete
191 inoremap <C-Space> <C-N>
192
193 " Single char insertion
194 " nmap <Space> i_<Esc>r
195
196 " Clear highlight
197 nnoremap <silent> <leader>n :nohlsearch<CR>
198
199 " ctrl p - Fuzzy file finder
200 noremap <C-p> :CtrlP<CR>
201 let g:ctrl_map = '<c-p>'
202 let g:ctrl_cmd = 'CtrlP'
203
204 map <C-l> :CtrlPBuffer<CR>
205 map <C-m> :CtrlPTag<CR>
206
207 " ctrl p - Commands
208 map <leader>p :CtrlPCmdPalette<CR>
209
210 " Markdown
211 let g:vim_markdown_folding_disabled=1
212
213 " tComment remap
214 nmap <leader>c <C-_><C-_>
215
216 " Neo Complete
217 let g:acp_enableAtStartup=0
218 let g:neocomplete#enable_at_startup=1
219 let g:neocomplete#enable_smart_case=1
220 let g:neocomplete#sources#syntax#min_keyword_length=3
221 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
222
223 " Define dictionary.
224 let g:neocomplete#sources#dictionary#dictionaries = {
225 \ 'default' : '',
226 \ 'vimshell' : $HOME.'/.vimshell_hist',
227 \ 'scheme' : $HOME.'/.gosh_completions'
228 \ }
229 " Recommended key-mappings.
230 " <CR>: close popup and save indent.
231 inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
232 function! s:my_cr_function()
233 return neocomplete#close_popup() . "\<CR>"
234 " For no inserting <CR> key.
235 "return pumvisible() ? neocomplete#close_popup() : "\<CR>"
236 endfunction
237 " <TAB>: completion.
238 inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
239 " <C-h>, <BS>: close popup and delete backword char.
240 inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
241
242 autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
243 autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
244 autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
245 autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
246 autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
247 autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
248 if !exists('g:neocomplete#sources#omni#input_patterns')
249 let g:neocomplete#sources#omni#input_patterns = {}
250 endif
251
252 " Neo Snippets
253 imap <C-k> <Plug>(neosnippet_expand_or_jump)
254 smap <C-k> <Plug>(neosnippet_expand_or_jump)
255 xmap <C-k> <Plug>(neosnippet_expand_target)
256
257 imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
258 \ "\<Plug>(neosnippet_expand_or_jump)"
259 \: pumvisible() ? "\<C-n>" : "\<TAB>"
260 smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
261 \ "\<Plug>(neosnippet_expand_or_jump)"
262 \: "\<TAB>"
263 let g:neocomplete#sources#omni#input_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
264
265 let g:neosnippet#snippets_directory='~/.vim/snippets'
266
267 " Tabular
268 inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
269
270 function! s:align()
271 let p = '^\s*|\s.*\s|\s*$'
272 if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
273 let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
274 let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
275 Tabularize/|/l1
276 normal! 0
277 call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
278 endif
279 endfunction
280
281 " Align Migration files
282 vmap <c-a> :Tabularize /:/l1l0l0<CR>
283
284 nmap <Leader>a= :Tabularize /=<CR>
285 vmap <Leader>a= :Tabularize /=<CR>
286 nmap <Leader>a=> :Tabularize /=><CR>
287 vmap <Leader>a=> :Tabularize /=><CR>
288 nmap <Leader>a: :Tabularize /:\zs/l0l1<CR>
289 vmap <Leader>a: :Tabularize /:\zs/l0l1<CR>
290 nmap <Leader>a, :Tabularize /,\zs/l0l1<CR>
291 vmap <Leader>a, :Tabularize /,\zs/l0l1<CR>
292 vmap <Leader>a- :Tabularize /-<CR>
293
294
295
296 augroup markdown
297 au!
298 au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
299 augroup END
300
301
302 " Latex plugin
303 au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb
304 au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0
305 au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb
306 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0
307
308 let g:tex_conseal = ""
309
310 let g:tex_comment_nospell=1
311 let g:Tex_DefaultTargetFormat = 'pdf'
312 let g:tex_flavor = 'latex'
313 let g:Tex_TreatMacViewerAsUNIX = 1
314 let g:Tex_ExecuterUNIXViewerInForeground = 1
315 let g:Tex_ViewRule_pdf = 'open -a Preview'
316 let g:Tex_ViewRule_ps = 'open -a Preview'
317
318 " Tagbar mapping
319 nmap <F8> :TagbarToggle<CR>
320
321 " The silver searcher
322 " let g:ackprg = 'ag --nogroup --nocolor --column'
323
324 " Multiple cursor insert
325 let g:multi_cursor_next_key='<C-n>'
326 let g:multi_cursor_prev_key='<C-m>'
327 let g:multi_cursor_skip_key='<C-x>'
328 let g:multi_cursor_quit_key='<Esc>'
329
330 " Gundo tree
331 nnoremap <leader>u :GundoToggle<CR>
332
333 " Yank ring
334 nnoremap <silent> <leader>y :YRShow<CR>
335
336 let g:livepreview_previewer = 'open -a Preview'