-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
365 lines (290 loc) · 9.51 KB
/
vimrc
File metadata and controls
365 lines (290 loc) · 9.51 KB
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
filetype off
source ~/.vim/bundle/vim-pathogen.git/autoload/pathogen.vim
call pathogen#infect()
syntax on
filetype on
filetype indent on
filetype plugin on
" Display
set t_Co=256
let g:solarized_contrast="high"
set background=light
colorscheme solarized
set nocompatible " the past is better left in the past
set modelines=0 " workaround for vulnerability with spell files
set encoding=utf-8 nobomb
set spell spelllang=en_us
set noerrorbells
set visualbell
set showcmd
set ruler
set nu
set autoread
set hidden
set nobackup
set nowb
set noswapfile
set lazyredraw
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=2
set smarttab
set autoindent
set shiftround
set list
" eol:¬
set listchars=tab:»\ ,trail:·,precedes:<,extends:>
set backspace=indent,eol,start " backspace over anything
set guifont=Menlo:h12
set ttyfast
set scrolloff=5 " minimum lines to show around cursor
set sidescrolloff=5 " min characters to show
set cursorline
set colorcolumn=80
let s:colorcolumn_old=0
highlight OverLength ctermbg=red ctermfg=white
match OverLength /\%81v.\+/
function! s:ToggleColorColumn()
if s:colorcolumn_old == 0
let s:colorcolumn_old = &colorcolumn
windo let &colorcolumn = 0
else
windo let &colorcolumn = s:colorcolumn_old
let s:colorcolumn_old = 0
endif
endfunction
nnoremap <Leader>8 :call <SID>ToggleColorColumn()<cr>
set wildmenu
set wildmode=list:longest,full
" use per-project .virmc
set exrc
set secure
set mouse=a
nnoremap ; :
" I always hit this when I mean to hit J or I
nnoremap K <nop>
" formatting options:
" help fo-table
" c: do the same for comments, but
" r: autoinsert comment character too
" o: ditto, but for o/O in normal node
" q: allow 'gq' to autowrap/format comments as well as normal text
" 1: Don't break a line before a one-character word
" n: recognize numbered lists
set formatoptions+=croq1n
set wrap
set linebreak
set textwidth=79
set formatprg="par -qe"
let mapleader = ','
" --- Gui Window Tabs ---------------------------------------------------------
" tab movement, cmd-shift-(move)
nnoremap <D-S-right> :tabnext<CR>
nnoremap <D-S-l> :tabnext<CR>
nnoremap <D-S-left> :tabprevious<CR>
nnoremap <D-S-h> :tabprevious<CR>
" --- Vim Windows -------------------------------------------------------------
set laststatus=2 " always show the status line
set splitbelow
set splitright
" Window and buffer movement
" cmd-opt-shift-(move) is similar to iterm
" Ctrl-(move) is easier in iterm
nnoremap <D-M-down> <C-w><Down> " window down
nnoremap <C-j> <C-w><Down>
nnoremap <D-M-up> <C-w><Up> " window up
nnoremap <C-k> <C-w><Up>
nnoremap <D-M-left> <C-w><Left> " window left
nnoremap <C-h> <C-w><Left>
nnoremap <D-M-right> <C-w><Right> " window right
nnoremap <C-l> <C-w><Right>
nnoremap <C-n> :bnext<CR> " buffer next
nnoremap <C-p> :bprev<CR> " buffer previous
" --- Insert Mode -------------------------------------------------------------
" option-backspace over words, emacs style
inoremap <M-Backspace> <C-[>ciw
inoremap <C-Backspace> <C-[>ciw
" disable the fucking help
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" --- Ex Mode -----------------------------------------------------------------
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
" option-backspace over words
cnoremap <M-Backspace> <S-Right> <C-W>
cnoremap <C-Backspace> <S-Right> <C-W>
cnoremap <M-Right> <S-Right>
cnoremap <M-Left> <S-Left>
" --- searching --------------------------------------------------------
set ignorecase
set smartcase
set wrapscan
set incsearch
set hlsearch
" remove the highlight
nnoremap <silent><Leader>, :noh<cr>
" make search use real regexes
nnoremap / /\v
vnoremap / /\v
set grepprg=ack\ -aH\ --nocolor
" --- spelling ----------------------------------------------------------------
if v:version >= 700
setlocal spell spelllang=en
nnoremap <silent><Leader>ss :set spell!<CR>
endif
" --- pasting -----------------------------------------------------------------
nnoremap <silent><Leader>sp :set paste!<CR>
nnoremap <silent><Leader>sl :set list!<CR>
" --- quickfix ----------------------------------------------------------------
autocmd QuickfixCmdPost grep copen
" --- folding -----------------------------------------------------------------
set foldmethod=indent
set foldlevelstart=99
autocmd BufNewFile,BufRead *.haml,*sass,*.scss set foldignore=
autocmd BufNewFile,BufRead * set foldmethod=indent
autocmd BufNewFile,BufRead *.diff set foldmethod=diff
" --- navigation --------------------------------------------------------------
" make the tab key match bracket pairs
nnoremap <tab> %
vnoremap <tab> %
" rails vim shortcut
autocmd User Rails Rnavcommand config config -glob=*.* -suffix= -default=routes.rb
" toggle between relative line numbers
nnoremap <Leader>n :if &nu <bar> set nonu rnu <bar> else <bar> set nu nornu <bar> endif<CR>
" --- File Navigation ---------------------------------------------------------
let g:CommandTMatchWindowAtTop=1
silent! nnoremap <silent> <Leader>t :CommandT<CR>
nnoremap <Leader>T :CommandTFlush<CR>
nnoremap <Leader>e :e %:h/**/
cnoremap <Leader>e :e %:h/**/
let g:netrw_liststyle=4
" tags
set tags+=../tags,../../tags,../../../tags,../../../../tags,tmp/tags
map <silent> <Leader>r :!/usr/local/bin/ctags -f tags -R *<CR><CR>
" --- Text Manipulation
let g:ragtag_global_maps = 1
let g:surround_45 = "<% \r %>"
let g:surround_61 = "<%= \r %>"
" --- Git / Fugitive ----------------------------------------------------------
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <silent> <Leader>gd :w<CR>:Gdiff<CR><CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gw :Gw<CR>
" --- Visual Column Stuff -----------------------------------------------------
autocmd BufNewFile,BufRead * set nocursorcolumn
autocmd BufNewFile,BufRead *.coffee,*Cakefile set cursorcolumn
autocmd BufNewFile,BufRead *.haml,*.sass,*.scss set cursorcolumn
" --- Yankring ----------------------------------------------------------------
nnoremap <silent> <Leader>y :YRShow<CR>
" === Custom Shit =============================================================
" DiffOrig() will do a diff with of the buffer vs. its unsaved state.
" This is handy for seeing what you've changed and accepting/reverting
" changes before writing
nnoremap <Leader>d :call DiffOrig()<cr>
function! DiffOrig()
if &diff
wincmd p | bdel | diffoff
else
vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
endif
endfunction
" UPPER CASE -> lower case -> Title Case
" from http://vim.wikia.com/wiki/Switching_case_of_characters
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")<CR>Pgv
" change directory to that of current file
nmap <Leader>cd :cd%:p:h<cr>
" just sudo it
cmap w!! %!sudo tee > /dev/null %
let html_use_css=1
" --- gui stuff ---------------------------------------------------------------
if has("gui_running")
" a: visual-mode autoselect (takes over the OS selection process)
" A: autoselect for modeless selection
" c: use console dialogs for simple choices
" e: use the gui's tabs -- not using for now, prevent macvim from resizing
" window on tabs
" g: grey-out non-active menu items
" m: show system menu bars
" t: include tear-off menu items
set guioptions=aAcgmt
" T: system toolbar
" r: right-hand scrollbar
" l: left-hand scrollbar
" L: left-hand scrollbar when vertically-split window
set guioptions-=TrlL
set fuoptions=maxvert,maxhorz
else
" bar cursor in insert mode
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
" block cursor in normal mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" --- statusline --------------------------------------------------------------
function! GitStatus()
if exists('*fugitive#statusline')
let branchname = fugitive#statusline()
" let branchname = substitute(branchname, '[Git(]', '', '')
" let branchname = substitute(branchname, ')]$', '', '')
" let branchname = substitute(branchname, '^feature/', 'ƒ ', '')
" let branchname = substitute(branchname, '^bug/', 'β ', '')
" let branchname = substitute(branchname, '^hotfix/', 'λ ', '')
" let branchname = substitute(branchname, '^chore/', 'ς ', '')
" let maxlen = 30
" if strlen(branchname) > maxlen
" let branchname = strpart(branchname, 0, maxlen)
" let branchname .= "…"
" end
if strlen(branchname) > 0
" let git = ' ± ' . branchname . ' '
let git = ' ± '
else
let git = ''
end
else
let git = ''
endif
return git
endfunction
function! SyntaxStatus()
if exists('*SyntasticStatuslineFlag')
let toReturn = SyntasticStatuslineFlag()
let toReturn = substitute(toReturn, '[\[\]]', ' ', 'g')
if strlen(toReturn) > 0
return " ".toReturn
else
return ''
else
return ''
end
endfunction
let rails_statusline = 0
let stl = "%<"
let stl .= "%#DiffChange#"
let stl .= "%-.60f "
let stl .= "%#DiffAdd#"
let stl .= " %{&filetype} "
let stl .= "%*"
let stl .= "%-.35{GitStatus()}"
let stl .= "%="
let stl .= "%#ErrorMsg#"
let stl .= "%{&modified > 0 ? '-dirty-' : ''}"
let stl .= "%{&modified == 1 && &modifiable == 0 ? ' ' : ''}"
let stl .= "%{&modifiable == 0 ? 'readonly' : ''}"
let stl .= "%{SyntaxStatus()}"
let stl .= "%*"
let stl .= " %c:"
let stl .= "%l/%L %P"
set statusline=%!stl