Created
November 10, 2011 11:41
-
-
Save imxiaobo/1354671 to your computer and use it in GitHub Desktop.
Revisions
-
imxiaobo revised this gist
Nov 10, 2011 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ set nocompatible " be iMproved filetype off " required! @@ -246,6 +247,12 @@ augroup php autocmd BufReadPre,FileReadPre *.php set expandtab augroup END " Go code. augroup go autocmd BufReadPre,FileReadPre *.go set tabstop=4 autocmd BufReadPre,FileReadPre *.go set expandtab augroup END " Java code. augroup java autocmd BufReadPre,FileReadPre *.java set tabstop=4 @@ -542,13 +549,13 @@ autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType go set omnifunc=gocomplete#Complete autocmd FileType golang set omnifunc=gocomplete#Complete autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType java set completefunc=javacomplete#CompleteParamsInfo autocmd FileType java set omnifunc=javacomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType ruby set omnifunc=rubycomplete#Complete autocmd FileType sql set omnifunc=sqlcomplete#Complete autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags -
imxiaobo revised this gist
Nov 10, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -169,7 +169,7 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ function! CurDir() let curdir = substitute(getcwd(), '/Users/xiaobo/', "~/", "g") return curdir endfunction -
imxiaobo created this gist
Nov 10, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,602 @@ set nocompatible " be iMproved filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle " required! Bundle 'gmarik/vundle' filetype on filetype plugin indent on " required! func! MySys() return "mac" endfunc " General "{{{ set autowrite " Writes on make/shell commands set autoread " Modeline set modeline set modelines=5 " default numbers of lines to read for modeline instructions " Backup set nowritebackup set nobackup set directory=/tmp// " prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//) " Buffers set hidden " The current buffer can be put to the background without writing to disk " Match and search set hlsearch " highight search set ignorecase " Do case in sensitive matching with set smartcase " be sensitive when there's a capital letter set incsearch " " With a map leader it's possible to do extra key combinations " like <leader>w saves the current file let mapleader = "," let g:mapleader = "," " Fast saving nmap <leader>w :w!<cr> " Fast editing of the .vimrc map <leader>e :e! ~/.vimrc<cr> " When vimrc is edited, reload it autocmd! bufwritepost vimrc source ~/.vimrc " Turn backup off, since most stuff is in SVN, git anyway... set nobackup set nowb set noswapfile " "}}} " Formatting "{{{ set fo+=o " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. set fo-=r " Do not automatically insert a comment leader after an enter set fo-=t " Do no auto-wrap text using textwidth (does not apply to comments) set nowrap set textwidth=0 " Don't wrap lines by default set wildmode=longest,list " At command line, complete longest common string, then list alternatives. set backspace=indent,eol,start " more powerful backspacing set tabstop=4 " Set the default tabstop set softtabstop=4 set shiftwidth=4 " Set the default shift width for indents set expandtab " Make tabs into spaces (set by tabstop) set smarttab " Smarter tab levels set autoindent set cindent set cinoptions=:s,ps,ts,cs set cinwords=if,else,while,do,for,switch,case filetype on " Automatically detect file types. syntax enable " enable syntax " "}}} " Visual "{{{ set showfulltag " Get function usage help automatically set showcmd " Show current vim command in status bar set showmatch " Show matching parentheses/brackets set showmode " Show current vim mode set wildmenu " use a scrollable menu for filename completions set number " Show line number set mouse=a " Enable mouse in console set matchtime=5 " Bracket blinking. set laststatus=2 " Always show status line. set cmdheight=2 "The commandbar height set ruler " Show ruler set shortmess=atI " Shortens messages set nolist " Display unprintable characters f12 - switches set listchars=tab:·\ ,eol:¶,trail:·,extends:»,precedes:« " Unprintable chars mapping set foldenable " Turn on folding set foldmethod=marker " Fold on the marker set foldlevel=10 " Don't autofold anything (but I can still fold manually) set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds set splitbelow set splitright set hid "Change buffer - without saving " Set backspace config set backspace=eol,start,indent set whichwrap+=<,>,h,l set ignorecase "Ignore case when searching set smartcase set hlsearch "Highlight search things set incsearch "Make search act like search in modern browsers set nolazyredraw "Don't redraw while executing macros set magic "Set magic on, for regular expressions """""""""""""""""""""""""""""" " => Visual mode related """""""""""""""""""""""""""""" " Really useful! " In visual mode when you press * or # to search for the current selection vnoremap <silent> * :call VisualSearch('f')<CR> vnoremap <silent> # :call VisualSearch('b')<CR> " When you press gv you vimgrep after the selected text vnoremap <silent> gv :call VisualSearch('gv')<CR> map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left> function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Foo endfunction " From an idea by Michael Naumann function! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_reg endfunction " Always hide the statusline " set laststatus=2 " Format the statusline set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c function! CurDir() let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") return curdir endfunction function! HasPaste() if &paste return 'PASTE MODE ' else return '' endif endfunction " Color scheme Bundle "https://github.com/altercation/vim-colors-solarized.git" if has("gui_running") set background=light colorscheme solarized set guioptions-=T " Get rid of toolbar " endif " "}}} " Command and Auto commands " {{{ " Sudo write comm! W exec 'w !sudo tee % > /dev/null' | e! "Auto commands au BufRead,BufNewFile {Gemfile,Rakefile,Capfile,*.rake,config.ru} set ft=ruby au BufRead,BufNewFile {*.md,*.mkd,*.markdown} set ft=markdown au BufRead,BufNewFile {COMMIT_EDITMSG} set ft=gitcommit autocmd BufNewFile,BufReadPost *.go set ft=go au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | execute "normal g'\"" | endif " restore position in file " Enabled file type detection and file-type specific plugins. " Drupal *.module and *.engine files. augroup module autocmd BufRead *.module,*.engine set filetype=php augroup END " Python code. augroup python autocmd BufReadPre,FileReadPre *.py set tabstop=4 autocmd BufReadPre,FileReadPre *.py set expandtab augroup END " C/C++ code. augroup cpp autocmd BufReadPre,FileReadPre *.c,*.cpp,*.cxx,*.cc,*.h,*.hpp set tabstop=4 autocmd BufReadPre,FileReadPre *.c,*.cpp,*.cxx,*.cc,*.h,*.hpp set expandtab augroup END " Ruby code. augroup ruby autocmd BufReadPre,FileReadPre *.rb set tabstop=2 autocmd BufReadPre,FileReadPre *.rb set expandtab augroup END " Scala code. augroup scala autocmd BufReadPre,FileReadPre *.sacala set tabstop=2 autocmd BufReadPre,FileReadPre *.scala set expandtab augroup END " PHP code. augroup php autocmd BufReadPre,FileReadPre *.php set tabstop=4 autocmd BufReadPre,FileReadPre *.php set expandtab augroup END " Java code. augroup java autocmd BufReadPre,FileReadPre *.java set tabstop=4 autocmd BufReadPre,FileReadPre *.java set expandtab augroup END " ANT build.xml files. augroup xml autocmd BufReadPre,FileReadPre build.xml set tabstop=4 augroup END " (J)Flex files. augroup lex " autocmd BufRead,BufNewFile *.flex,*.jflex set filetype=lex autocmd BufRead,BufNewFile *.flex,*.jflex set filetype=jflex augroup END " (Nu)SMV files. augroup smv autocmd BufRead,BufNewFile *.smv set filetype=smv augroup END " " }}} " Key mappings " {{{ nnoremap <silent> <LocalLeader>rs :source ~/.vimrc<CR> nnoremap <silent> <LocalLeader>rt :tabnew ~/.vim/vimrc<CR> nnoremap <silent> <LocalLeader>re :e ~/.vim/vimrc<CR> nnoremap <silent> <LocalLeader>rd :e ~/.vim/ <CR> " Tabs nnoremap <silent> <LocalLeader>[ :tabprev<CR> nnoremap <silent> <LocalLeader>] :tabnext<CR> " Duplication vnoremap <silent> <LocalLeader>= yP nnoremap <silent> <LocalLeader>= YP " Buffers nnoremap <silent> <LocalLeader>- :bd<CR> " Split line(opposite to S-J joining line) nnoremap <silent> <C-J> gEa<CR><ESC>ew " map <silent> <C-W>v :vnew<CR> " map <silent> <C-W>s :snew<CR> nnoremap # :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR> nnoremap * # map <S-CR> A<CR><ESC> " " Control+S and Control+Q are flow-control characters: disable them in your terminal settings. " $ stty -ixon -ixoff noremap <C-S> :update<CR> vnoremap <C-S> <C-C>:update<CR> inoremap <C-S> <C-O>:update<CR> " " show/Hide hidden Chars map <silent> <F12> :set invlist<CR> " " generate HTML version current buffer using current color scheme map <silent> <LocalLeader>2h :runtime! syntax/2html.vim<CR> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Command mode related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Smart mappings on the command line cno $h e ~/ cno $d e ~/Desktop/ cno $j e ./ cno $c e <C-\>eCurrentFileDir("e")<cr> " $q is super useful when browsing on the command line cno $q <C-\>eDeleteTillSlash()<cr> " Bash like keys for the command line cnoremap <C-A> <Home> cnoremap <C-E> <End> cnoremap <C-K> <C-U> cnoremap <C-P> <Up> cnoremap <C-N> <Down> " Useful on some European keyboards map ½ $ imap ½ $ vmap ½ $ cmap ½ $ func! Cwd() let cwd = getcwd() return "e " . cwd endfunc func! DeleteTillSlash() let g:cmd = getcmdline() if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "") endif if g:cmd == g:cmd_edited if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "") endif endif return g:cmd_edited endfunc func! CurrentFileDir(cmd) return a:cmd . " " . expand("%:p:h") . "/" endfunc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Parenthesis/bracket expanding """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" vnoremap $1 <esc>`>a)<esc>`<i(<esc> vnoremap $2 <esc>`>a]<esc>`<i[<esc> vnoremap $3 <esc>`>a}<esc>`<i{<esc> vnoremap $$ <esc>`>a"<esc>`<i"<esc> vnoremap $q <esc>`>a'<esc>`<i'<esc> vnoremap $e <esc>`>a"<esc>`<i"<esc> " Map auto complete of (, ", ', [ inoremap $1 ()<esc>i inoremap $2 []<esc>i inoremap $3 {}<esc>i inoremap $4 {<esc>o}<esc>O inoremap $q ''<esc>i inoremap $e ""<esc>i inoremap $t <><esc>i """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General Abbrevs """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Editing mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Remap VIM 0 map 0 ^ "Move a line of text using ALT+[jk] or Comamnd+[jk] on mac nmap <M-j> mz:m+<cr>`z nmap <M-k> mz:m-2<cr>`z vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z if MySys() == "mac" nmap <D-j> <M-j> nmap <D-k> <M-k> vmap <D-j> <M-j> vmap <D-k> <M-k> endif "Delete trailing white space, useful for Python ;) func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc autocmd BufWrite *.py :call DeleteTrailingWS() set guitablabel=%t """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Pressing ,ss will toggle and untoggle spell checking map <leader>ss :setlocal spell!<cr> "Shortcuts using <leader> map <leader>sn ]s map <leader>sp [s map <leader>sg zg map <leader>s? z= """""""""""""""""""""""""""""" " => Python section """""""""""""""""""""""""""""" let python_highlight_all = 1 au FileType python syn keyword pythonDecorator True None False self au BufNewFile,BufRead *.jinja set syntax=htmljinja au BufNewFile,BufRead *.mako set ft=mako au FileType python inoremap <buffer> $r return au FileType python inoremap <buffer> $i import au FileType python inoremap <buffer> $p print au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi au FileType python map <buffer> <leader>1 /class au FileType python map <buffer> <leader>2 /def au FileType python map <buffer> <leader>C ?class au FileType python map <buffer> <leader>D ?def """""""""""""""""""""""""""""" " => JavaScript section """"""""""""""""""""""""""""""" au FileType javascript call JavaScriptFold() au FileType javascript setl fen au FileType javascript setl nocindent au FileType javascript imap <c-t> AJS.log();<esc>hi au FileType javascript imap <c-a> alert();<esc>hi au FileType javascript inoremap <buffer> $r return au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi function! JavaScriptFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend function! FoldText() return substitute(getline(v:foldstart), '{.*', '{...}', '') endfunction setl foldtext=FoldText() endfunction " " }}} " Plugins " {{{ Bundle "AutoComplPop" Bundle "c.vim" Bundle "comments.vim" Bundle "Cpp11-Syntax-Support" Bundle "dbext.vim" Bundle "javacomplete" Bundle "opencl.vim" Bundle "project.tar.gz" Bundle "scala.vim" Bundle "SuperTab" Bundle "virtualenv.vim" Bundle "bash-support.vim" Bundle "https://github.com/digitaltoad/vim-jade.git" Bundle "https://github.com/fholgado/minibufexpl.vim.git" Bundle "https://github.com/garbas/vim-snipmate.git" Bundle "https://github.com/godlygeek/tabular.git" Bundle "https://github.com/hail2u/vim-css3-syntax.git" Bundle "https://github.com/hallettj/jslint.vim.git" Bundle "https://github.com/honza/snipmate-snippets.git" Bundle "https://github.com/int3/vim-taglist-plus.git" Bundle "https://github.com/jnwhiteh/vim-golang.git" Bundle "https://github.com/klen/python-mode.git" Bundle "https://github.com/MarcWeber/vim-addon-mw-utils.git" Bundle "https://github.com/mileszs/ack.vim.git" Bundle "https://github.com/mmalecki/vim-node.js.git" Bundle "https://github.com/msanders/cocoa.vim.git" Bundle "https://github.com/othree/html5.vim.git" Bundle "https://github.com/Rip-Rip/clang_complete.git" Bundle "https://github.com/scrooloose/nerdcommenter.git" Bundle "https://github.com/scrooloose/nerdtree.git" Bundle "https://github.com/tomtom/tlib_vim.git" Bundle "https://github.com/tpope/vim-abolish.git" Bundle "https://github.com/tpope/vim-bundler.git" Bundle "https://github.com/tpope/vim-ragtag.git" Bundle "https://github.com/tpope/vim-rails.git" Bundle "https://github.com/tpope/vim-rake.git" Bundle "https://github.com/tpope/vim-rvm.git" Bundle "https://github.com/tpope/vim-surround.git" Bundle "https://github.com/vim-ruby/vim-ruby.git" Bundle "https://github.com/vim-scripts/Autoproject.git" Bundle "https://github.com/vim-scripts/JSON.vim.git" Bundle "https://github.com/wavded/vim-stylus.git" Bundle "https://github.com/wincent/Command-T.git" Bundle "https://github.com/tmallen/proj-vim.git" " " }}} "Plugin Configs" {{{ " Clang Complete let g:clang_user_options = '-std=c++0x -stdlib=libc++ -fblocks -fexceptions -I/usr/local/include' let g:clang_use_library=1 let g:clang_library_path="/Developer/usr/clang-ide/lib" let g:clang_complete_copen=1 let g:clang_periodic_quickfix=1 let g:clang_snippets=1 let g:clang_complete_macros=1 let g:clang_complete_patterns=1 " Omni Complete set ofu=syntaxcomplete#Complete autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType go set omnifunc=gocomplete#Complete autocmd FileType golang set omnifunc=gocomplete#Complete autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd Filetype java set completefunc=javacomplete#CompleteParamsInfo autocmd Filetype java set omnifunc=javacomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType ruby set omnifunc=rubycomplete#Complete autocmd FileType sql set omnifunc=sqlcomplete#CompletePHP autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags " Add recently accessed projects menu (project plugin) set viminfo^=! " Minibuffer Explorer Settings let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 " alt+n or alt+p to navigate between entries in QuickFix map <silent> <m-p> :cp <cr> map <silent> <m-n> :cn <cr> " CTags map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> """""""""""""""""""""""""""""" " => Command-T """""""""""""""""""""""""""""" let g:CommandTMaxHeight = 15 set wildignore+=*.o,*.obj,.git,*.pyc noremap <leader>j :CommandT<cr> noremap <leader>y :CommandTFlush<cr> """""""""""""""""""""""""""""" " => Vim grep """""""""""""""""""""""""""""" let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated' set grepprg=/bin/grep\ -nH """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => MISC """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm "Quickly open a buffer for scripbble map <leader>q :e ~/buffer<cr> au BufRead,BufNewFile ~/buffer iab <buffer> xh1 =========================================== map <leader>pp :setlocal paste!<cr> map <leader>bb :cd ..<cr> " "}}}