-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
392 lines (388 loc) · 13.6 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
" ------------------------------------------------------------------------
"
" Author: G. Tillman
"
" ------------------------------------------------------------------------
"
" Enable pathogen before doing anything else.
" See http://www.vim.org/scripts/script.php?script_id=2332
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" copy indent from current line when starting new line
set autoindent
" intuitive backspacing in insert mode
set backspace=indent,eol,start
"
" ------------------------------------------------------------------------
" BUBBLING TEXT - bubbling text mappings using the unimpaired plugin
" Bubble single lines
nmap <M-Up> [e
nmap <M-Down> ]e
" Bubble multiple lines
vmap <M-Up> [egv
vmap <M-Down> ]egv
" ------------------------------------------------------------------------
"
" let all copy and paste operations use X11 selection buffer
" set clipboard+=unnamed
"
" ------------------------------------------------------------------------
"
" COFFEESCRIPT
"
" CoffeeCompile
noremap <leader>cc :CoffeeCompile<CR>
" CoffeeMake
noremap <leader>cm :CoffeeMake<CR>
" CoffeeRun
noremap <leader>cr :CoffeeRun<CR>
" Automatically build the coffee source file when you save
" 2011-09-06 (got) - disabled this for now
" autocmd BufWritePost *.coffee silent CoffeeMake!
"
" ------------------------------------------------------------------------
"
" COLOR SCHEME - set default colorscheme
if !has('gui_running')
"let g:solarized_termcolors=256
"colorscheme solarized
"colorscheme desert
colorscheme lucius
set background=dark
endif
"
" ------------------------------------------------------------------------
" COMMENTS
" comment abbreviations
ia #b /******************************************************************************
ia #e ****************************************************************************/
set commentstring=\ #\ %s
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" DIFF WHITESPACE TOGGLE
" ------------------------------------------------------------------------
"
map <leader><leader>w :call ToggleWhitespaceDiff()<cr>
function ToggleWhitespaceDiff()
if exists("g:whitespace_diff")
unlet g:whitespace_diff
set diffopt=filler
echo "whitespace matters"
else
let g:whitespace_diff = 1
set diffopt=filler,iwhite
echo "ignoring whitespace"
endif
endfunction
"
" ------------------------------------------------------------------------
" ERLANG
"
" Overwrite the default location to search for the Erlang man pages
"
if hostname() =~ "gordy29"
let erlang_man_path = "/usr/local/Cellar/erlang/HEAD/share/man"
endif
"
" ------------------------------------------------------------------------
" insert spaces when you hit tab key. NOTE: to insert a real tab when
" expandtab is set, just your CTRL-V<Tab>
set expandtab
"
" ------------------------------------------------------------------------
" FOLDING
"
" Once you set a foldmethod the following will let the space
" bar fold and unfold a section of code
" :set foldmethod=indent
nnoremap <space> za
" when opening a file have all folds initially closed
set foldlevel=0
" enable indent folding for python files
autocmd FileType python set foldmethod=indent
" enable indent folding for javascript files.
" see http://www.vim.org/scripts/script.php?script_id=1491
" for improved javascript syntax file
autocmd FileType javascript set foldmethod=syntax
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" FUNCTION - Open the URL on the current line in a browser
function! Browser ()
let line = getline (".")
let line = matchstr (line, "\%(http://\|www\.\)[^ ,;\t]*")
echo line
endfunction
map <Leader>w :call Browser ()<CR>
" ------------------------------------------------------------------------
"
" GREP - program to use for the :grep command
set grepprg=grep\ -nH\ $*
"
" HIDDEN - let you switch from a buffer that contains unsaved changes
" to another buffer without complaining.
set hidden
"
" ------------------------------------------------------------------------
" Gundo - provides a visual representation of your Vim undo graph
"
nnoremap <F5> :GundoToggle<CR>
"
" ------------------------------------------------------------------------
" HIGHLIGHTING - highlight search terms dynamically as they are typed
let g:highlight_search_enabled = 1
set hlsearch
set incsearch
" toggle hlsearch on and off
function! HighlightSearchToggle ()
if exists("g:highlight_search_enabled")
set nohlsearch
unlet g:highlight_search_enabled
else
let g:highlight_search_enabled = 1
set hlsearch
endif
endfunction
map <Leader><Leader>h :call HighlightSearchToggle()<CR>
" ------------------------------------------------------------------------
"
" use both ignorecase AND smartcase case in searches
set ignorecase
set smartcase
"
" Give Vim a larger history buffer (default = 20)
"
set history=10000
"
" ------------------------------------------------------------------------
" Javascript Settings
"
" Hilite characters if line length in a Javascript file exceeds 79
autocmd BufEnter *.js :call HighlightLongLines ()
" Replace all occurrances of == with ===
noremap <leader>dbe :s/\([^!]\)==/\1===/g<CR>
" Replace all occurrances of != with !==
noremap <leader>ndbe :s/!=/!==/g<CR>
" Run jsbeautify on visual selection
vnoremap <leader>jsb !jsbeautify<CR>
" Run jsbeautify on visual selection and indent one level
vnoremap <leader>jsbi !jsbeautify<CR>:'[,']><CR>
" Increase indent of last visual selection
noremap <leader>vsi :'[,']><CR>
"
" ------------------------------------------------------------------------
"
" LATEX - Vim-LaTeX: http://vim-latex.sourceforge.net/
let g:tex_flavor='latex'
" wrap long lines at a blank
set linebreak
noremap <SID>_disable_IMAP_JumpForward_ <Plug>IMAP_JumpForward
"
" ------------------------------------------------------------------------
"
" LINE NUMBERING (RELATIVE) - add ability to toggle relative line
" numbering on and off
"
"
function! ToggleRelativeNumbering ()
if exists("g:toggle_relative_numbering")
unlet g:toggle_relative_numbering
set norelativenumber
else
let g:toggle_relative_numbering = 1
set relativenumber
endif
endfunction
map <Leader>rn :call ToggleRelativeNumbering ()<CR>
"
" ------------------------------------------------------------------------
"
" LONG LINE HIGHLIGHTING - adds ability to turn on and off highting
" of lines that are longer that 79 characters in length. The mapping
" will toggle on and off
"
function! HighlightLongLines ()
if exists("g:highlight_long")
match
unlet g:highlight_long
else
let g:highlight_long = 1
match ErrorMsg /\%>79v.\+/
endif
endfunction
map <Leader>h :call HighlightLongLines ()<CR>
"
" ------------------------------------------------------------------------
" make tabs and trailing spaces visible when requested (next 2 lines)
set listchars=tab:>-,trail:.,eol:$
nmap <silent> <leader>s :set nolist!<CR>
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" Markdown Settings
"
" Tell Vim to treat files ending in .md as Markdown
autocmd BufEnter *.md set filetype=markdown
if has('mac')
" This is a little bash wrapper in /usr/local/bin on gordy29
let g:PreviewBrowsers='browser'
" Preview file with Marked application (mac os x)
:nnoremap <leader>m :silent !open -a Marked.app '%:p'<cr>
else
let g:PreviewBrowsers='chromium-browser,firefox'
endif
"
" ------------------------------------------------------------------------
" netrw
"
" NOTE: To simulate what NERDTree does
"
" Edit current directory
" With cursor over file, press v
" Resize windows if necessary
" To edit a new file in right pane, with cursor over file, press P
" ------------------------------------------------------------------------
"
let g:netrw_altv = 1
let g:netrw_winsize = 80
"
" ------------------------------------------------------------------------
" OMNICOMPLETION
"
" enable omni completion for python files.
autocmd FileType python set omnifunc=pythoncomplete#Complete
" Note: to generate the python.tags file you must have exuberant-ctags
" installed. Then issue this command:
"
" ctags -R --exclude='*.js' -f ~/.vim/tags/python.ctags \
" /System/Library/Frameworks/Python.framework/Versions/2.6/lib \
" /Library/Python/2.6
"
let taglist = split(&tags, ",")
let tagfiles = split(glob("`find $HOME/.vim/tags -name '*.ctags' -print`"), "\n")
let &tags = join(tagfiles + taglist, ",")
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" PYTHON settings
" Hilite characters if line length in a python file exceeds 79
autocmd BufEnter *.py :call HighlightLongLines ()
" Hilite all tab characters in a Python file. Note that since I had
" already defined one "match" for *.py, I had to use "2match" command
" to add the second match pattern.
autocmd BufEnter *.py 2match ErrorMsg /[\t]/
" Automatically remove all trailing whitespace when you save a python file
autocmd BufWritePre *.py :%s/\s\+$//e
" With the following you can put your cursor over the
" name of any module you are importing and type gf and it will open the file
" that contains that module.
" NOTE: This requires fairly current vim. On the mac you need MacVim
" (mvim)
if has("python")
python << EOF
import os, sys, vim
for p in sys.path:
if p != '' and os.path.isdir(p):
vim.command(r'set path+=%s' % (p.replace(' ', r'\ ')))
EOF
"
" vim-flake8 notes:
"
" 1. <F7> is the default key to invoke it.
" 2. You can configure flake8 to ignore certain errors. Here is an example:
"
" let g:flake8_ignore="E501,W293"
"
" 3. You can confiugre flake8 to be automatically invoked every time you
" save a Pyhton buffer as follows:
"
" autocmd BufWritePost *.py call Flake8()
"
let g:flake8_ignore="E501"
endif
"
" ------------------------------------------------------------------------
" RULER
" show line and column number of cursor
set ruler
" Make a more informative status line
" name, format, filetype, ascii and hex value of character under cursor,
" position in document as row and column number and percent, linecount
set statusline=[FMT=%{&ff}]\ [TYP=%Y]\ [ASC=\%03.3b]\ [HEX=\%02\.2B]\ [POS=%04l,%04v]\ [%p%%]\ [LEN=%L]\ [%<%f]
set laststatus=2
" ------------------------------------------------------------------------
"
" number of spaces for each step of (auto)indent
set shiftwidth=4
" number of spaces that <Tab> counts for when performing editing operations
set softtabstop=4
" Turn on spell checking
" setlocal spell spelllang=en_us
"
" ------------------------------------------------------------------------
" SESSIONS - When using the :mksession command, have it save
" pretty much everything about what you are doing
set sessionoptions=blank,buffers,curdir,folds,globals,help,localoptions,options,resize,tabpages,winpos,winsize
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" SYNTAX HIGHLIGHTING
" file-type highlighting and configuration.
syntax on
filetype on
filetype plugin on
filetype indent on
" ------------------------------------------------------------------------
"
" number of spaces a <Tab> accounts for - spec calls for 8
set tabstop=8
"
" ------------------------------------------------------------------------
" TETRIS
" load tetris game if it is available - \te to start
if filereadable(expand("~/.vim/scripts/tetris.vim"))
so ~/.vim/scripts/tetris.vim
endif
" ------------------------------------------------------------------------
"
" maximum width of text that is inserted. when 0, wrapmargin may be used.
set textwidth=0
" TWITVIM TwitVim login information
let twitvim_login = "gordyt:xyzzy1"
"
" ------------------------------------------------------------------------
" enable tab command completion
set wildmenu
" have completion only up to the point of ambiguity, while still
" showing other options
set wildmode=list:longest
" ------------------------------------------------------------------------
"
" UUID generation
imap <Leader>u <C-R>=system('uuidgen <Bar> tr -d "\n-"')<CR>
"
" ------------------------------------------------------------------------
" WINDOW RESIZING and Navigation - Easy window resizing mappings
"
map + + " taller
map _ - " shorter
map = > " wider
map - < " skinnier
"
set winminheight=0 " Allow windows to get fully squashed
" Switch between windows, maximizing the current window
noremap <C-J> <C-W>j<C-W>_
noremap <C-K> <C-W>k<C-W>_
" ------------------------------------------------------------------------
"
" ------------------------------------------------------------------------
" WRAPPING - uncomment next line to turn on wrapping
" set wrap
" turn off wrapping for javascript files
autocmd FileType javascript set nowrap
" turn off wrapping for python files
autocmd FileType python set nowrap
" YAML - turn off wrapping for yaml files
autocmd FileType yaml set nowrap
" ------------------------------------------------------------------------