# HG changeset patch # User Steve Losh # Date 1314922342 14400 # Node ID 959a5c4fc9fb4b6406cc4d4c8833d48c869505ef # Parent 5b9c4d43e1a9f21d73462b810d154de98b51220a Tons of awesome suggestions from the @dotvimrc suggestion-fest. diff -r 5b9c4d43e1a9 -r 959a5c4fc9fb vim/.vimrc --- a/vim/.vimrc Wed Aug 31 12:14:28 2011 -0400 +++ b/vim/.vimrc Thu Sep 01 20:12:22 2011 -0400 @@ -20,8 +20,6 @@ set showmode set showcmd set hidden -set wildmenu -set wildmode=list:longest set visualbell set cursorline set ttyfast @@ -38,7 +36,6 @@ set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮ set shell=/bin/bash set lazyredraw -set wildignore+=*.pyc,.hg,.git set matchtime=3 set showbreak=↪ set splitbelow @@ -47,6 +44,23 @@ set ttimeout set notimeout set nottimeout +set autowrite +set shiftround + +" Wildmenu completion {{{ +set wildmenu +set wildmode=list:longest + +set wildignore+=.hg,.git,.svn " Version control +set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files +set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images +set wildignore+=*.luac " Lua byte code +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files +set wildignore+=*.pyc " Python byte code +set wildignore+=*.spl " compiled spelling word lists +set wildignore+=*.sw? " Vim swap files +set wildignore+=*.DS_Store? " OSX bullshit +" }}} " Make Vim able to edit crontab files again. set backupskip=/tmp/*,/private/tmp/*" @@ -133,7 +147,7 @@ set virtualedit+=block -map :noh +noremap :noh:match none:2match none:3match none runtime macros/matchit.vim map % @@ -146,11 +160,12 @@ set sidescrolloff=10 " Keep search matches in the middle of the window. -nnoremap * *zzzv -nnoremap # #zzzv nnoremap n nzzzv nnoremap N Nzzzv +" Don't move on * +nnoremap * mq*`q + " Same when jumping around nnoremap g; g;zz nnoremap g, g,zz @@ -163,9 +178,12 @@ inoremap I inoremap A -" Open a Quickfix window for the last search +" Open a Quickfix window for the last search. nnoremap / :execute 'vimgrep /'.@/.'/g %':copen +" Ack for the last search. +nnoremap ? :execute "Ack! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'" + " Fix linewise visual selection of various text objects nnoremap VV V nnoremap Vit vitVkoj @@ -205,6 +223,13 @@ " }}} +" Highlight word {{{ +nnoremap hh :execute 'match InterestingWord1 /\<\>/' +nnoremap h1 :execute 'match InterestingWord1 /\<\>/' +nnoremap h2 :execute '2match InterestingWord2 /\<\>/' +nnoremap h3 :execute '3match InterestingWord3 /\<\>/' +" }}} + " }}} " Folding --------------------------------------------------------------------- {{{ @@ -219,7 +244,7 @@ nnoremap zO zCzO " Use ,z to "focus" the current fold. -nnoremap z zMzv +nnoremap z zMzvzz function! MyFoldText() " {{{ let line = getline(v:foldstart) @@ -447,9 +472,9 @@ " }}} " Python {{{ -au Filetype python noremap rr :RopeRename -au Filetype python vnoremap rm :RopeExtractMethod -au Filetype python noremap ri :RopeOrganizeImports +au Filetype python noremap rr :RopeRename +au Filetype python vnoremap rm :RopeExtractMethod +au Filetype python noremap ri :RopeOrganizeImports au FileType python setlocal omnifunc=pythoncomplete#Complete " }}} @@ -520,6 +545,14 @@ " HTML tag closing inoremap :call InsertCloseTag()a +" Align text +nnoremap Al :left +nnoremap Ac :center +nnoremap Ar :right +vnoremap Al :left +vnoremap Ac :center +vnoremap Ar :right + " Faster Esc inoremap jk @@ -550,25 +583,22 @@ " Sudo to write cmap w!! w !sudo tee % >/dev/null -" Tags -nnoremap T :!ctags -R -f ./tags . - " I suck at typing. nnoremap = == -" Easy filetype switching +" Easy filetype switching {{{ nnoremap _md :set ft=markdown nnoremap _hd :set ft=htmldjango nnoremap _jt :set ft=htmljinja nnoremap _cw :set ft=confluencewiki nnoremap _pd :set ft=python.django nnoremap _d :set ft=diff +" }}} " Toggle paste set pastetoggle= -" Split/Join -" ---------- +" Split/Join {{{ " " Basically this splits the current line into two new ones at the cursor position, " then joins the second one with whatever comes next. @@ -587,6 +617,40 @@ " Especially useful for adding items in the middle of long lists/tuples in Python " while maintaining a sane text width. nnoremap K h/[^ ]"zd$jyyP^v$h"zpJk:s/\v +$//:nohj^ +" }}} + +" Handle URL {{{ +" Stolen from https://github.com/askedrelic/homedir/blob/master/.vimrc +" OSX only: Open a web-browser with the URL in the current line +function! HandleURI() + let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^ >,;]*') + echo s:uri + if s:uri != "" + exec "!open \"" . s:uri . "\"" + else + echo "No URI found in line." + endif +endfunction +map u :call HandleURI() +" }}} + +" Quickreturn +inoremap A +inoremap A: + +" Indent Guides {{{ +let g:indentguides_state = 0 +function! IndentGuides() " {{{ + if g:indentguides_state + let g:indentguides_state = 0 + 2match None + else + let g:indentguides_state = 1 + execute '2match IndentGuides /\%(\_^\s*\)\@<=\%(\%'.(0*&sw+1).'v\|\%'.(1*&sw+1).'v\|\%'.(2*&sw+1).'v\|\%'.(3*&sw+1).'v\|\%'.(4*&sw+1).'v\|\%'.(5*&sw+1).'v\|\%'.(6*&sw+1).'v\|\%'.(7*&sw+1).'v\)\s/' + endif +endfunction " }}} +nnoremap i :call IndentGuides() +" }}} " }}} " Plugin settings ------------------------------------------------------------- {{{ @@ -767,7 +831,7 @@ let g:yankring_min_element_length = 2 function! YRRunAfterMaps() - nnoremap Y :YRYankCount 'y$' + nnoremap Y :YRYankCount 'y$' omap L YRMapsExpression("", "$") omap H YRMapsExpression("", "^") endfunction @@ -776,21 +840,6 @@ " }}} " }}} -" 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() - -" }}} " Text objects ---------------------------------------------------------------- {{{ " Shortcut for [] {{{ @@ -833,12 +882,6 @@ " }}} " }}} -" Quickreturn ----------------------------------------------------------------- {{{ - -inoremap A -inoremap A: - -" }}} " Error toggles --------------------------------------------------------------- {{{ command! ErrorsToggle call ErrorsToggle() @@ -874,6 +917,22 @@ exec 'echom "----------> ' . a:msg . '"' endfunction +" 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() + +" }}} + " }}} " Hg Diff --------------------------------------------------------------------- {{{ diff -r 5b9c4d43e1a9 -r 959a5c4fc9fb vim/colors/molokai.vim --- a/vim/colors/molokai.vim Wed Aug 31 12:14:28 2011 -0400 +++ b/vim/colors/molokai.vim Thu Sep 01 20:12:22 2011 -0400 @@ -68,7 +68,11 @@ hi Macro guifg=#C4BE89 gui=italic hi SpecialKey guifg=#66D9EF gui=italic -hi MatchParen guifg=#E4E400 guibg=#232728 gui=bold +hi InterestingWord1 guifg=#000000 guibg=#FFA700 +hi InterestingWord2 guifg=#000000 guibg=#53FF00 +hi InterestingWord3 guifg=#000000 guibg=#FF74F8 + +hi MatchParen guifg=#E4E400 guibg=#434748 gui=bold hi ModeMsg guifg=#E6DB74 hi MoreMsg guifg=#E6DB74 hi Operator guifg=#F92672 @@ -86,6 +90,7 @@ hi Repeat guifg=#F92672 gui=bold " marks column +hi IndentGuides guibg=#373737 hi SignColumn guifg=#A6E22E guibg=#151617 hi SpecialChar guifg=#F92672 gui=bold hi SpecialComment guifg=#465457 gui=bold diff -r 5b9c4d43e1a9 -r 959a5c4fc9fb vim/indent/less.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/indent/less.vim Thu Sep 01 20:12:22 2011 -0400 @@ -0,0 +1,76 @@ +" Vim indent file +" Language: CSS +" Maintainer: Nikolai Weibull +" Latest Revision: 2010-12-22 + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetCSSIndent() +setlocal indentkeys=0{,0},!^F,o,O +setlocal nosmartindent + +if exists("*GetCSSIndent") + finish +endif + +function s:prevnonblanknoncomment(lnum) + let lnum = a:lnum + while lnum > 1 + let lnum = prevnonblank(lnum) + let line = getline(lnum) + if line =~ '\*/' + while lnum > 1 && line !~ '/\*' + let lnum -= 1 + endwhile + if line =~ '^\s*/\*' + let lnum -= 1 + else + break + endif + else + break + endif + endwhile + return lnum +endfunction + +function s:count_braces(lnum, count_open) + let n_open = 0 + let n_close = 0 + let line = getline(a:lnum) + let pattern = '[{}]' + let i = match(line, pattern) + while i != -1 + if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' + if line[i] == '{' + let n_open += 1 + elseif line[i] == '}' + if n_open > 0 + let n_open -= 1 + else + let n_close += 1 + endif + endif + endif + let i = match(line, pattern, i + 1) + endwhile + return a:count_open ? n_open : n_close +endfunction + +function GetCSSIndent() + let line = getline(v:lnum) + if line =~ '^\s*\*' + return cindent(v:lnum) + endif + + let pnum = s:prevnonblanknoncomment(v:lnum - 1) + if pnum == 0 + return 0 + endif + + return indent(pnum) + s:count_braces(pnum, 1) * &sw + \ - s:count_braces(v:lnum, 0) * &sw +endfunction