# HG changeset patch # User Steve Losh # Date 1299622225 18000 # Node ID a5066da2a34d3c7a18dd0a3cb4732efd3cc1b782 # Parent 81859b5dd262263815958c5ef8b9240e8e0932ee vim: tons of tweaks diff -r 81859b5dd262 -r a5066da2a34d .ctags --- a/.ctags Tue Mar 08 16:30:16 2011 -0500 +++ b/.ctags Tue Mar 08 17:10:25 2011 -0500 @@ -7,3 +7,4 @@ --regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/ --regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/ --regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/ +--exclude='**/ckeditor' diff -r 81859b5dd262 -r a5066da2a34d vim/.vimrc --- a/vim/.vimrc Tue Mar 08 16:30:16 2011 -0500 +++ b/vim/.vimrc Tue Mar 08 17:10:25 2011 -0500 @@ -87,7 +87,7 @@ " }}} " }}} -" Useful Abbreviations -------------------------------------------------------- {{{ +" Useful abbreviations -------------------------------------------------------- {{{ iabbrev ldis ಠ_ಠ iabbrev sl/ http://stevelosh.com/ @@ -96,16 +96,19 @@ iabbrev sl@ steve@stevelosh.com " }}} -" Searching and Movement ------------------------------------------------------ {{{ +" Searching and movement ------------------------------------------------------ {{{ +" Use sane regexes. nnoremap / /\v vnoremap / /\v set ignorecase set smartcase + set incsearch set showmatch set hlsearch + set gdefault map :noh @@ -116,19 +119,31 @@ nnoremap Y y$ nnoremap D d$ +" Keep search matches in the middle of the window. +nnoremap * *zz +nnoremap ? ?zz nnoremap n nzz nnoremap N Nzz -nnoremap L $ -vnoremap L $ -onoremap L $ +" L is easier to type, and I never use the default behavior. +noremap L $ +" Error navigation {{{ +" +" Location List QuickFix Window +" (i.e. Syntastic) (i.e. Ack) +" ---------------------------------- +" Next | M-k M-Down | +" Previous | M-l M-Up | +" ---------------------------------- +" nnoremap ˚ :lnext nnoremap ¬ :lprevious inoremap ˚ :lnext inoremap ¬ :lprevious nnoremap :cnext nnoremap :cprevious +" }}} " Directional Keys {{{ @@ -158,8 +173,13 @@ " Folding --------------------------------------------------------------------- {{{ set foldlevelstart=0 + +" Space to toggle folds. nnoremap za vnoremap za + +" Make zO recursively open whatever top level fold we're in, no matter where the +" cursor happens to be. nnoremap zO zCzO function! MyFoldText() " {{{ @@ -184,8 +204,8 @@ " Fuck you, help key. set fuoptions=maxvert,maxhorz +noremap :set invfullscreen inoremap :set invfullscreena -noremap :set invfullscreen " Fuck you too, manual key. nnoremap K @@ -199,19 +219,22 @@ " Cram {{{ au BufNewFile,BufRead *.t set filetype=cram + let cram_fold=1 autocmd Syntax cram setlocal foldlevel=1 " }}} " Clojure {{{ -au BufNewFile,BufRead *.clj nmap ee 0;\et au FileType clojure call TurnOnClojureFolding() +" Eval toplevel form, even when you're on the opening paren. +au FileType clojure nmap ee 0;\et + " }}} " C {{{ -au BufNewFile,BufRead *.c setlocal foldmethod=syntax +au FileType c setlocal foldmethod=syntax " }}} " HTML and HTMLDjango {{{ @@ -245,35 +268,61 @@ au BufNewFile,BufRead *.html imap . " }}} -" CSS {{{ - -au BufNewFile,BufRead *.css setlocal foldmethod=marker -au BufNewFile,BufRead *.css setlocal foldmarker={,} -au BufNewFile,BufRead *.css nnoremap cc ddko -au BufNewFile,BufRead *.css nnoremap S ?{jV/\v^\s*\}?$k:sort:noh -au BufNewFile,BufRead *.css inoremap { {}.kA - -" }}} -" LessCSS {{{ +" CSS and LessCSS {{{ au BufNewFile,BufRead *.less setlocal filetype=less + +au BufNewFile,BufRead *.css setlocal foldmethod=marker au BufNewFile,BufRead *.less setlocal foldmethod=marker + +au BufNewFile,BufRead *.css setlocal foldmarker={,} au BufNewFile,BufRead *.less setlocal foldmarker={,} + +" Use cc to change lines without borking the indentation. +au BufNewFile,BufRead *.css nnoremap cc ddko au BufNewFile,BufRead *.less nnoremap cc ddko + +" Use S to sort properties. Turns this: +" +" p { +" width: 200px; +" height: 100px; +" background: red; +" +" ... +" } +" +" into this: + +" p { +" background: red; +" height: 100px; +" width: 200px; +" +" ... +" } +" +au BufNewFile,BufRead *.css nnoremap S ?{jV/\v^\s*\}?$k:sort:noh au BufNewFile,BufRead *.less nnoremap S ?{jV/\v^\s*\}?$k:sort:noh + +" Make { insert a pair of brackets in such a way that the cursor is correctly +" positioned inside of them AND the following code doesn't get unfolded. +au BufNewFile,BufRead *.css inoremap { {}.kA au BufNewFile,BufRead *.less inoremap { {}.kA " }}} " Javascript {{{ -au BufNewFile,BufRead *.js setlocal foldmethod=marker -au BufNewFile,BufRead *.js setlocal foldmarker={,} +au FileType javascript setlocal foldmethod=marker +au FileType javascript setlocal foldmarker={,} " }}} " Confluence {{{ au BufRead,BufNewFile *.confluencewiki setlocal filetype=confluencewiki -au BufRead,BufNewFile *.confluencewiki setlocal wrap linebreak nolist + +" Wiki pages should be soft-wrapped. +au FileType confluencewiki setlocal wrap linebreak nolist " }}} " Fish {{{ @@ -284,6 +333,8 @@ " Markdown {{{ au BufNewFile,BufRead *.m*down setlocal filetype=markdown + +" Use 1/2/3 to add headings. au Filetype markdown nnoremap 1 yypVr= au Filetype markdown nnoremap 2 yypVr- au Filetype markdown nnoremap 3 I### @@ -312,8 +363,8 @@ " }}} " Nginx {{{ -au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx -au BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx +au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx +au BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx au BufRead,BufNewFile /usr/local/etc/nginx/sites-available/* set ft=nginx " }}} @@ -352,9 +403,9 @@ " Better Completion set completeopt=longest,menuone -inoremap pumvisible() ? "\" : "\u\" -inoremap pumvisible() ? '' : '=pumvisible() ? "\up>" : ""' -inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' +inoremap pumvisible() ? "\" : "\u\" +inoremap pumvisible() ? '' : '=pumvisible() ? "\up>" : ""' +inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' " Make selecting inside an HTML tag less dumb nnoremap Vit vitVkoj @@ -388,7 +439,7 @@ cmap Wq wq " }}} -" Plugin Settings ------------------------------------------------------------- {{{ +" Plugin settings ------------------------------------------------------------- {{{ " NERD Tree {{{ @@ -444,12 +495,16 @@ " }}} " Synstack -------------------------------------------------------------------- {{{ +" Show the stack of syntax hilighting classes affecting whatever is under the +" cursor. function! SynStack() " {{{ if !exists("*synstack") return endif + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') endfunc " }}} + nmap :call SynStack() " }}} @@ -574,7 +629,7 @@ " }}} " Ctags ----------------------------------------------------------------------- {{{ -map T :!/usr/local/bin/ctags --exclude='**/ckeditor' -R . $(test -f .venv && echo ~/lib/virtualenvs/`cat .venv`) +map T :!/usr/local/bin/ctags -R . $(test -f .venv && echo ~/lib/virtualenvs/`cat .venv`) " }}} " MacVim ---------------------------------------------------------------------- {{{