forked from rocksolidwebdesign/home-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
615 lines (501 loc) · 18.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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
" Vim Config File
" standard settings to keep me sane
"
" Dependencies:
" par
" exuberant-ctags
" perl
" DejaVu Sans Mono
"
" Last Modified: 11/13/2010
" ****************************************************************
filetype indent plugin on
syntax enable
" Active Plugins {{{
let g:my_vim_plugins = []
let g:my_plugin_repos = []
call add(g:my_plugin_repos, {'name': 'jst', 'settings': { 'type' : 'git', 'url' : 'git://github.com/briancollins/vim-jst' }})
call add(g:my_plugin_repos, {'name': 'fugitive', 'settings': { 'type' : 'git', 'url' : '/home/vaughn/src/vim-fugitive' }})
" CORE
call add(g:my_vim_plugins, 'The_NERD_tree' ) " file tree
call add(g:my_vim_plugins, 'The_NERD_Commenter' ) " coment toggling
call add(g:my_vim_plugins, 'ctrlp' ) " fuzzy finder
call add(g:my_vim_plugins, 'ack' ) " a multi-file search utility
call add(g:my_vim_plugins, 'EasyMotion' ) " an enhanced f command
call add(g:my_vim_plugins, 'UltiSnips' ) " a snippets plugin
" NICETIES
call add(g:my_vim_plugins, 'matchit.zip' ) " better % matching
call add(g:my_vim_plugins, 'YankRing' ) " copy paste history
call add(g:my_vim_plugins, 'bufkill' ) " close file but not window
call add(g:my_vim_plugins, 'fugitive' ) " the git plugin
call add(g:my_vim_plugins, 'surround' ) " wrap text easily
" LANGUAGES
call add(g:my_vim_plugins, 'VimClojure' ) " clojure
call add(g:my_vim_plugins, 'jst' ) " Underscore.js Templates
call add(g:my_vim_plugins, 'haml.zip' ) " HAML and SASS
call add(g:my_vim_plugins, 'vim-coffee-script' ) " Coffeescript
" COLORS
call add(g:my_vim_plugins, 'molokai' ) " dark and colorful
call add(g:my_vim_plugins, 'inkpot' ) " dark and blue-ish
call add(g:my_vim_plugins, 'Solarized' ) " the only light scheme I like
" }}}
" VAM {{{
function! EnsureVamIsOnDisk(vam_install_path)
" windows users may want to use http://mawercer.de/~marc/vam/index.php
" to fetch VAM, VAM-known-repositories and the listed plugins
" without having to install curl, 7-zip and git tools first
" -> BUG [4] (git-less installation)
let is_installed_c = "isdirectory(a:vam_install_path.'/vim-addon-manager/autoload')"
if eval(is_installed_c)
return 1
else
call mkdir(a:vam_install_path, 'p')
call system('git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '.shellescape(a:vam_install_path, 1).'/vim-addon-manager')
exec 'helptags '.fnameescape(a:vam_install_path.'/vim-addon-manager/doc')
return eval(is_installed_c)
endif
endfunction
function! MyExtraVamRepos()
let d = vam#install#Pool()
for repo in g:my_plugin_repos
let d[repo['name']] = repo['settings']
endfor
return d
endfunction
function! SetupVAM()
let g:vim_addon_manager = {'shell_commands_run_method': 'system', 'auto_install': 1, 'known_repos_activation_policy': 'always'}
let g:vim_addon_manager.pool_fun = function('MyExtraVamRepos')
" Set advanced options like this:
" let g:vim_addon_manager = {}
" let g:vim_addon_manager['key'] = value
" Example: drop git sources unless git is in PATH. Same plugins can
" be installed from www.vim.org. Lookup MergeSources to get more control
" let g:vim_addon_manager['drop_git_sources'] = !executable('git')
" let g:vim_addon_manager.debug_activation = 1
" VAM install location:
let vam_install_path = expand('$HOME') . '/.vim/vim-addons'
if !EnsureVamIsOnDisk(vam_install_path)
echohl ErrorMsg
echomsg "No VAM found!"
echohl NONE
return
endif
exec 'set runtimepath+='.vam_install_path.'/vim-addon-manager'
" Tell VAM which plugins to fetch & load:
call vam#ActivateAddons(g:my_vim_plugins)
" this is just here so I can easily do completion
" call vam#ActivateAddons([''])
" sample: call vam#ActivateAddons(['pluginA','pluginB', ...], {'auto_install' : 0})
" Addons are put into vam_install_path/plugin-name directory
" unless those directories exist. Then they are activated.
" Activating means adding addon dirs to rtp and do some additional
" magic
" How to find addon names?
" - look up source from pool
" - (<c-x><c-p> complete plugin names):
" You can use name rewritings to point to sources:
" ..ActivateAddons(["github:foo", .. => github://foo/vim-addon-foo
" ..ActivateAddons(["github:user/repo", .. => github://user/repo
" Also see section "2.2. names of addons and addon sources" in VAM's documentation
endfunction
call SetupVAM()
" experimental [E1]: load plugins lazily depending on filetype, See
" NOTES
" experimental [E2]: run after gui has been started (gvim) [3]
" option1: au VimEnter * call SetupVAM()
" option2: au GUIEnter * call SetupVAM()
" See BUGS sections below [*]
" Vim 7.0 users see BUGS section [3]
" }}}
" Option Settings {{{
set hidden
set wildmenu
set nocompatible
set number
set ruler
set list
"set encoding=utf8
" I like this personally
set listchars=tab:\⇒\─,trail:\‣,extends:\↷,precedes:\↶
" But for example, you might like something like this
" set listchars=tab:\→\ ,trail:\‣,extends:\↷,precedes:\↶
"
" Or something more cluttered, like this
" set listchars=tab:\↴\⇒,trail:\⎕,extends:\↻,precedes:\↺,eol:\↵
"
" Or something more prominent but still thin and line oriented
" set listchars=tab:\┼\─,trail:\˽,extends:\↷,precedes:\↶
" standard-ish default-ish tab behavior
set expandtab
set ts=8
set sts=4
set sw=4
" search
set ignorecase
set smartcase
set incsearch
set nohlsearch
set nowrap
" window splits
set winminheight=0
set winminwidth=0
" keys
set backspace=2
set whichwrap=b,s,h,l,[,],<,>
" misc
set foldmethod=marker
set display=lastline,uhex
set sessionoptions+=resize
set laststatus=2
" set statusline=[%n]\ %<%.99f\ %h%w%m%r%y%=%-16(\ %l,%c\ %)%P
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y%{fugitive#statusline()}%=%-16(\ %l,%c\ %)%P
" Sophisticated Swap Files {{{
if has("win32")
if exists("my_diff_mode_flag") && my_diff_mode_flag == 1
set directory=~\vimfiles\swpdiff,C:\WINDOWS\Temp,~/tmp,~,.
else
set directory=~\vimfiles\swpdiff,C:\WINDOWS\Temp,~/tmp,~,.
endif
elseif has("unix")
if exists("my_diff_mode_flag") && my_diff_mode_flag == 1
set directory=~/.vim/swpdiff,~/.swpdiff,/tmp,~/tmp,~,.
else
set directory=~/.vim/swp,~/.swp,/tmp,~/tmp,~,.
endif
endif
" }}}
" }}}
" Plugin Settings {{{
" prevent annoying warnings from nerdtree
let g:NERDShutUp = 1
" don't load the matchparen plugin
let loaded_matchparen = 1
" filetype plugin settings
let g:no_html_tab_mapping = 1 " let me insert tabs when i press the freakin tab key!
let g:html_tag_case = 'lowercase'
let g:sql_type_default = 'pgsql'
let g:miniBufExplTabWrap = 1
let g:insertlessly_cleanup_trailing_ws = 0
let g:insertlessly_cleanup_all_ws = 0
"let g:php_sync_method = 0
let g:php_sync_method = 100
" taglist plugin settings
let Tlist_Auto_Highlight_Tag = 0
let Tlist_Sort_Type = "name"
let Tlist_Highlight_Tag_On_BufEnter = 0
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 'auto'
" use a vertical window split
let g:yankring_window_use_horiz = 0
" don't include single character deletes
let g:yankring_min_element_length = 2
" truncate each paste at 50 chars to keep the window width small
let g:yankring_max_display = 50
" don't bother to colorize end tags differently
" based on what type of block is being ended
" hopefully this means faster loads and better
" syntax hilite with folds
let ruby_no_expensive = 1
" JRuby Load-Speed Fix
" if !empty(matchstr($MY_RUBY_HOME, 'jruby'))
if !empty(matchstr($MY_RUBY_HOME, 'jruby'))
"let g:ruby_path = join(split(glob($MY_RUBY_HOME.'/lib/ruby/*.*')."\n".glob($MY_RUBY_HOME.'/lib/ruby/site_ruby/*'),"\n"),',')
"let g:ruby_path = join(split(glob($MY_RUBY_HOME.'/lib/ruby/*.*')."\n".glob($MY_RUBY_HOME.'/lib/ruby/site_ruby/*')."\n".glob($GEM_HOME.'*/**/lib'),"\n"),',')
" hardcoding this for speed, do it this way if you're new
" and need to figure out what your paths actually are or
" maybe if you need to add or change some gems
" bare minimum basics for a nicer/faster startup time, I
" don't personally use any of the gem related features of
" the ruby plugin that I'm aware
let g:ruby_path = '/home/vaughn/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.9,/home/vaughn/.rvm/rubies/jruby-1.6.7.2/lib/ruby/site_ruby/shared'
endif
" }}}
" GUI vs Console {{{
" ****************************************************************
set winaltkeys=no
" Unbreak Unix style mouse selection -> copy
vnoremap <LeftRelease> "+y<LeftRelease>gv
" tab display
if v:version >= 700
set guitablabel=%L\ %t\ %h
set guitabtooltip=%f
endif
" Setup Toolbars
set guioptions=ti " with menubar and toolbar and tearoffs
" Set Font
if has("win32")
set gfn=DejaVu_Sans_Mono:h8:cANSI
elseif has("unix")
set gfn=DejaVu\ Sans\ Mono\ 9
elseif has("macunix")
set gfn=DejaVu\ Sans\ Mono:h11
endif
" light in gvim, dark in terminal
if has("gui_running")
"colorscheme molokai
"hi Folded guifg=#dddddd guibg=#1B1D1E
"colorscheme inkpot
"hi Folded guibg=#1c314c guifg=#dddddd
colorscheme solarized
set background=light
else
"colorscheme molokai
"hi Folded guifg=#dddddd guibg=#1B1D1E
colorscheme inkpot
hi Folded guibg=#1c314c guifg=#dddddd
"colorscheme solarized
"set background=light
"set t_Co=256
set mouse=a
endif
" }}}
" Auto Commands {{{
"autocmd FileType xml,xhtml,html,php,phtml,eruby,jst runtime scripts/closetag.vim
autocmd BufRead *.handlebars set ft=handlebars
autocmd BufRead *.tpl set ft=jst
autocmd BufRead *.as set ft=actionscript
autocmd BufRead *.mxml set ft=mxml
autocmd BufRead *.conf set ft=apache
autocmd BufRead *.phtml set ft=php
autocmd BufRead *.wsgi set ft=python
autocmd BufWrite *.wsgi set ft=python
autocmd BufRead *.haml.js set ft=haml
autocmd BufRead *.jst.haml set ft=haml
autocmd BufEnter *.html set sts=2 sw=2
autocmd BufEnter *.ctp set sts=2 sw=2 " cake templates
autocmd BufNew,BufRead * set relativenumber
" }}}
" Key Mappings {{{
let maplocalleader = "-"
nmap <Return> <Plug>OpenNewline
nmap <S-Return> <Plug>InsertNewLine
" fast .vimrc access
nnoremap <LocalLeader>v :e ~/.vimrc<CR>
nnoremap <LocalLeader>o :source ~/.vimrc<CR>
" toggles
let g:ctrlp_map = '<Leader>p'
nnoremap <LocalLeader>f :botright copen<CR>
nnoremap <LocalLeader>x :cclose<CR>
nnoremap <LocalLeader>t :TlistToggle<CR>
nnoremap <LocalLeader>n :NERDTreeToggle<CR>
nnoremap <LocalLeader>h :set hls!<CR>
nnoremap <Return> :call ToggleFold()<CR>
nnoremap <LocalLeader>r :call ToggleRelativeNumber()<CR>
vnoremap <LocalLeader>r :call ToggleRelativeNumberVisual()<CR>
nnoremap <LocalLeader>w :call ToggleWrap()<CR>
nnoremap <LocalLeader>m :call ToggleMousePaste()<CR>
nnoremap <LocalLeader>z :syntax on<CR>
nnoremap <LocalLeader>yr :YRShow<CR>
nnoremap <LocalLeader>yc :YRClear<CR>
nnoremap <LocalLeader>y1 :YRGetElem 1<CR>
nnoremap <LocalLeader>y2 :YRGetElem 2<CR>
nnoremap <LocalLeader>y3 :YRGetElem 3<CR>
nnoremap <LocalLeader>y4 :YRGetElem 4<CR>
nnoremap <LocalLeader>y5 :YRGetElem 5<CR>
nnoremap <LocalLeader>y6 :YRGetElem 6<CR>
nnoremap <LocalLeader>y7 :YRGetElem 7<CR>
nnoremap <LocalLeader>y8 :YRGetElem 8<CR>
nnoremap <LocalLeader>y9 :YRGetElem 9<CR>
nnoremap <LocalLeader>y0 :YRGetElem 10<CR>
" filters
nnoremap <LocalLeader>q {v}!par -jw
vnoremap <LocalLeader>q !par -jw
vnoremap <LocalLeader>a !perl ~/.vim/bin/align.pl -c:=
nnoremap <LocalLeader>s :call StripWhitespace()<CR>
" javascript specific stuff
nnoremap <LocalLeader>jsb :call JsBeautify()<CR>
vnoremap <LocalLeader>jsb :call JsBeautifyRange()<CR>
nmap <LocalLeader>jsy ^yypysiW)kysiW"ysiW)^iconsole.log<ESC>j^.$a;<ESC>k$a;<ESC>
nmap <LocalLeader>jsl ^v$hS"gvS)^iconsole.log<ESC>$a;<ESC>
vmap <LocalLeader>jsl S"gvS)^iconsole.log<ESC>$a;<ESC>
nmap <LocalLeader>pdv ysiW(^iecho "<pre>"; var_dump<ESC>$a; exit;<ESC>
nmap <LocalLeader>pdf ysiW(ysi((iget_class_methods<ESC>^iecho "<pre>"; var_dump<ESC>$a; exit;<ESC>
" auto insert curly braces on Control-F
inoremap <C-F> {<CR>}<C-O>O
" alt key substitutions for normal style
" editor things like copy paste save
" close and quit
nnoremap <M-q> :qa!<CR>
nnoremap <M-a> ggVG
nnoremap <M-v> "+P
nnoremap <M-V> "+p
vnoremap <M-c> "+y
vnoremap <M-x> "+x
nnoremap <M-s> :w<CR>
nnoremap <M-w> :BD<CR>
nnoremap <M-W> :bd<CR>
nnoremap <M-n> :bn<CR>
nnoremap <M-p> :bp<CR>
nnoremap <M-1> :YRGetElem 1<CR>
nnoremap <M-2> :YRGetElem 2<CR>
nnoremap <M-3> :YRGetElem 3<CR>
nnoremap <M-4> :YRGetElem 4<CR>
nnoremap <M-5> :YRGetElem 5<CR>
nnoremap <M-6> :YRGetElem 6<CR>
nnoremap <M-7> :YRGetElem 7<CR>
nnoremap <M-8> :YRGetElem 8<CR>
nnoremap <M-9> :YRGetElem 9<CR>
nnoremap <M-0> :YRGetElem 10<CR>
" show and hide the menubar, toolbar and scrollbar respectively
nnoremap <C-F1> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
nnoremap <C-F2> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>
nnoremap <C-F3> :if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>
" make indentation easier by default
nnoremap < <<
nnoremap > >>
" make indentation keep selection intact
vnoremap > >gv
vnoremap < <gv
nnoremap <C-e> j<C-e>
nnoremap <C-y> k<C-y>
" }}}
" Functions {{{
function! ToggleMousePaste()
if &mouse == 'a'
set paste
set mouse=
set nonumber
echo 'Mouse Paste ON'
else
set nopaste
set number
set mouse=a
echo 'Mouse Paste OFF'
endif
endfunction
function! ToggleRelativeNumberVisual()
call ToggleRelativeNumber()
normal gvj
endfunction
function! ToggleRelativeNumber()
if( &nu == 1 )
set nonu
set rnu
else
set nu
set nornu
endif
endfunction
function! ToggleWrap()
set wrap!
if( &wrap == 1 )
nmap j gj
nmap k gk
else
unmap j
unmap k
endif
endfunction
function! ToggleFold()
if foldlevel('.') == 0
normal! l
else
if foldclosed('.') < 0
. foldclose
else
. foldopen
endif
endif
" Clear status line
echo
endfunction
function! StripWhitespace()
let currPos=Mark()
exe 'v:^--\s*$:s:\s\+$::e'
exe currPos
endfunction
function! Mark(...)
if a:0 == 0
let mark = line(".") . "G" . virtcol(".") . "|"
normal! H
let mark = "normal!" . line(".") . "Gzt" . mark
execute mark
return mark
elseif a:0 == 1
return "normal!" . a:1 . "G1|"
else
return "normal!" . a:1 . "G" . a:2 . "|"
endif
endfunction
function! JsBeautify()
" Things `js-beautify` does not do
" ****************************************************************
" line breaks between class definitions
%s/^}\s*)\s*;\(\s*\n\)*/});\r\r/g
" line breaks between function definitions
%s/^ }\s*,\(\s*\n\)*/ },\r\r/g
" change $(this.el) to this.$el
%s/$(\s*\(this\|cmp\)\s*\.\s*el\s*)/\1.$el/g
" Run `js-beautify`
" ****************************************************************
%!myjsbeautify -
" Things to change
" ****************************************************************
" put opening function braces of underscore style closures back on the same line
%s/\(_\.[a-zA-Z0-9_]\+(.\{-}function\s([^{]*\)\s*\n\s*{\(\s*\n\)*/\1 {\r/
%s/\(_\.\s*extend\*([^{]*\)\s*\n\s*{\(\s*\n\)*/\1 {\r/
" put opening function braces of other closures back on the same line
%s/\((.\{-}function\s*[^{]*\)\(\s*\n\)*\s*{\(\s*\n\)*/\1 {\r/g
" put opening braces of foo({ bar: baz }) type calls back on the same line
%s/^\(\(.\(function\|if\|else\|while\|for\|try\|catch\|switch\)\@!\)*\)(\s*\n\s*{/\1({/
" catch those pesky object extenders
%s/\(_\.\s*extend\s*([^;]\+\)\(\s*\n\)\+\s*{\(\s*\n\)*/\1 {\r/
" normalize line breaks
%s/\(\s*\n\)\{3,}/\r\r/g
endfunction
function! JsBeautifyRange() range
" Things `js-beautify` does not do
" ****************************************************************
" line breaks between class definitions
'<,'>s/^}\s*)\s*;\(\s*\n\)*/});\r\r/g
" line breaks between function definitions
'<,'>s/^ }\s*,\(\s*\n\)*/ },\r\r/g
" change $(this.el) to this.$el
'<,'>s/$(\s*\(this\|cmp\)\s*\.\s*el\s*)/\1.$el/g
" Run `js-beautify`
" ****************************************************************
'<,'>!myjsbeautify -
" Things to change
" ****************************************************************
" put opening function braces of underscore style closures back on the same line
'<,'>s/\(_\.[a-zA-Z0-9_]\+(.\{-}function\s([^{]*\)\s*\n\s*{\(\s*\n\)*/\1 {\r/
'<,'>s/\(_\.\s*extend\*([^{]*\)\s*\n\s*{\(\s*\n\)*/\1 {\r/
" put opening function braces of other closures back on the same line
'<,'>s/\((.\{-}function\s*[^{]*\)\(\s*\n\)*\s*{\(\s*\n\)*/\1 {\r/g
" put opening braces of foo({ bar: baz }) type calls back on the same line
'<,'>s/^\(\(.\(function\|if\|else\|while\|for\|try\|catch\|switch\)\@!\)*\)(\s*\n\s*{/\1({/
" catch those pesky object extenders
'<,'>s/\(_\.\s*extend\s*([^;]\+\)\(\s*\n\)\+\s*{\(\s*\n\)*/\1 {\r/
" normalize line breaks
'<,'>s/\(\s*\n\)\{3,}/\r\r/g
endfunction
function! UnHamlize()
" keep things sane
%s/'/"/g
" normalish tags with attributes
%s/%\([a-zA-Z].\{-}\){\(.\{-}\)}/<\1 \2>/g
" tags with no attributes
%s/%\([a-zA-Z]\{-}\)\(\s\+\|\n\)/<\1>\2/g
" tags with attributes that have plain vars as values
%s/\(\s*\):\([a-z-]\{-}\)\s*=>\s*\([^"]\{-}\)\s*,/\1\2="<%= \3 %>"/g
%s/\(\s*\):\([a-z-]\{-}\)\s*=>\s*\([^"]\{-}\)\(\s*}\|\s*>\)/\1\2="<%= \3 %>"\4/g
" tags with attributes that are regular strings
%s/\(\s*\):\([a-z-]\{-}\)\s*=>\s*"\(.\{-}\)"\s*,/\1\2="\3"/g
%s/\(\s*\):\([a-z-]\{-}\)\s*=>\s*"\(.\{-}\)"\(\s*}\|\s*>\)/\1\2="\3"\4/g
" output tags
%s/^\(\s*\)= \(.*\)$/\1<%= \2 %>/
" script tags
%s/^\(\s*\)- \(.*\)$/\1<% \2 %>/
" interpolated variables
%s/#{\(.\{-}\)}/<%= \1 %>/g
" comments
%s#^\(\s*\)/\s*\(.*\)$#\1<!-- \2 -->#
" dangling script tags
%s#<script\(.*\)>\s*$#<script \1></script>#
endfunction
function! Retab()
let &tabstop = &shiftwidth
retab
let &tabstop = 8
endfunction
" }}}