-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
412 lines (353 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
" Changes leader key
let mapleader = ","
" Buffers events
"""""""""""""""""
"au VimEnter * wincmd l
"au BufEnter * :syntax sync fromstart
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru,*.sinew} set ft=ruby
au BufNewFile,BufRead *.json set filetype=javascript
au BufNewFile,BufRead *.ejs set filetype=html
au BufNewFile,BufRead *.tpl set filetype=html.erb
au BufNewFile,BufRead {*.vimrc,*.vim} set filetype=vim
au BufWinLeave * silent! mkview " Auto-saves foldings
au BufWinEnter * silent! loadview " Auto-load foldings
if !exists('g:trim_trailing_space') || g:trim_trailing_space != 'no'
au BufWritePre * :call StripTrailingWhitespaces()
endif
au insertenter * setlocal cursorline " Highlights on cursor line in insert mode
au insertleave * setlocal nocursorline " Highlights off cursor line in normal mode
"au BufWritePost *.coffee silent CoffeeMake! | cwindow | redraw!
" Reloads vimrc file after saving it
augroup AutoReloadVimRC
au!
au BufWritePost $MYVIMRC so $MYVIMRC
augroup END
let g:ackprg = 'ag --nogroup --nocolor --column'
""""""""""""""""""""""""""""""""""""""""""""
" Settings "
""""""""""""""""""""""""""""""""""""""""""""
syntax on " Enable syntax highlight
set nocompatible " Old-vim Rest In Peace
set rnu " Activates relative line numbers
set ruler " Activates ruler
set encoding=utf-8 " Set encoding
set clipboard=unnamed " Copy/pastes to/from system clipboard
set viminfo+=n~/.vim/viminfo " viminfo stores the the state of your previous editing session
""""""""""""""""""""""""""""""""""""""""""""
set nowrap " Whitespace stuff
set tabstop=2 " Whitespace stuff
set shiftwidth=2 " Whitespace stuff
set softtabstop=2 " Whitespace stuff
set expandtab " Whitespace stuff
set list listchars=tab:\ \ ,trail:· " Whitespace stuff
""""""""""""""""""""""""""""""""""""""""""""
set hlsearch " Search stuff
set incsearch " Search stuff
set ignorecase " Search stuff
set smartcase " Search stuff
""""""""""""""""""""""""""""""""""""""""""""
set wildmode=list:longest,list:full " Tab completion
""""""""""""""""""""""""""""""""""""""""""""
set laststatus=2 " Status bar
set modelines=5 " Status bar
""""""""""""""""""""""""""""""""""""""""""""
set backspace=indent,eol,start " allow backspacing over everything in insert mode
""""""""""""""""""""""""""""""""""""""""""""
set modeline " Activates modeline support
set modelines=10 " Checks 10 first or last lines in a file for vim settings overrides
""""""""""""""""""""""""""""""""""""""""""""
set wrap " Sets lines wrap
set hidden " Buffers are just hidden when closing files
set ttyfast " Fasth terminal connection
set timeout timeoutlen=500 ttimeoutlen=500 " Timeout for keystrokes
set wildignore+=*.o " Ignored files paths
set wildignore+=*.obj " Ignored files paths
set wildignore+=.git " Ignored files paths
set wildignore+=*.rbc " Ignored files paths
set wildignore+=*.class " Ignored files paths
set wildignore+=.svn " Ignored files paths
set wildignore+=vendor/gems/* " Ignored files paths
set wildignore+=*.jpg " Ignored files paths
set wildignore+=*.jpeg " Ignored files paths
set wildignore+=*.jpeg* " Ignored files paths
set wildignore+=*.png " Ignored files paths
set wildignore+=*.gif " Ignored files paths
set wildignore+=.dat* " Ignored files paths
set wildignore+=tags " Ignored files paths
set wildignore+=*.sqlite* " Ignored files paths
set wildignore+=*/public/uploads/* " Ignored files paths
set wildignore+=*/.git/* " Ignored files paths
set wildignore+=*/.bundle/* " Ignored files paths
set wildignore+=*/bin/* " Ignored files paths
set wildignore+=*/log/* " Ignored files paths
set wildignore+=*/tmp/* " Ignored files paths
set wildignore+=*/.sass-cache/* " Ignored files paths
set wildignore+=*/.jhw-cache/* " Ignored files paths
set wildignore+=*/node_modules/* " Ignored files paths
set wildignore+=*/vendor/* " Ignored files paths
set wildignore+=*/resources/* " Ignored files paths
set wildignore+=*/build/* " Ignored files paths
set wildignore+=*/_site/* " Ignored files paths
""""""""""""""""""""""""""""""""""""""""""""
set nobackup " get rid of annoying backup behaviour
set nowritebackup " get rid of annoying backup behaviour
set noswapfile " get rid of annoying backup behaviour
""""""""""""""""""""""""""""""""""""""""""""
set splitright " Vertical splits at right side
set splitbelow " Horizontal splits below
""""""""""""""""""""""""""""""""""""""""""""
set gdefault " don't need /g after :s or :g
""""""""""""""""""""""""""""""""""""""""""""
set completeopt=longest,menuone " Improves autocomplete menu
""""""""""""""""""""""""""""""""""""""""""""
"set foldmethod=syntax " Folds based on syntax
set foldnestmax=2 " Sets max folding level
""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vundle config
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" Vundle bundles
Bundle 'altercation/vim-colors-solarized'
Bundle 'vim-scripts/SearchFold'
Bundle 'kien/ctrlp.vim'
Bundle 'mattn/gist-vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'godlygeek/tabular'
Bundle 'altercation/vim-colors-solarized'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-haml'
Bundle 'michaeljsmith/vim-indent-object'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rvm'
Bundle 'tpope/vim-surround'
Bundle 'mattn/zencoding-vim'
Bundle 'nanotech/jellybeans.vim'
Bundle 'kana/vim-textobj-user'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'coderifous/textobj-word-column.vim'
Bundle 'tpope/vim-vividchalk'
Bundle 'vim-scripts/ZoomWin'
Bundle 'vim-scripts/notes.vim'
Bundle 'msanders/snipmate.vim'
Bundle 'Townk/vim-autoclose'
Bundle 'clones/vim-cecutil'
Bundle 'tpope/vim-ragtag'
Bundle 'vim-ruby/vim-ruby'
Bundle 'AndrewRadev/switch.vim'
Bundle 'samsonw/vim-task'
Bundle 'spolu/dwm.vim'
Bundle 'Lokaltog/vim-powerline'
Bundle 'tsaleh/vim-matchit'
Bundle 'benmills/vimux'
Bundle 'pgr0ss/vimux-ruby-test'
Bundle 'mileszs/ack.vim'
Bundle 'majutsushi/tagbar'
Bundle 'mutewinter/vim-indent-guides'
Bundle 'xolox/vim-easytags'
Bundle 'roman/golden-ratio'
Bundle 'AndrewRadev/splitjoin.vim'
Bundle 'chrisbra/NrrwRgn'
Bundle 'nelstrom/vim-markdown-preview'
Bundle 'sjl/gundo.vim'
Bundle 'ervandew/supertab'
Bundle 'danro/rename.vim'
Bundle 'mikewest/vimroom'
Bundle 'SirVer/ultisnips'
Bundle 'xolox/vim-session'
Bundle 'rnaveiras/vim-git-session'
Bundle 'airblade/vim-gitgutter'
Bundle 'ap/vim-css-color'
Bundle 'sjl/vitality.vim'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vundle config
"""""""""""""""""""""""""""""" Plugins config
so ~/.vim/config/colors.vimrc
so ~/.vim/config/ctrlp.vimrc
so ~/.vim/config/vim-powerline.vimrc
so ~/.vim/config/vim-autoclose.vimrc
so ~/.vim/config/syntastic.vimrc
so ~/.vim/config/vim-task.vimrc
so ~/.vim/config/dwm.vimrc
so ~/.vim/config/vundle.vimrc
so ~/.vim/config/nrrwrgn.vimrc
so ~/.vim/config/vim-markdown-preview.vimrc
so ~/.vim/config/vim-session.vimrc
so ~/.vim/config/vim-easytags.vimrc
so ~/.vim/config/switch.vim.vimrc
"""""""""""""""""""""""""""""" Plugins config
" undo stuff
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/undo') == 0
:silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/undo//
set undofile
endif
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
""""""""""""""""""""""""""""""""
" Functions "
""""""""""""""""""""""""""""""""
fun! StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
function! s:setupWrapping()
set wrap
set wrapmargin=2
set textwidth=72
endfunction
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" % to bounce from do to end etc.
runtime! macros/matchit.vim
""""""""""""""""""""""""""""""""
" Mappings "
""""""""""""""""""""""""""""""""
vnoremap p "_dP
" ZoomWin configuration
map <leader><leader> :ZoomWin<CR>
" CTags
map <leader>rt :!ctags --extra=+f -R *<CR><CR>
map <leader>tt :TagbarToggle<CR>
map <leader>gd <C-]>
" To create new files
map <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>n :tabnew<CR>
map <leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
map <leader>ct :tabc<CR>
map <leader>to :tabo<CR>
" Map ESC to jj and save my pinky
imap jk <ESC>
imap Jk <ESC>
imap JK <ESC>
" Switch between buffers
"nmap <tab> <C-w><C-w>
" :bd deletes the current buffer (all windows of)
"nmap <leader>d :bd<CR>
" ,a to Ack
nn <leader>a :Ack
" Rotating among results in an ack search
map an :cn<CR>
map ap :cp<CR>
" ease of use keyboard mappings (why do I care about top/bottom of screen?)
map H ^
map L $
" remap space bar to search
:nmap <Space> /
" Disable the regular keys to get me on the right track
nn <up> <nop>
nn <down> <nop>
nn <left> <nop>
nn <right> <nop>
ino <up> <nop>
ino <down> <nop>
ino <left> <nop>
ino <right> <nop>
" Better default behaviour with left and right
nn j gj
nn k gk
" easier quitting
" save and close all
nmap <leader>q :wqa!<CR>
nmap <leader>w :w!<CR>
nmap <leader><Esc> :q!<CR>
" Splits ,v to open a new vertical split and switch to it
nn <leader>v <C-w>v<C-w>l
nn <leader>h <C-w>s<C-w>l
" Move between splits
"nn <C-h> <C-w>h
"nn <C-j> <C-w>j
"nn <C-k> <C-w>k
"nn <C-l> <C-w>l
nnoremap <C-J> <C-W>w
nnoremap <C-K> <C-W>W
" Removes highlighted search terms
" <C-M> == <CR>
noremap <CR> :noh<CR>
" Numbers to move between tabs
map <leader>0 0gt
map <leader>1 1gt
map <leader>2 2gt
map <leader>3 3gt
map <leader>4 4gt
map <leader>5 5gt
map <leader>6 6gt
map <leader>7 7gt
map <leader>8 8gt
map <leader>9 9gt
" Formats json files
map <leader>jf <Esc>:%!python -m json.tool<CR>
" Activates VimRoom-mode
nn <silent> <leader>vr :VimroomToggle<CR>
nn 80c :set textwidth=80<CR>
" Folds all foldings but the current you are in
no <leader>z zMzvzz
no aa za
no CC zM
no AA zR
" Ruby test Vimux config
map tf :RunRubyFocusedTest<CR>
map tc :RunRubyFocusedContext<CR>
map ta :RunAllRubyTests<CR>
map tl :RunLastVimTmuxCommand<CR>
map th :CloseVimTmuxPanes<CR>
" Opens vimrc file in a new tab
nmap <leader>vrc :tabedit $MYVIMRC<CR>
" Opens /etc/hosts file
nmap <leader>etc :tabedit /etc/hosts<CR>
" Saves as super-user
nmap <leader>sw :w !sudo tee %<CR>
" Gundo toggle
nmap <leader>u :GundoToggle<CR>
" Alignment commands
nn <leader>\" :Tabularize /"<CR>
nn <leader>= :Tabularize /=<CR>
nn <leader>=> :Tabularize /=<CR>
nn <leader>{ :Tabularize /{<CR>
nn <leader>} :Tabularize /}<CR>
nn <leader>; :Tabularize /;<CR>
nn <leader>\: :Tabularize /\:<CR>
" Nerdtree commands
nn <leader>nt :NERDTreeToggle<CR>
" Use sane regexp
nn / /\v
vn / /\v
" Format commands
nnoremap - :Switch<cr>
" Moving between diffs
nn <leader>nd ]c
nn <leader>pd [c
" Code shortcuts
nn db orequire 'debugger'; debugger<Esc>
nn rb orequire 'ruby-debug'; debugger<Esc>
nn tabu :Tabularize /
nn <tab><tab> :Tabularize /
vn <tab><tab> :Tabularize /
nn // :%s//
nn == :Tabularize /=<CR>
vn == :Tabularize /=<CR>
nn {{ :Tabularize /{<CR>
vn {{ :Tabularize /{<CR>
nn }} :Tabularize /}<CR>
vn }} :Tabularize /}<CR>
nn <C-f> <Nop>
""""""""""""""""""""""""""""""""
" Macros "
""""""""""""""""""""""""""""""""
let @r='/def V%zf'