Skip to content

Instantly share code, notes, and snippets.

@agassiyzh
Created December 17, 2013 02:15
Show Gist options
  • Save agassiyzh/7998847 to your computer and use it in GitHub Desktop.
Save agassiyzh/7998847 to your computer and use it in GitHub Desktop.
set sh=/bin/bash
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/vundle/
endif
call vundle#rc(expand('~/.vim/bundle/'))
Bundle 'gmarik/vundle'
Bundle 'bling/vim-airline'
let g:airline_powerline_fonts = 1
Bundle 'Align'
Bundle 'The-NERD-Commenter'
Bundle 'bufexplorer.zip'
Bundle 'The-NERD-tree'
let NERDTreeIgnore=['bower_components', 'node_modules']
Bundle 'surround.vim'
Bundle 'Tagbar'
Bundle 'kchmck/vim-coffee-script.git'
Bundle 'Indent-Guides'
let g:indent_guides_guide_size=1
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-haml'
Bundle 'hallison/vim-markdown'
Bundle 'scrooloose/syntastic'
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-", "<html> proprietary attribute \"class"]
let g:syntastic_enable_signs=1
let g:syntastic_check_on_open=1
let g:syntastic_auto_loc_list=2
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11'
Bundle 'jmcantrell/vim-virtualenv'
let g:virtualenv_auto_activate=1
Bundle 'slim-template/vim-slim'
Bundle 'EasyMotion'
Bundle 'dbext.vim'
Bundle 'myhere/vim-nodejs-complete'
Bundle 'Stormherz/tablify'
Bundle 'SingleCompile'
let g:SingleCompile_alwayscompile = 0
call SingleCompile#ChooseCompiler('cpp', 'clang')
nmap <F9> :SCCompile<cr>
nmap <F10> :SCCompileRun<cr>
Bundle 'clang-complete'
let g:clang_complete_auto=0
Bundle 'mattn/gist-vim'
Bundle 'mattn/webapi-vim'
Bundle 'kien/ctrlp.vim'
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|bower_components'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NeoComplete
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Bundle 'Shougo/neocomplete.vim'
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left> neocomplete#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
"inoremap <expr><Up> neocomplete#close_popup() . "\<Up>"
"inoremap <expr><Down> neocomplete#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NeoSnippet
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Bundle 'Shougo/neosnippet.vim'
Bundle 'mattn/emmet-vim'
Bundle 'terryma/vim-multiple-cursors'
Bundle "pangloss/vim-javascript"
Bundle 'mklabs/grunt.vim'
Bundle 'digitaltoad/vim-jade'
" color theme
Bundle 'Diablo3'
Bundle 'sophacles/vim-processing'
Bundle 'DfrankUtil'
Bundle 'vim-scripts/vimprj'
"Bundle 'vim-scripts/indexer.tar.gz'
filetype plugin indent on
syntax on
" matchit.vim plugin
source $VIMRUNTIME/macros/matchit.vim
set history=400
if has('mouse')
set mouse=a
endif
set backspace=indent,eol,start
"set ruler " show the cursor position all the time
set nu
set showcmd " display incomplete commands
set incsearch " do incremental searching
set autoread
set iskeyword+='-'
set autoindent
set smartindent
set cindent
set ambiwidth=double
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set anti
set t_Co=256
"colorscheme desert
"colorscheme morning
"colorscheme diablo3
colorscheme Tomorrow-Night-Bright
"set cursorline
"hi cursorline ctermbg=NONE cterm=underline
set formatoptions+=mM
set helplang=cn
function! MySys()
if has("win32") || has("win64")
return "windows"
elseif has("mac")
return "mac"
else
return "linux"
endif
endfunction
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set backupdir=~/.vim/backups
set dir=~/.vim/backups
set nobackup
"set nowritebackup
set undodir=~/.vim/undos
set undofile
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set nowrap
set wildmenu
set matchpairs+=(:),{:},[:],<:>
set whichwrap=b,s,<,>,[,]
set foldmethod=syntax
set foldlevel=1
set diffopt+=iwhite,vertical " 忽略缩进的差异
"set cursorbind
"set gdefault
set so=7
"set rnu
set numberwidth=4
set equalalways
set guitablabel=%t
set laststatus=2
"set autochdir "自动进入编辑文件的目录
autocmd! bufwritepost .vimrc source ~/.vimrc
autocmd! bufwritepost vimrc source ~/.vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" filetype
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.vm setlocal ft=html
autocmd BufNewFile,BufRead *.xul setlocal ft=xml
autocmd BufNewFile,BufRead *.as setlocal ft=actionscript
autocmd BufNewFile,BufRead *.json setlocal ft=javascript
autocmd BufNewFile,BufRead *.pac setlocal ft=javascript
autocmd BufNewFile,BufRead *.ypac setlocal ft=yaml
autocmd BufNewFile,BufRead *.wsgi setlocal ft=python
autocmd BufNewFile,BufRead Podfile setlocal ft=ruby
autocmd BufNewFile,BufRead *.podspec setlocal ft=ruby
au FileType coffee setl foldmethod=indent foldlevel=0
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=2
" language support
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=79
autocmd FileType ruby setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType yaml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType xml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType html setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType coffee setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType php setlocal noexpandtab shiftwidth=4 tabstop=4 softtabstop=4
" turn on omnicompletion
set ofu=syntaxcomplete#Complete
" Omni Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
"" tags
"autocmd FileType php set tags=php_tags
"autocmd FileType javascript set tags=js_tags
"autocmd FileType python set tags=py_tags
"autocmd FileType php nnoremap <F12> :!ctags -R --exclude='/.git/' --languages=php --php-kinds=+cf-v --tag-relative=yes --totals=yes -f php_tags<cr>
"autocmd FileType javascript nnoremap <F12> :!ctags -R --exclude='/.git/' --languages=javascript --javascript-kinds=-v --tag-relative=yes --totals=yes -f js_tags<cr>
"autocmd FileType python nnoremap <F12> :!ctags -R --exclude='/.git/' --languages=python --python-kinds=-v --tag-relative=yes --totals=yes -f py_tags<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" map
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader=","
let g:mapleader=","
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
map <D-H> <C-h>
map <D-J> <C-j>
map <D-K> <C-k>
map <D-L> <C-l>
nnoremap <D-V> <C-w>v
noremap <leader>ee :e ~/.vimrc<cr>
noremap <leader>tb :TagbarToggle<cr>
noremap <silent><leader>nt :NERDTreeToggle<cr>
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv
"移动长行
nnoremap <Down> gj
nnoremap <Up> gk
map <silent><A-Right> :bn<CR>
map <silent><A-Left> :bp<CR>
let php_folding=1
noremap <silent> <Left> :bp<CR>
noremap <silent> <Right> :bn<CR>
nnoremap \ :!open <C-R>%<CR><CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment