-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
371 lines (293 loc) · 11.3 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
"
" tmellor's vimrc
" @email timothy.mellor@gmail.com
"
" -----------------------------------------------------------------------------
" Mandatory stuff for vundle
" -----------------------------------------------------------------------------
set nocompatible " be iMproved
filetype off " required!
filetype plugin indent on " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" mandatory for some plugins
set t_Co=256
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" -----------------------------------------------------------------------------
" Plugin Bundles
" -----------------------------------------------------------------------------
""" Language Agnostic """
" Library
Bundle 'vim-scripts/L9'
" UI improvements
Bundle 'wycats/nerdtree'
Bundle 'majutsushi/tagbar'
Bundle 'dickeytk/status.vim'
" Utilities
Bundle 'mileszs/ack.vim'
Bundle 'tsaleh/vim-align'
" Bundle 'wincent/Command-T'
Bundle 'vim-scripts/FuzzyFinder'
Bundle 'kien/ctrlp.vim'
" don't use this
" Bundle 'Lokaltog/vim-easymotion'
" Manipulation
Bundle 'michaeljsmith/vim-indent-object'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-repeat'
Bundle 'scrooloose/nerdcommenter'
" Code completion
Bundle 'Raimondi/delimitMate'
Bundle 'docunext/closetag.vim'
Bundle 'vim-scripts/UltiSnips'
Bundle 'mattn/zencoding-vim'
" Source Control
Bundle 'tpope/vim-fugitive'
Bundle 'sjl/gundo.vim'
Bundle 'gregsexton/gitv'
" Window/buffer/tab manipulation
Bundle 'vim-scripts/ZoomWin'
" LJ seems cool, but never use it
" Bundle 'mutewinter/LustyJuggler'
" also use 'mpage' but it doesnt have a repo,
" included manually
set rtp+=~/.vim/bundle/mpage/*
" Colors
Bundle 'altercation/vim-colors-solarized'
Bundle 'scottymoon/vim-twilight'
Bundle 'nanotech/jellybeans.vim'
Bundle 'godlygeek/csapprox'
Bundle 'mattsa/vim-eddie'
Bundle 'tomasr/molokai'
Bundle 'therubymug/vim-pyte'
Bundle 'vim-scripts/vydark'
Bundle 'Cleanroom'
Bundle 'vexxor/zenburn.vim'
" Syntax
Bundle 'scrooloose/syntastic'
""" Language Specific """
" Python
" Bundle 'kevinw/pyflakes-vim'
" Bundle 'fs111/pydoc.vim'
Bundle 'klen/python-mode'
" Bundle 'nvie/vim-pep8'
" Java
" see http://www.vim.org/scripts/script.php?script_id=1785
Bundle 'javacomplete'
" Css
"" these are really cool, but they slow down vim ALOT
" Bundle 'skammer/vim-css-color'
" Bundle 'vim-scripts/Better-CSS-Syntax-for-Vim'
" Velocity
Bundle 'velocity.vim'
" Lisp
" Bundle 'vim-scripts/slimv.vim'
" -----------------------------------------------------------------------------
" Plugin Setup / Shortcuts / Maps
" -----------------------------------------------------------------------------
" python-mode
" required
let g:pymode_syntax = 1
" Easy access to Align
nnoremap <Leader>= :Align
vnoremap <Leader>= :Align
" Shortcut to ZoomWin
nnoremap <Leader>z :ZoomWin<CR>
" Run Ack fast
nnoremap <Leader>a :Ack<Space>
nnoremap <Leader>la :LAck<Space>
" toggle tagbar
nnoremap <Leader>tg :TagbarToggle<CR>
" generate ctags
nnoremap <Leader>ct :silent! ctags -R --extra=+f
" fuzzy funder
nnoremap <Leader>ff :FufFileWithCurrentBufferDir<CR>
nnoremap <Leader>fb :FufBuffer<CR>
nnoremap <Leader>ft :FufTaggedFile<CR>
" ctrl p
nnoremap <Leader>pb :CtrlPBuffer<CR>
nnoremap <Leader>b :CtrlPBuffer<CR>
" status line
" always show status bar
set laststatus=2
" ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" nerd tree toggle
nnoremap <Leader>nt :NERDTreeToggle<CR>
nnoremap <Leader>nf :NERDTreeFind<CR>
" -----------------------------------------------------------------------------
" General setup
" -----------------------------------------------------------------------------
""" Color setup """
set background=dark
colorscheme jellybeans
""" Editing behavior """
set showmode " always show what mode we're currently editing in
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set scrolloff=4 " keep 4 lines off the edges of the screen when scrolling
set virtualedit=all " allow the cursor to go in to "invalid" places
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set gdefault " search/replace "globally" (on a line) by default
set nolist " don't show invisible characters by default,
set mouse=a " enable using the mouse if terminal emulator
" supports it (xterm does)
set fileformats= " unix,dos,mac
set termencoding=utf-8
set encoding=utf-8
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set undofile " keep a persistent backup file
set undodir=~/.vim/.undo,~/tmp,/tmp
set nobackup " the backup feature is annoying, use source control
" but if you must...
set directory=~/.vim/.swap,~/tmp,/tmp " store swap files in one of these directories
set backupdir=~/.vim/.backup,~/tmp,/tmp " store swap files in one of these directories
set wildmenu " make tab completion for files/buffers act like bash
set wildmode=list:full " show a list when pressing tab and complete
" first full match
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set novisualbell " don't blink
set noerrorbells " don't beep
set showcmd " show (partial) command in the last line of the screen
" this also shows visual selection info
set nomodeline " disable mode lines (security measure)
set cursorline " underline the current line, for quick orientation
set cursorcolumn
""" Search and Movement """
" Make vim use regular regexps (very magic)
" @see http://stevelosh.com/blog/2010/09/coming-home-to-vim
" @see :help \v
nnoremap / /\v
vnoremap / /\v
" Swap implementations of ` and ' jump to markers
" By default, ' jumps to the marked line, ` jumps to the marked line and
" column, so swap them
nnoremap ' `
nnoremap ` '
" Quickfix window with last search
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
""" Utility """
" restore position in file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" save when focus lost
au FocusLost * :wa
" Auto resize windows when vim resized
autocmd VimResized * wincmd =
" Make D and Y behave
nnoremap D d$
nnoremap Y y$
""" Gvim specific """
if has('gui_running')
" Not sure which of these are totally necessary
" but I want to get rid of as much as possible.
set guioptions-=m
set guioptions-=M
set guioptions-=T
set guioptions-=r
set guioptions-=l
set guioptions-=L
set guioptions-=b
set guioptions-=F
endif
" -----------------------------------------------------------------------------
" General Shortcuts and mappings
" -----------------------------------------------------------------------------
" reload vimrc
nnoremap <Leader>sv :source $MYVIMRC<CR>
" close other buffers
nnoremap <Leader>o :on<CR>
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
nnoremap <Leader>v <C-w>v<C-w>l
" use semicolon for commands
" http://vim.wikia.com/wiki/Map_semicolon_to_colon
map ; :
" Easier movement up and down
nnoremap H <C-D>
nnoremap L <C-U>
" Turn off highlight with space and clear messages
" @see http://vim.wikia.com/wiki/Highlight_all_search_pattern_matches
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Quit fast
nnoremap <Leader>q :q<CR>
nnoremap <Leader>w :wq<CR>
" Delete buffer
nnoremap <Leader>d :bd<CR>
" %% expands to dir of current file
cnoremap %% %:p:h
" close the quickfix window
nnoremap <Leader>cl :cclose<CR>
" location list stuff
nnoremap <Leader>ll :ll<CR>
nnoremap <Leader>j :lne<CR>
nnoremap <Leader>k :lpre<CR>
" navigate tabs
nnoremap <Leader>tn :tabnext<CR>
nnoremap <Leader>tp :tabpre<CR>
nnoremap <Leader>tc :tabnew<CR>
nnoremap <Leader>td :tabclose<CR>
" -----------------------------------------------------------------------------
" Auto/omni complete settings
" -----------------------------------------------------------------------------
" javacomplete
" Could also use CompleteParamsInfo
autocmd Filetype java setlocal omnifunc=javacomplete#Complete
" -----------------------------------------------------------------------------
" Language specific settings
" -----------------------------------------------------------------------------
" 2 spaces for tab in vim script
autocmd FileType vim setlocal shiftwidth=2 tabstop=2 softtabstop=2
" 2 spaces for tab in html
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Set velocity syntax (redundant but necessary)
autocmd BufRead,BufNewFile *.vm setfiletype velocity
" -----------------------------------------------------------------------------
" Custom magic goes here
" -----------------------------------------------------------------------------
" Stuff below is to center the current buffer in the screen
" This is good for going full screen and editing just one file
" at a time.
let g:centerinscreen_active = 0
function! ToggleCenterInScreen(desired_width)
if g:centerinscreen_active == 0
let a:window_width = winwidth(winnr())
let a:sidepanel_width = (a:window_width - a:desired_width) / 2
exec("silent leftabove " . a:sidepanel_width . "vsplit new")
wincmd l
exec("silent rightbelow " . a:sidepanel_width . "vsplit new")
wincmd h
let g:centerinscreen_active = 1
else
wincmd h
close
wincmd l
close
let g:centerinscreen_active = 0
endif
endfunction
nnoremap <Leader>r :exec ToggleCenterInScreen(100)<CR>
nnoremap <Leader>f :call system("xte 'key F11'")<CR>