-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc_on_mac
442 lines (379 loc) · 12.7 KB
/
.vimrc_on_mac
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
" fork from github/tienle
set nocompatible
"-----------------------------------------------------------------------------
" Vundle
"-----------------------------------------------------------------------------
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'Lokaltog/vim-easymotion'
"Bundle 'Lokaltog/vim-powerline'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
"Bundle 'scrooloose/syntastic'
Bundle 'tpope/vim-pathogen'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-rails.git'
Bundle 'tpope/vim-haml'
Bundle 'tpope/vim-bundler'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-repeat'
Bundle 'godlygeek/tabular'
Bundle 'mutewinter/vim-indent-guides'
Bundle 'pangloss/vim-javascript'
Bundle 'kchmck/vim-coffee-script'
Bundle 'leshill/vim-json'
Bundle 'kana/vim-textobj-user'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'vim-scripts/ZoomWin'
Bundle 'vim-scripts/matchit.zip'
Bundle 'vim-scripts/greplace.vim'
Bundle 'itspriddle/vim-jquery'
"Bundle 'fholgado/minibufexpl.vim'
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
Bundle 'snipmate-snippets'
Bundle 'garbas/vim-snipmate'
Bundle 'kien/ctrlp.vim'
Bundle 'mileszs/ack.vim'
Bundle 'garbas/vim-snipmate'
Bundle 'vim-ruby/vim-ruby'
"Bundle 'wincent/Command-T'
Bundle 'kien/ctrlp.vim'
Bundle 'tienle/vim-itermux'
" vim-scripts repos
Bundle 'L9'
Bundle 'vis'
Bundle 'bocau'
Bundle 'YankRing.vim'
Bundle 'altercation/vim-colors-solarized'
Bundle 'kikijump/tslime.vim'
"Bundle 'jeffkreeftmeijer/vim-numbertoggle'
"-----------------------------------------------------------------------------
" General
"-----------------------------------------------------------------------------
set history=1024
set cf " enable error files and error jumping
set ffs=unix,dos,mac " support these files
filetype plugin indent on
set isk+=_,$,@,%,#,-
set modeline
set autoread " reload file
set tabpagemax=50 " open 50 tabs max
set splitbelow
if version>=730
set undodir=/tmp
set undofile
set undolevels=1000
endif
"-----------------------------------------------------------------------------
" Colors/ Theme
"-----------------------------------------------------------------------------
if !has("gui_running")
set t_Co=256
set term=xterm-256color
endif
colo bocau
if !has('mac')
set guifont=ProggyCleanTT\ 14
else
set guifont=Monaco:h13
endif
if has("syntax")
syntax on
endif
set hls " Highlighting search result
"-----------------------------------------------------------------------------
" Backup
"-----------------------------------------------------------------------------
set nobackup
set nowritebackup
set noswapfile
set backupdir=/tmp/
set backupcopy=yes
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
set directory=/tmp
"-----------------------------------------------------------------------------
" UI
"-----------------------------------------------------------------------------
set ruler " show cursor position all the time
set nolazyredraw
set number " set line number on
set wildmenu
set ch=1 " command line height
set backspace=indent,eol,start " backspace through everything in insert mode
set report=0 " tell us about changes
set guioptions=aegitcm
"win 180 50
set mousehide " hide mouse after chars typed
set mouse=a " mouse in all modes
map <M-Esc>[62~ <ScrollWheelUp>
map! <M-Esc>[62~ <ScrollWheelUp>
map <M-Esc>[63~ <ScrollWheelDown>
map! <M-Esc>[63~ <ScrollWheelDown>
map <M-Esc>[64~ <S-ScrollWheelUp>
map! <M-Esc>[64~ <S-ScrollWheelUp>
map <M-Esc>[65~ <S-ScrollWheelDown>
map! <M-Esc>[65~ <S-ScrollWheelDown>
if has('statusline')
set laststatus=2 " always show status line
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
"set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " filetype
"set statusline+=\ [%{getcwd()}] " current dir
"set statusline+=\ [A=\%03.3b/H=\%02.2B] " ASCII / Hexadecimal value of char
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
"-----------------------------------------------------------------------------
" Visual cues
"-----------------------------------------------------------------------------
set showmatch
set incsearch
set ignorecase " case insensitive search
set mat=5 " bracket blinking
set novisualbell " no blinking
highlight ExtraWhitespace ctermbg=yellow guibg=yellow
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
autocmd BufWritePre * :%s/\s\+$//e
"-----------------------------------------------------------------------------
" Text formatting
"-----------------------------------------------------------------------------
set autoindent
set smartindent
set nowrap
set tabstop=2
set softtabstop=2
set nosmarttab
set formatoptions+=n
set shiftwidth=2
set encoding=utf-8
set vb t_vb=
set virtualedit=all
set textwidth=80
set smartcase
set expandtab
set list
" List chars
set listchars="" " Reset the listchars
set listchars=tab:\`\ " a tab should display as " ", trailing whitespace as "."
set listchars+=trail:. " show trailing spaces as dots
set listchars+=extends:> " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set listchars+=precedes:< " The character to show in the last column when wrap is
" off and the line continues beyond the right of the screen
set foldmethod=syntax
set foldnestmax=10
set nofoldenable "don't fold by default
set foldlevel=1
"set clipboard+=unnamed " yanks go on clipboard instead
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set cindent
"-----------------------------------------------------------------------------
" Mapping keys
"-----------------------------------------------------------------------------
" remap Leader to , instead of \
let mapleader = ","
"save
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
if has("gui_macvim") && has("gui_running")
imap <D-]> <Esc>>>i
imap <D-[> <Esc><<i
else
imap <A-]> <Esc>>>i
imap <A-[> <Esc><<i
endif
" format the entire file
nmap <leader>fef gg=G<C-O><C-O>
nmap <leader>q :bd<CR>
" close quickfix window
nmap <leader>x :ccl<CR>
nmap <leader>w :w<CR>
if has("gui_macvim") && has("gui_running")
map <D-J> :m +1 <CR>
map <D-K> :m -2 <CR>
map <D-j> 4j
map <D-k> 4k
vnoremap <D-J> dp'[V']
vnoremap <D-K> dkP'[V']
"move to next/previous line with same indentation
nnoremap <D-,> k:call search('^'. matchstr(getline(line('.')+1), '\(\s*\)') .'\S', 'b')<CR>^
nnoremap <D-.> :call search('^'. matchstr(getline(line('.')), '\(\s*\)') .'\S')<CR>^
" RSI preventions
imap <silent> <D-k> _
nnoremap <D-'> ci'
imap <D-'> <Esc>ci'
nnoremap <D-"> ci"
imap <D-"> <Esc>ci"
else
map <M-J> :m +1 <CR>
"map <M-K> :m -2 <CR>
"map <C-j> 4j
"map <C-k> 4k
vnoremap <M-J> dp'[V']
vnoremap <M-K> dkP'[V']
"move to next/previous line with same indentation
nnoremap <M-,> k:call search('^'. matchstr(getline(line('.')+1), '\(\s*\)') .'\S', 'b')<CR>^
nnoremap <M-.> :call search('^'. matchstr(getline(line('.')), '\(\s*\)') .'\S')<CR>^
" RSI preventions
imap <silent> <M-k> _
nnoremap <M-'> ci'
imap <M-'> <Esc>ci'
nnoremap <M-"> ci"
imap <M-"> <Esc>ci"
endif
vnoremap < <gv
vnoremap > >gv
nnoremap <silent> vv <C-w>v
"noremap H ^
"noremap L $
map <F2> :NERDTreeToggle<CR>
map <Leader>nt :NERDTreeToggle<CR>
"map <Leader>a :Ack <cword><CR>
"nmap <tab> v>
"vmap <tab> >gv
"vmap <tab> >gv
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:<CR>
vmap <Leader>a: :Tabularize /:<CR>
"a trick for sudo save
cmap w!! w !sudo tee % >/dev/null
" map esc
"imap ;; <Esc>
imap jj <Esc>
imap jk <Esc>
"Remap VIM 0
noremap 0 ^
noremap ^ 0
" make Y consistent with C and D
nnoremap Y y$
"Ctrl + Space to auto complete on local buff
imap <C-Space> <C-P>
"Expand current file's path
cnoremap <C-F> <C-R>=expand('%:p:h')<CR>
nnoremap gG :OpenURL http://www.google.com/search?q=<cword><CR>
nnoremap gA :Ack! <cword><CR>
nnoremap <silent> <F3> :TlistToggle<CR>
let g:CommandTMatchWindowAtTop = 1
let g:CommandTCancelMap=['<ESC>']
nnoremap <Leader><Space> :CtrlP<CR>
nnoremap <Leader>b :CommandTBuffer<CR>
nnoremap <silent> <F4> :CtrlPClearCache<CR>
nnoremap <Leader>u :CommandTFlush<CR>
"let g:ctrlp_map = '<Leader><Space>'
"let g:ctrlp_working_path_mode = 2
let g:ctrlp_match_window_bottom = 0
let g:ctrlp_match_window_reversed = 0
"nnoremap <silent> <F5> <Esc>:ClearCtrlPCache<CR>
let MRU_Max_Entries = 400
nnoremap <Leader>j :CtrlPMRU<CR>
"nnoremap <Leader>b :CtrlPBuffer<CR>
"nnoremap <Leader>f <C-^>
set wildignore+=*.o,*.obj,.git
"clear highlight search
nnoremap <Esc> :noh<CR><Esc>
"Ctrl + S to save
map <C-s> :w<CR>
imap <C-s> <Esc>:w<CR>
" Toogle buffer zoom
map <Leader>zw <C-w>o
" make Y consistent with C and D
nnoremap Y y$
"Ctrl + Space to auto complete on local buff
imap <C-Space> <C-P>
"autotest
"nmap <Leader>fd :cf /tmp/autotest.txt<CR> :compiler rubyunit<CR>
"rspec test
"map <Leader>r :SweetSpec<CR>
"map <Leader>R :SweetSpecRunAtLine<CR>
"map <Leader>L :SweetSpecRunLast<CR>
"-----------------------------------------------------------------------------
" Auto commands
"-----------------------------------------------------------------------------
" Edit .vimrc
au! BufRead,BufNewFile *.haml setfiletype haml
au! BufRead,BufNewFile *.hamlc setfiletype haml
au! BufRead,BufNewFile *.rabl setfiletype ruby
"auto open NERDTree when start
"autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
"NERD Tree
"let g:NERDCreateDefaultMappings=0
"let g:NERDSpaceDelims=1
"let g:NERDShutUp=1
"let g:NERDTreeHijackNetrw=0
"-----------------------------------------------------------------------------
" Ruby related
"-----------------------------------------------------------------------------
compiler rubyunit
let g:rubytest_in_quickfix = 0 " minimal ruby test error message
let g:rubytest_cmd_test = "ruby %p"
let g:rubytest_cmd_testcase = "ruby %p -n '/%c/'"
let g:rubytest_cmd_spec = "spec -f specdoc %p"
let g:rubytest_cmd_example = "spec -f specdoc %p -e '%c'"
let g:rubytest_cmd_feature = "cucumber %p"
let g:rubytest_cmd_story = "cucumber %p -n '%c'"
"au Filetype ruby call Foldsearch("")
au Filetype ruby let b:foldsearchprefix='\v^\s*(#.*)?$'
let Tlist_Exit_OnlyWindow = 1 " exit if taglist is last window open
let Tlist_Show_One_File = 1 " Only show tags for current buffer
let Tlist_Enable_Fold_Column = 0 " no fold column (only showing one file)
let tlist_sql_settings = 'sql;P:package;t:table'
let tlist_ant_settings = 'ant;p:Project;r:Property;t:Target'
"let Tlist_Ctags_Cmd = $VIM.'/vimfiles/ctags.exe' " location of ctags tool
let g:rails_ctags_arguments = "`gem env gemdir`/gems"
set tags=tags;/
let g:rails_ctags_arguments = "`gem env gemdir`/gems"
"auto update ctags after file was saved
au BufWritePost .rb,.c,.cpp,*.h silent! !ctags -R &
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/gem/**;vendor/plugins/**;coverage/**;tmp/**;rdoc/**"
let g:fuf_splitPathMatching=1
" Auto indicating changes
"let g:changes_autocmd=1
let g:changes_vcs_system='git'
"Mini buffer
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplMapWindowNavArrows = 1
"let g:miniBufExplMapCTabSwitchBufs = 1
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplSplitBelow = 0
" Indent guides
"let g:indent_guides_guide_size = 1
"
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
if has("gui_running")
if has("autocmd")
" Automatically resize splits when resizing MacVim window
autocmd VimResized * wincmd =
endif
endif
let g:no_itermux_mappings = 1
let g:itermux_session_name = 'rspec'
let g:rspec_drb = 1
if has('mac')
nmap <leader>T <ESC>:call SendTestToiTerm(expand('%'))<CR>
nmap <leader>t <ESC>:call SendFocusedTestToiTerm(expand('%'), line('.'))<CR>
endif
map <CR> o<Esc>
set cursorline
set cursorcolumn
set expandtab