Commits

Ed Brannin  committed b72010e

vimrc: Group autocommands into augroups

  • Participants
  • Parent commits 7c06ae2

Comments (0)

Files changed (2)

 2dd198c6c412b4ddd361b43586b01981e8383239 vim/bundle/nerdtree
 b0dbf8e43a12ec52efd541b594a0a6c4b41f5f40 vim/bundle/puppet
 c2e507ecdc0c1015c5c6d5eebcec8d561470d307 vim/bundle/simplenote.vim
+0075555d33a5937ac7e1667ef7c926dc35b40515 vim/bundle/snipmate.vim
 c6197a10ace82e0fe0c08e5cf5c017b7069a978e vim/bundle/sparkup
 b7b4d8791a50013b56c2d68b6c5708c808203b54 vim/bundle/tabular
 12c767050f09fb158e26b935501f96300bf650a6 vim/bundle/taskpaper.vim
 9990a767695c78a44611ce33fb2dbc25c83d8827 vim/bundle/vim-javascript
  vim/bundle/vim-markdown
 fb16afe7382f8460c3a6f5318ed882319081330a vim/bundle/vim-pathogen
+613eb1c81261adfa5dead315089c432ff6dbbc51 vim/bundle/vim-repeat
 d9e6bfdd902fc661c8fd58ede248ccfc3b3039d7 vim/bundle/vim-surround
 6bfea0006a364c60e5e7e0daecb9a3899312cb58 vim/bundle/vim-trailing-whitespace
 84297c90516c40df5c6e224930c3bd92a8046efd vim/bundle/vimwiki
 set hlsearch
 set ruler
 set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.info,.aux,.log,.dvi,.bbl,.out
-syn on 
+syn on
 
-au BufNewFile,BufRead *.less set filetype=less
 
 set hlsearch
 
 
 " https://github.com/juanpabloaj/dotfiles/blob/master/.vimrc#L404,L405
 if exists('+relativenumber')
-  autocmd InsertEnter * setl nu
-  autocmd InsertLeave * setl rnu
-  autocmd WinLeave *
-        \ if &rnu==1 |
-        \ exe "setl norelativenumber" |
-        \ exe "setl nu" |
-        \ endif
-  autocmd WinEnter *
-        \ if &rnu==0 |
-        \ exe "setl rnu" |
-        \ endif
+  augroup RelativeNumbers
+    au!
+    autocmd InsertEnter * setl nu
+    autocmd InsertLeave * setl rnu
+    autocmd WinLeave *
+          \ if &rnu==1 |
+          \ exe "setl norelativenumber" |
+          \ exe "setl nu" |
+          \ endif
+    autocmd WinEnter *
+          \ if &rnu==0 |
+          \ exe "setl rnu" |
+          \ endif
+  augroup END
 endif
 
 
 set list
 " set listchars=tab:▸\ ,eol:¬
 if has("gui_macvim") || has("gui_running")
-  set listchars=tab:▸\ 
+  set listchars=tab:▸\
 endif
 
 if has("gui_macvim")
 nnoremap <leader>eR :source $MYVIMRC<CR>
 " When vimrc is edited, reload it
 " FIXME: This works with vimrc but not _vimrc
-autocmd! bufwritepost vimrc source $MYVIMRC
+augroup vimrc
+  autocmd! bufwritepost vimrc source $MYVIMRC
+augroup END
 
 
 
 
 " Convert TSV to CSV
 nnoremap <leader>c :CSV<cr>
-verbose command! -range=% CSV <line1>,<line2>!python -c 'import csv, sys, fileinput; writer = csv.writer(sys.stdout); [writer.writerow([field.strip() for field in line.split("\t")]) for line in fileinput.input() if line.strip() != ""]'
+verbose command! -range=% CSV <line1>,<line2>!python -c 'import csv, sys, fileinput; writer = csv.writer(sys.stdout); [writer.writerow([field.strip() for field in line.split("\t")]) for line in fileinput.input() if line.strip() \!= ""]'
 
 nnoremap <leader>J :g/\v:$/normal J<cr>:%s/\v\tHelp$//e<cr>:FixWhitespace<cr>:%s/.*Sort By: //<cr>
 
   vnoremap <Leader>a\| :Tabularize /\|\+<CR>
 endif
 
-" http://twitter.com/dotvimrc/status/112171196153475073
-" http://twitter.com/dotvimrc/status/112192216633573376
-au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap
-
-
 " Split/Join {{{
 "
 " Basically this splits the current line into two new ones at the cursor position,
 nnoremap K h/[^ ]<cr>"zd$jyyP^v$h"zpJk:s/\v +$//<cr>:noh<cr>j^
 " }}}
 
-" Fold HTML tags with <localleader>f
-" http://twitter.com/dotvimrc/status/104209301882667008
-au FileType html setlocal foldmethod=manual
-au FileType html nnoremap <buffer> <localleader>f Vatzf
-
-" Open :help documents in a nice, big vertical split instead of a horizontal one
-" http://twitter.com/dotvimrc/status/103460040903626752
-au FileType help wincmd L
-
 
 " Press <C-b> in insert mode to calculate:
 "  10+24*100<c-b>
 " http://twitter.com/dotvimrc/status/103161175033917442
 inoremap <C-B> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
 
-" Add dashes to the list of "word characters" for CSS files:
-" http://twitter.com/dotvimrc/status/114423824161837056
-au Filetype css setlocal iskeyword+=-
 
 set pastetoggle=<f12>
 
 verbose command! -range -nargs=* Cowsay <line1>,<line2>!cowsay <args>
 verbose command! -range -nargs=* Figsay <line1>,<line2>!figlet | cowsay -n
 
-" TODO: Add a mapping to CDATA the selected visual block or motion.
-au BufNewFile,BufRead *.md set filetype=markdown
+augroup FileTypes
+  au!
+  " TODO: Add a mapping to CDATA the selected visual block or motion.
+  au BufNewFile,BufRead *.less setf less
+  au BufNewFile,BufRead *.md setf markdown
+  au BufRead,BufNewFile *.j2 setf html.jinja
+
+  " http://twitter.com/dotvimrc/status/112171196153475073
+  " http://twitter.com/dotvimrc/status/112192216633573376
+  au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap
+
+
+  " Fold HTML tags with <localleader>f
+  " http://twitter.com/dotvimrc/status/104209301882667008
+  au FileType html setlocal foldmethod=manual
+  au FileType html nnoremap <buffer> <localleader>f Vatzf
+
+  " Open :help documents in a nice, big vertical split instead of a horizontal one
+  " http://twitter.com/dotvimrc/status/103460040903626752
+  au FileType help wincmd L
+
+  " Add dashes to the list of "word characters" for CSS files:
+  " http://twitter.com/dotvimrc/status/114423824161837056
+  au Filetype css setlocal iskeyword+=-
+augroup END