-
Notifications
You must be signed in to change notification settings - Fork 15
/
vimrc
212 lines (176 loc) · 5.32 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
call pathogen#infect()
call pathogen#helptags()
if has("mouse")
set mouse=a
set mousehide
endif
if has("gui_running")
set lines=50 columns=100
if has("gui_win32")
" gvim/win32 fails to do this automatically
source $VIMRUNTIME/mswin.vim
set guifont=Consolas:h10
elseif has("mac")
set guifont=Inconsolata:h14
else
set guifont=Inconsolata\ Medium\ 12
endif
endif
set background=dark
set guioptions-=T " Hide toolbar
if has("win32")
cd $USERPROFILE " Default cwd is System32, which is stupid
endif
" Search options
set hlsearch " Highlight search results
set smartcase " Search strings that are all-lowercase will do a case-insensitive search
set incsearch " Incremental search
nnoremap <silent> <CR> :noh<CR><CR> " Clear search highlight by hitting enter
set number " Show line numbers
set foldcolumn=2
set foldmethod=syntax
set shiftwidth=4
set tabstop=4
set hlsearch " Highlight search results
set smartcase " Search strings that are all-lowercase will do a case-insensitive search
set incsearch " Incremental search
set cursorline " Highlight current line
set autoread " Reload files that have changed
set guioptions-=T " Hide toolbar
set backspace=indent,eol,start " make backspace work like everything else
syntax enable
filetype plugin indent on
colorscheme solarized
set laststatus=2
set statusline=[%l,%v\ %P%M]\ %f\ %y%r%w[%{&ff}]%{fugitive#statusline()}\ %b\ 0x%B
"set t_Co=256
"call togglebg#map("<F5>")
" Save Taskpaper files automatically and use light background
autocmd BufLeave,FocusLost *.taskpaper w
autocmd Filetype taskpaper set background=light
" Source the vimrc file after saving it
autocmd BufWritePost .vimrc source $MYVIMRC
" Run wrapwithtag.vim script when opening html docs (shouldn't this be a
" filetype plugin? meh.)
autocmd Filetype html,xml,aspvbs runtime scripts/wrapwithtag.vim
" Use aspvbs filetype for .asa and .asp files so we get syntax highlighting
let g:filetype_asa = "aspvbs"
let g:filetype_asp = "aspvbs"
" Use Groovy syntax highlighting for gradle buildfiles
au BufNewFile,BufRead *.gradle setf groovy
" Set up NERDTree keybinds and options
map <F3> :NERDTreeFind<CR>
map <F4> :NERDTreeMirrorToggle<CR>
let NERDTreeChDirMode=2 " pwd follows NERDtree
let NERDTreeHijackNetrw=0 " So vcscommand can commit directories
let NERDTreeIgnore=['^CVS$', '^\.svn$', '\~$']
let g:nerdtree_tabs_open_on_gui_startup=0
" Set up taglist keybinds
map <F5> :TlistToggle<CR>
let Tlist_Use_Right_Window=1
if has("gui_macvim") && has("gui_running")
" Map command-[ and command-] to indenting or outdenting
" while keeping the original selection in visual mode
vmap <D-]> >gv
vmap <D-[> <gv
nmap <D-]> >>
nmap <D-[> <<
omap <D-]> >>
omap <D-[> <<
imap <D-]> <Esc>>>i
imap <D-[> <Esc><<i
" Bubble single lines
nmap <D-Up> [e==
nmap <D-Down> ]e==
nmap <D-k> [e==
nmap <D-j> ]e==
imap <D-k> <Esc>[e==gi
imap <D-j> <Esc>]e==gi
" Bubble multiple lines
vmap <D-Up> [e==gv
vmap <D-Down> ]e==gv
vmap <D-k> [e==gv
vmap <D-j> ]e==gv
else
" Map command-[ and command-] to indenting or outdenting
" while keeping the original selection in visual mode
vmap <A-]> >gv
vmap <A-[> <gv
nmap <A-]> >>
nmap <A-[> <<
omap <A-]> >>
omap <A-[> <<
imap <A-]> <Esc>>>i
imap <A-[> <Esc><<i
" Bubble single lines
nmap <A-Up> [e==
nmap <A-Down> ]e==
nmap <A-k> [e==
nmap <A-j> ]e==
imap <A-k> <Esc>[e==gi
imap <A-j> <Esc>]e==gi
" Bubble multiple lines
vmap <A-Up> [e==gv
vmap <A-Down> ]e==gv
vmap <A-k> [e==gv
vmap <A-j> ]e==gv
endif
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
" jj/kk exits insert mode
inoremap jj <Esc>
inoremap kk <Esc>
" for typos
map :E :e
" <F9> toggles fold under cursor
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
vnoremap <F9> zf
" <F10> decreases fold level by one
inoremap <F10> <C-O>zm
nnoremap <F10> zm
onoremap <F10> <C-C>zm
vnoremap <F10> zm
" <F11> opens all folds in the file
inoremap <F11> <C-O>zR
nnoremap <F11> zR
onoremap <F11> <C-C>zR
vnoremap <F11> zR
" Open all folds by default
autocmd Syntax * normal zR
" If there is a fold under the cursor, spacebar toggles it as well
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
" \c changes to directory of current file
nnoremap <Leader>c :cd %:p:h<CR>
" Indent guides plugin config
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
" Override the indent guide plugin's color choices based on whether we're
" using a light or dark background.
function! RecolorIndentGuides()
if &background == "dark"
" base02
:hi IndentGuidesEven guibg=#073642 ctermbg=0
:hi SignColumn guibg=#073642 ctermbg=0
:hi IndentGuidesOdd guibg=NONE ctermbg=0
else
" base2
:hi IndentGuidesEven guibg=#eee8d5 ctermbg=7
:hi SignColumn guibg=#eee8d5 ctermbg=7
:hi IndentGuidesOdd guibg=#eee8d5 ctermbg=7
endif
endfunction
autocmd VimEnter,Colorscheme * :call RecolorIndentGuides()
" ctrlp plugin config
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules\|\.git$\|\.hg$\|\.svn$\|^CVS$'
\ }
" Filetype-specific indentation
autocmd Filetype coffee setlocal tabstop=2 shiftwidth=2 expandtab
autocmd Filetype ruby setlocal tabstop=2 shiftwidth=2 expandtab
autocmd Filetype yaml setlocal tabstop=2 shiftwidth=2 expandtab