Mercurial > dotfiles.old
annotate vimrc @ 14:09c60bc0fc38
Add vim-textmanip for visual block dragging
author | zegervdv <zegervdv@me.com> |
---|---|
date | Mon, 10 Mar 2014 20:37:14 +0100 |
parents | dd1519fc21e3 |
children | 17afab9bd228 |
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 | |
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 | |
4
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
83 " Switch between the last two files |
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
84 nnoremap <SPACE><SPACE> <C-^> |
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
85 |
0 | 86 " Very Magic search patterns |
87 nmap / /\v | |
88 cmap s/ s/\v | |
89 | |
90 | |
91 inoremap £ \ | |
92 | |
4
050d4d8c6796
Vim: use double space to alternate files
zegervdv <zegervdv@me.com>
parents:
3
diff
changeset
|
93 " nnoremap <SPACE> <C-e> |
0 | 94 |
95 " Close Quickfix window (,qq) | |
5 | 96 " map <leader>qq :cclose<CR> |
0 | 97 |
98 nnoremap <silent> n n:call HLNext(0.4)<cr> | |
99 nnoremap <silent> N N:call HLNext(0.4)<cr> | |
100 | |
101 function! HLNext (blinktime) | |
102 highlight WhiteOnRed ctermfg=white ctermbg=red guifg=white guibg=red | |
103 let [bufnum, lnum, col, off] = getpos('.') | |
104 let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/)) | |
105 let target_pat = '\c\%#'.@/ | |
106 let ring = matchadd('WhiteOnRed', target_pat, 101) | |
107 redraw | |
108 exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' | |
109 call matchdelete(ring) | |
110 redraw | |
111 endfunction | |
112 | |
113 " Swap v and CTRL-V | |
114 nnoremap v <C-V> | |
115 nnoremap <C-V> v | |
116 | |
117 vnoremap v <C-V> | |
118 vnoremap <C-V> v | |
119 | |
120 " Use backspace as delete in visual mode | |
121 vmap <BS> x | |
122 | |
123 " Keep selection when shifting | |
124 vmap <expr> > KeepVisualSelection(">") | |
125 vmap <expr> < KeepVisualSelection("<") | |
126 | |
127 function! KeepVisualSelection(cmd) | |
128 set nosmartindent | |
129 if mode() ==# "V" | |
130 return a:cmd . ":set smartindent\<CR>gv" | |
131 else | |
132 return a:cmd . ":set smartindent\<CR>" | |
133 endif | |
134 endfunction | |
135 | |
136 let g:indent_guides_auto_colors = 0 | |
137 let g:indent_guides_guide_size = 1 | |
138 highlight IndentGuidesEven guibg=background | |
139 highlight IndentGuidesOdd guibg='#282a2e' | |
140 | |
141 " Show trailing whitespaces | |
142 " exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~" | |
143 " set list | |
144 | |
145 " Vim Math plugin; make simple calculations | |
146 vmap <expr> ++ VMATH_YankAndAnalyse() | |
147 nmap ++ vip++ | |
148 | |
149 " Airline configuration | |
150 let g:airline_inactive_collapse=0 | |
151 let g:airline_powerline_fonts=1 | |
152 | |
153 let g:airline_left_sep = '' | |
154 let g:airline_right_sep = '' | |
155 | |
156 let g:airline_theme = 'tomorrow' | |
157 | |
158 let g:airline#extensions#syntastic#enabled = 0 | |
159 | |
160 nnoremap <F5> :buffers<CR>:buffer<Space> | |
161 noremap <C-TAB> <C-w><C-w> | |
162 | |
163 " Set leader to , | |
164 let mapleader = "," | |
165 | |
166 " Custom key mappings | |
167 | |
168 let g:yankring_replace_n_pkey = 'cp' | |
169 | |
170 " Nerdtree | |
171 map <F2> :NERDTreeToggle<CR> | |
172 map <Leader>e :NERDTreeToggle<CR> | |
173 let NERDTreeIgnore = ['\.aux$', '\.log$', '\.out$'] | |
174 | |
175 " Vim - Rspec | |
176 map <leader>t :call RunCurrentSpecFile()<CR> | |
177 map <leader>s :call RunNearestSpec()<CR> | |
178 map <leader>l :call RunLastSpec()<CR> | |
179 map <leader>r :call RunAllSpecs()<CR> | |
180 | |
181 " Cucumber | |
182 map <leader>f :call RunAllFeatures()<CR> | |
183 map <leader>k :call RunCurrentFeature()<CR> | |
184 | |
185 " Autocomplete | |
186 inoremap <C-Space> <C-N> | |
187 | |
188 " Single char insertion | |
189 " nmap <Space> i_<Esc>r | |
190 | |
191 " Clear highlight | |
192 nnoremap <silent> <leader>n :nohlsearch<CR> | |
193 | |
194 " ctrl p - Fuzzy file finder | |
195 noremap <C-p> :CtrlP<CR> | |
196 let g:ctrl_map = '<c-p>' | |
197 let g:ctrl_cmd = 'CtrlP' | |
198 | |
199 map <C-l> :CtrlPBuffer<CR> | |
200 map <C-m> :CtrlPTag<CR> | |
201 | |
5 | 202 if executable('ag') |
203 let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
204 let g:ctrlp_use_caching = 0 | |
205 endif | |
206 | |
0 | 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 | |
13 | 336 " Open pdf in Preview |
0 | 337 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
|
338 |
13 | 339 |
340 " Smalls | |
341 nmap s <Plug>(smalls) | |
342 omap s <Plug>(smalls) | |
343 xmap s <Plug>(smalls) | |
344 | |
14
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
345 " Textmanip |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
346 xmap <C-j> <Plug>(textmanip-move-down) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
347 xmap <C-k> <Plug>(textmanip-move-up) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
348 xmap <C-h> <Plug>(textmanip-move-left) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
349 xmap <C-l> <Plug>(textmanip-move-right) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
350 xmap <F10> <Plug>(textmanip-toggle-mode) |
09c60bc0fc38
Add vim-textmanip for visual block dragging
zegervdv <zegervdv@me.com>
parents:
13
diff
changeset
|
351 |
13 | 352 " Load local vimrc |
3
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
353 if filereadable($HOME . "/.vimrc.local") |
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
354 source ~/.vimrc.local |
44d3af8838f8
Add support for local zshrc and vimrc files
zegervdv <zegervdv@me.com>
parents:
0
diff
changeset
|
355 endif |