-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.vimrc
393 lines (311 loc) · 10.2 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
" .vimrc
" An assortment of little vim tricks collected from numerous sources.
" Most functionality comes from these authors:
"
" -------------------------------------------------------------------------
" Author: janus Vim Distribution
" Source: https://github.com/carlhuda/janus
" -------------------------------------------------------------------------
" -------------------------------------------------------------------------
" Author: Frew
" Source: http://stackoverflow.com/questions/164847/what-is-in-your-vimrc
" -------------------------------------------------------------------------
" -------------------------------------------------------------------------
" Author: Steve Losh <steve@stevelosh.com>
" Source: http://bitbucket.org/sjl/dotfiles/src/tip/vim/
" -------------------------------------------------------------------------
" General settings
" ================
syntax on " syntax highlighting
filetype plugin indent on " activates indenting for files
set autoindent " auto indenting
set number " line numbers
set nocompatible
set ruler
set tabstop=2
set shiftwidth=2
set softtabstop=2
set list listchars=tab:\ \ ,trail:·
set expandtab
set backupdir=/Volumes/Data/Backup/.vim_backup
set dir=/Volumes/Data/Backup/.vim_backup
set swapfile
"set transparency=10
colorscheme desert
"colorscheme flatland
"colorscheme Tomorrow-Night-Eighties
"colorscheme mirodark
"colorscheme ir_black
"colorscheme solarized
" Set encoding
set encoding=utf-8
set enc=utf-8
" Start in fullscreen mode
"set fullscreen
" Status bar
set laststatus=2
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Use modeline overrides
set modeline
set modelines=10
" This shows what you are typing as a command.
set showcmd
set cursorline
set ttyfast
set history=1000
set undofile
set undodir=~/vim_backup
set undoreload=10000
set splitbelow
set splitright
set autoread
set dictionary=/usr/share/dict/words
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
" Packages
" ========
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle. Required!
Bundle 'gmarik/Vundle.vim'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'wincent/Command-T'
Bundle 'godlygeek/tabular'
" All of your Plugins must be above this line
call vundle#end()
" Movement
" ========
set scrolloff=6
set sidescroll=1
set sidescrolloff=10
" MacVIM Settings
" ===============
" Switch between open split windows in MacVim
" http://superuser.com/questions/387207/how-do-i-map-cmd-shift-f-to-run-ack-plugin-in-vim
nmap <D-J> <C-w>w
nmap <D-K> <C-w>w
" Show toolbar in MacVIM
if has("gui_running")
:hi TabLine guibg=#303030
:hi TabLineFill guifg=#303030
set guifont=CosmicSansNeueMono:h16
"set guifont=Source\ Code\ Pro:h17
"set guifont=Menlo:h15
"set guifont=Consolas:h16
"set guifont=Inconsolata-dz\ for\ Powerline:h15
"set guifont=Inconsolata:h14
" Remove all the UI cruft
set go-=T
set go-=l
set go-=L
set go-=r
set go-=R
set go+=m " Show menubar
set go+=g " Grey menu itmems
set go-=r " Right hand scrollbar not always present
highlight SpellBad term=underline gui=undercurl guisp=Orange
" Different cursors for different modes.
"set guicursor=n-c:block-Cursor-blinkon0
set guicursor+=v:block-vCursor-blinkon0
"set guicursor+=i-ci:ver20-iCursor
if has("gui_macvim")
" Full screen means FULL screen
set nofullscreen
set fuoptions=maxvert,maxhorz
" ...but we don't need that by default
else
" Non-MacVim GUI, like Gvim
end
else
" Console Vim
endif
" German Keyboard options
" ========================
" Change default modifier key (German keyboard)
let mapleader=","
" Jump to above/below paragraph with t/T
" This is useful for German Keyboards, since
" the curly brackets are hidden behind some meta-key
noremap Ö {
noremap ö }
" Folding options
" ================
set foldtext=MyFoldText()
function! MyFoldText()
" do whatever processing you want here
" the function will be called for each folded line visible on screen
" the line number of each fold's "head" line will be in v:foldstart
" last line of fold in v:foldend
" can do whatever processing you want, then return text you want
" displayed:
let line = getline(v:foldstart)
" Remove comment characters and gibberish
let line = substitute(line, "{,\\=[^,]*$", "", "g")
let foldedlinecount = v:foldend - v:foldstart
return '+-'.line.'['.foldedlinecount.']'
endfunction
" au BufWinLeave *.* mkview " Remember manual foldings
" au BufWinEnter *.* silent loadview " Load foldings on startup
"set foldminlines=5 " Minimum lines to create fold
set foldlevelstart=0
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
" Other Mappings
" ==============
" EasyMotion
"let g:EasyMotion_leader_key = '<Leader>'
nnoremap f <leader><leader>w
"nnoremap t <Leader>w
"vnoremap t <Leader>w
" Mac specific: Text-to-speech on selected text in visual mode
" w: Don't replace selection with command output after execution
" silent: Don't prompt for enter after execution
vnoremap <leader>v :w<Home>silent <End> !say <CR>
" Remap T to play a macro
nnoremap T @
" Don't switch to insert mode after inserting a new line
nnoremap * maO<esc>`a
nnoremap + mao<esc>`a
" Move through wrapped lines as expected
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
map N Nzz
map n nzz
" Searching
" ==========
set hlsearch
set incsearch
set ignorecase
set smartcase
" Clear search highlights
noremap <silent><Leader>/ :nohls<CR>
" Tricks
" =======
"Reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Fix common typos
:command WQ wq
:command Wq wq
:command W w
:command Q q
" Set off the other paren
highlight MatchParen ctermbg=4
" Keep search matches in the middle of the window and pulse the line when moving
" to them.
nnoremap n nzzzv:call PulseCursorLine()<cr>
nnoremap N Nzzzv:call PulseCursorLine()<cr>
" Coding options
" ==============
" This enables automatic indentation as you type.
filetype indent on
" Auto Commands
" Automatically cd into the directory that the file is in
" autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
set autochdir
" Remove any trailing whitespace that is in the file
" autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
" Functions
" ==========
function! PulseCursorLine()
let current_window = winnr()
windo set nocursorline
execute current_window . 'wincmd w'
setlocal cursorline
redir => old_hi
silent execute 'hi CursorLine'
redir END
let old_hi = split(old_hi, '\n')[0]
let old_hi = substitute(old_hi, 'xxx', '', '')
hi CursorLine guibg=#2a2a2a ctermbg=233
redraw
sleep 20m
hi CursorLine guibg=#333333 ctermbg=235
redraw
sleep 20m
hi CursorLine guibg=#3a3a3a ctermbg=237
redraw
sleep 20m
hi CursorLine guibg=#444444 ctermbg=239
redraw
sleep 20m
hi CursorLine guibg=#3a3a3a ctermbg=237
redraw
sleep 20m
hi CursorLine guibg=#333333 ctermbg=235
redraw
sleep 20m
hi CursorLine guibg=#2a2a2a ctermbg=233
redraw
sleep 20m
execute 'hi ' . old_hi
windo set cursorline
execute current_window . 'wincmd w'
endfunction
" Status line
" ============
augroup ft_statuslinecolor
au!
au InsertEnter * hi StatusLine ctermfg=196 guifg=#FF3145
au InsertLeave * hi StatusLine ctermfg=130 guifg=#CD5907
augroup END
set statusline=%f " Path.
set statusline+=%m " Modified flag.
set statusline+=%r " Readonly flag.
set statusline+=%w " Preview window flag.
set statusline+=\ " Space.
set statusline+=%#redbar# " Highlight the following as a warning.
"set statusline+=%{SyntasticStatuslineFlag()} " Syntastic errors.
set statusline+=%* " Reset highlighting.
set statusline+=%= " Right align.
" File format, encoding and type. Ex: "(unix/utf-8/python)"
set statusline+=(
set statusline+=%{&ff} " Format (unix/DOS).
set statusline+=/
set statusline+=%{strlen(&fenc)?&fenc:&enc} " Encoding (utf-8).
set statusline+=/
set statusline+=%{&ft} " Type (python).
set statusline+=)
" Line and column position and counts.
set statusline+=\ (line\ %l\/%L,\ col\ %03c)