From 1f87ce0328acefbb5e68ea3af323d76e8d98c614 Mon Sep 17 00:00:00 2001 From: Wanpeng Yang Date: Fri, 10 Feb 2012 23:11:06 -0500 Subject: [PATCH] add autoclose plugin --- .gitmodules | 3 + .vim/bundle/vim-autoclose | 1 + .vimrc | 207 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 202 insertions(+), 9 deletions(-) create mode 160000 .vim/bundle/vim-autoclose diff --git a/.gitmodules b/.gitmodules index 83a205e..3fb3be6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -46,3 +46,6 @@ [submodule ".vim/bundle/vim-colors-solarized"] path = .vim/bundle/vim-colors-solarized url = git://github.com/altercation/vim-colors-solarized.git +[submodule ".vim/bundle/vim-autoclose"] + path = .vim/bundle/vim-autoclose + url = git://github.com/Townk/vim-autoclose.git diff --git a/.vim/bundle/vim-autoclose b/.vim/bundle/vim-autoclose new file mode 160000 index 0000000..1e5eb35 --- /dev/null +++ b/.vim/bundle/vim-autoclose @@ -0,0 +1 @@ +Subproject commit 1e5eb35f5d4ef93082455e11298520cfa2e30d4c diff --git a/.vimrc b/.vimrc index e3b5bfb..d871e09 100644 --- a/.vimrc +++ b/.vimrc @@ -56,7 +56,7 @@ colorscheme jellybeans set encoding=utf-8 "encoding to utf-8 set fileencoding=utf-8 "set encoding when opening files to utf-8 -set ch=2 " Make command line two lines high +set ch=1 " Make command line two lines high set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h12,DejaVu\ Sans\ Mono:h12,Menlo\ Regular\ for\ Powerline:h12,Monaco:h13 "use DejaVu Sans Mono for english on win/liunux, Monaco for mac set guifontwide=SimHei:h11,Monaco:h13 "use SimHei for Chinese, Monaco for mac set backspace=indent,eol,start " allow backspacing over everything in insert mode @@ -82,10 +82,6 @@ set wildignore+=*.sw? " Vim swap files set wildignore+=*.DS_Store " OSX bullshit set wildignore+=*.pyc " Python byte code set wildignore+=*.orig " Merge resolution files - -" Clojure/Leiningen -set wildignore+=classes -set wildignore+=lib set visualbell "flash screen when bell rings set cursorline "highline cursor line set ttyfast "indicate faster terminal connection @@ -94,7 +90,9 @@ set cpoptions+=J set nu " show line number set lbr " break the line by words set scrolloff=3 " show at least 3 lines around the current cursor position -set completeopt=longest,menu "set on the fly completion +set sidescroll=1 +set sidescrolloff=10 +set virtualedit+=block set mouse=a syntax on "set syntax color on set lazyredraw @@ -131,9 +129,10 @@ set autoindent " indent at the same level of the previous line set expandtab set shiftwidth=4 set softtabstop=4 +set textwidth=80 +set formatoptions=qrn1 +set colorcolumn=+1 -"space toggle folds!" -nnoremap za "use sane regx" set gdefault " the /g flag on :s substitutions by default nnoremap / /\v @@ -151,10 +150,28 @@ set smartcase " case sensitive when uc present "clearing highlighted search nmap / :nohlsearch -set wildignore+=*.pyc,.hg,.git +runtime macros/matchit.vim +map % + set matchtime=3 "Tenths of a second to show a matching pattern set showbreak=↪ " show break when the line is wraped. +" Keep search matches in the middle of the window and pulse the line when moving +" to them. +nnoremap n nzzzv +nnoremap N Nzzzv + +" Don't move on * +nnoremap * * + +" Same when jumping around +nnoremap g; g;zz +nnoremap g, g,zz + +" Window resizing +nnoremap 5> +nnoremap 5< + "switch between windows with leader key nnoremap h h nnoremap j j @@ -168,6 +185,178 @@ nnoremap tn :tabnext nnoremap tp :tabprev nnoremap tt :tabnew +"}}} + +" Various filetype-specific stuff ----------------------------------------- {{{ +" CSS and LessCSS {{{ + +augroup ft_css + au! + + au BufNewFile,BufRead *.less setlocal filetype=less + + au Filetype less,css setlocal foldmethod=marker + au Filetype less,css setlocal foldmarker={,} + au Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS + au Filetype less,css setlocal iskeyword+=- + + " 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 *.less,*.css 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 *.less,*.css inoremap { {}.kA +augroup END +" }}} +" HTML and HTMLDjango {{{ + +augroup ft_html + au! + + au BufNewFile,BufRead *.html setlocal filetype=htmldjango + au FileType html,jinja,htmldjango setlocal foldmethod=manual + + " Use f to fold the current tag. + au FileType html,jinja,htmldjango nnoremap f Vatzf + + " Use Shift-Return to turn this: + " | + " + " into this: + " + " | + " + au FileType html,jinja,htmldjango nnoremap vitavitoi + + " Smarter pasting + au FileType html,jinja,htmldjango nnoremap p :YRPaste 'p'v`]=`] + au FileType html,jinja,htmldjango nnoremap P :YRPaste 'P'v`]=`] + au FileType html,jinja,htmldjango nnoremap π :YRPaste 'p' + au FileType html,jinja,htmldjango nnoremap ∏ :YRPaste 'P' + + " Indent tag + au FileType html,jinja,htmldjango nnoremap = Vat= + + " Django tags + au FileType jinja,htmldjango inoremap {%%} + + " Django variables + au FileType jinja,htmldjango inoremap {{}} +augroup END + +" }}} +" Javascript {{{ + +augroup ft_javascript + au! + + au FileType javascript setlocal foldmethod=marker + au FileType javascript setlocal foldmarker={,} + + " 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 Filetype javascript inoremap { {}.kA +augroup END + +" }}} +" Markdown {{{ + +augroup ft_markdown + au! + + 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### +augroup END + +" }}} +" Nginx {{{ + +augroup ft_nginx + au! + + 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 + au BufRead,BufNewFile vhost.nginx set ft=nginx + + au FileType nginx setlocal foldmethod=marker foldmarker={,} +augroup END + +" }}} +" Python {{{ + +augroup ft_python + au! + + " au FileType python setlocal omnifunc=pythoncomplete#Complete + au FileType python setlocal define=^\s*\\(def\\\\|class\\) + au FileType python compiler nose + au FileType man nnoremap :q + + " Jesus tapdancing Christ, built-in Python syntax, you couldn't let me + " override this in a normal way, could you? + au FileType python if exists("python_space_error_highlight") | unlet python_space_error_highlight | endif + + " Jesus, Python. Five characters of punctuation for a damn string? + au FileType python inoremap _(u'') +augroup END + +" }}} +" Vim {{{ + +augroup ft_vim + au! + + au FileType vim setlocal foldmethod=marker + au FileType help setlocal textwidth=78 + au BufWinEnter *.txt if &ft == 'help' | wincmd L | endif +augroup END + +" }}} +" }}} +" +" Convenience mappings ---------------------------------------------------- {{{ + +" Change case +nnoremap gUiw +inoremap gUiwea + +" 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 + +" Better Completion +set completeopt=longest,menuone,preview +" }}} """""Plugins""""""""""" "------------Session--------------- let g:session_directory=$HOME.'/.vim/tmp/session'