-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
531 lines (415 loc) · 12.9 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Moving around, tabs and buffers
" -> Status line
" -> Editing mappings
" -> Spell checking
" -> Diff options
" -> Misc
" -> Helper functions
" -> Plugins
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %
" Use Vim settings, rather than Vi settings (much better!).
set nocompatible
" Enable filetype plugins
filetype plugin indent on
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
let mapleader = ","
let g:mapleader = ","
" System clipboard, no need of "+
set clipboard=unnamedplus
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Keep 7 lines distance when scrolling
set scrolloff=7
" Turn on the Wild menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,.git\*,.hg\*,.svn\*
" Always show current position
set ruler
" Show line number
set number
" A buffer becomes hidden when it is abandoned
set hidden
" Allow for cursor beyond last character
set virtualedit=onemore
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
" Allowed especified keys to cross line boundaries
set whichwrap+=b,s,h,l,<,>,[,]
" Ignore case when searching
set ignorecase
" No ignore case when pattern has uppercase
set smartcase
" Highlight search results
set hlsearch
" Highlight match while typing search pattern
set incsearch
" Show matching brackets when text indicator is over them
set showmatch
" No annoying sound on errors
set vb t_vb=
set t_vb=
" Highlight problematic whitespaces
set list
set listchars=tab:▸\ ,trail:.,extends:#,nbsp:.
" Remap join to merge comment lines
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j
endif
" Avoid escape key delay
if !has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Dark background
set background=dark
" Force 256 support
set t_Co=256
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nowritebackup
set noswapfile
" Persistent undo
set undofile
set undodir=~/.vim/tmp/undodir
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Expand tab with spaces
set expandtab
" Smart tab size
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set softtabstop=4
set tabstop=4
" Tablength exceptions
"autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
"autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
"autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Linebreak on 78 characters
set textwidth=78
set colorcolumn=80
" Indent options
set autoindent
set smartindent
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Easier moving of code blocks
vnoremap < <gv
vnoremap > >gv
" Smart way to move between windows
map <C-l> <c-w>l
map <C-h> <c-w>h
map <C-k> <c-w>k
map <C-j> <c-w>j
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,1000 bd!<cr>
" Tab navigation
map tm :tabm
map tt :tabnew<CR>
map X :tabn<CR>
map Z :tabp<CR>
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Return to last edit position when opening files
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
set noshowmode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Display incomplete commands
set showcmd
" Remap VIM 0 to first non-blank character
map 0 ^
" Remap H and L as the beginning and end of line, respectively.
map H ^
map L g_
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" Fast saving
nmap <leader>w :update<cr>
" Fast quiting
nmap <leader>q :quit<cr>
" Fast sorting
vnoremap <leader>s :sort<cr>
" Easier formatting of paragraphs
vmap Q gq
nmap Q gqap
" I don't have insert key. It's usefull for switching between replace and
" insert mode.
inoremap <C-z> <Insert>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Spell check in spanish by default
set spelllang=es
" Pressing ,ss will toggle spell checking
map <leader>ss :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Diff options
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ignore changes in the amount of white spaces
set diffopt+=iwhite
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Toggle paste mode on and off
set pastetoggle=<F12>
" For when you forget to sudo.. Really Write the file.
ca w!! w !sudo tee "%" > /dev/null
" Disable highlight when <leader>/ is pressed
map <silent> <leader>/ :noh<CR>
" Remove trailing spaces on save
autocmd BufWritePre * mark z | %s/\s\+$//e | 'z
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" => Vundle
""""""""""""""""""""""""""""""
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle..."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
" Required for Vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
" Required!
Bundle 'gmarik/vundle'
" Bundles from GitHub repos:
" Better file browser
Bundle 'scrooloose/nerdtree'
" Code commenter
Bundle 'scrooloose/nerdcommenter'
" Code checker
Bundle 'scrooloose/syntastic'
" Class/module browser
Bundle 'majutsushi/tagbar'
" Code and files fuzzy finder
Bundle 'kien/ctrlp.vim'
" Zen coding
Bundle 'mattn/emmet-vim'
" Fugitive - Git integration
Bundle 'tpope/vim-fugitive'
" Gitk clone, compatible with fugitive
Bundle 'gregsexton/gitv'
" Airline
Bundle 'bling/vim-airline'
" Pending tasks list
Bundle 'fisadev/FixedTaskList.vim'
" Surround
Bundle 'tpope/vim-surround'
" Autoclose
Bundle 'Raimondi/delimitMate'
" Indent text object
Bundle 'michaeljsmith/vim-indent-object'
" Python mode (indentation, doc, refactor, lints, code checking, motion and
" operators, highlighting, run and ipdb breakpoints)
Bundle 'klen/python-mode'
" Git diff icons on the side of the file lines
Bundle 'airblade/vim-gitgutter'
" Multiple cursors
Bundle 'terryma/vim-multiple-cursors'
" Seamless navigation between tmux panes and vim splits
Bundle 'christoomey/vim-tmux-navigator'
" Autocompletition
Bundle 'Valloric/YouCompleteMe'
" UltiSnips Code Completition
Bundle 'SirVer/ultisnips'
" Snipmate and Ultisnips snippets
Bundle 'honza/vim-snippets'
" Bundles from vim-scripts repos
" XML/HTML tags navigation
Bundle 'matchit.zip'
" Colorschemes
" Hybrid theme, based on tomorrow, jellybeans and solarized
Bundle 'w0ng/vim-hybrid'
Bundle 'nanotech/jellybeans.vim'
" Harlequin theme, based on badwolf and molokai
Bundle 'nielsmadan/harlequin'
Bundle 'altercation/solarized', {'rtp': 'vim-colors-solarized/'}
Bundle 'chriskempson/tomorrow-theme', {'rtp': 'vim/'}
Bundle 'jnurmine/Zenburn'
" Installing plugins the first time
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
""""""""""""""""""""""""""""""
" => Colorschemes
""""""""""""""""""""""""""""""
" Solarized colorscheme settings
let g:solarized_termcolors = 256
let g:solarized_contrast = 'high'
" Set colorscheme
colorscheme hybrid
""""""""""""""""""""""""""""""
" => Ultisnips
""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger="<c-e>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
""""""""""""""""""""""""""""""
" => Tagbar
""""""""""""""""""""""""""""""
map <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
""""""""""""""""""""""""""""""
" => Fixedtasklist
""""""""""""""""""""""""""""""
" Show pending tasks list
map <F2> :TaskList<CR>
""""""""""""""""""""""""""""""
" => Nerdtree
""""""""""""""""""""""""""""""
map <F3> :NERDTreeToggle<CR>
" Ignore files on NERDTree
let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
""""""""""""""""""""""""""""""
" => Syntastic
""""""""""""""""""""""""""""""
map <F10> :SyntasticToggleMode<CR>
" Better :sign interface symbols
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_javascript_closure_compiler_path = '/usr/share/java/closure-compiler/closure-compiler.jar'
" let g:syntastic_javascript_checkers = ["jslint", "closurecompiler"]
" let g:syntastic_python_checkers=["flake8", "pep257", "py3kwarn"]
""""""""""""""""""""""""""""""
" => Fugitive
""""""""""""""""""""""""""""""
" Auto-clean fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
" Go up a level to open the parent tree with '..'
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
""""""""""""""""""""""""""""""
" => Gitv
""""""""""""""""""""""""""""""
nmap <leader>gv :Gitv --all<cr>
nmap <leader>gV :Gitv! --all<cr>
vmap <leader>gV :Gitv! --all<cr>
""""""""""""""""""""""""""""""
" => CtrlP
""""""""""""""""""""""""""""""
let g:ctrlp_map = ',e'
nmap ,f :CtrlPLine<CR>
" Don't change working directory
let g:ctrlp_working_path_mode = 0
" Ignore files on fuzzy finder
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|\.hg|\.svn)$',
\ 'file': '\.pyc$\|\.pyo$',
\ }
""""""""""""""""""""""""""""""
" => Python-mode
""""""""""""""""""""""""""""""
" Disable python folding
let g:pymode_folding = 0
" Disable code checking
let g:pymode_lint = 0
" Disable rope plugin
let g:pymode_rope = 0
""""""""""""""""""""""""""""""
" => Nerdcommenter
""""""""""""""""""""""""""""""
" Agrega espacios entre los delimitadores de los comentarios
let NERDSpaceDelims = 1
""""""""""""""""""""""""""""""
" => Gitgutter
""""""""""""""""""""""""""""""
" Fix some problems with gitgutter and jedi-vim
let g:gitgutter_eager = 0
let g:gitgutter_realtime = 0 "
""""""""""""""""""""""""""""""
" => Airline
""""""""""""""""""""""""""""""
let g:airline_theme = 'tomorrow'
let g:airline#extensions#whitespace#enabled = 0
let g:airline_powerline_fonts = 0
" Vim-powerline symbols
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
let g:airline_branch_prefix = '⭠'
let g:airline_readonly_symbol = '⭤'
let g:airline_linecolumn_prefix = '⭡'"
""""""""""""""""""""""""""""""
" => YouCompleteMe
""""""""""""""""""""""""""""""
let g:ycm_key_detailed_diagnostics = ''
nnoremap <leader>d :YcmCompleter GoToDefinition<CR>