Created
July 1, 2017 07:15
-
-
Save houming818/cd69fc331c24cc87ac8b4594e9d6ad6e to your computer and use it in GitHub Desktop.
vimrc配置,支持语言Python,Golang,JavaScript,HTML,CSS.
This file contains 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 characters
""""""""""""""""""""""""""""""""" | |
" BEGIN OF VIMRC " | |
" Author: stduolc " | |
" Email: [email protected] " | |
" Version: 1.0 " | |
""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""" | |
" INIT " | |
" 初始化 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
let iCanHazVundle=1 | |
let vundle_readme=expand('~/.vim/bundle/vundle/README.md') | |
if !filereadable(vundle_readme) | |
echo "Installing Vundle..." | |
echo "" | |
silent !mkdir -p ~/.vim/bundle | |
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle | |
let iCanHazVundle=0 | |
endif | |
"" Installing plugins at first time | |
if iCanHazVundle == 0 | |
echo "Installing Bundles, please ignore key map error messages" | |
echo "" | |
:BundleInstall | |
endif | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" IMPORT BUNDLES " | |
" 导入Bundles " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
"" required! | |
"" let Vundle manage Vundle | |
Bundle 'gmarik/vundle' | |
"" Themes Bundles | |
Bundle 'flazz/vim-colorschemes' | |
"" Tools Bundles | |
"" Files browser | |
Bundle 'scrooloose/nerdtree' | |
"" Git support | |
Bundle 'tpope/vim-fugitive' | |
"" Git support | |
Bundle 'vim-gitgutter' | |
"" Ctags support | |
Bundle 'xolox/vim-misc' | |
"" Ctags support | |
Bundle 'xolox/vim-easytags' | |
"" Ctags support | |
Bundle 'taglist.vim' | |
"" Ctags support | |
Bundle 'tagbar' | |
"" OptimizeCodeSpeed Bundles | |
"" Autocomplete with tab | |
Bundle 'ervandew/supertab' | |
"" Autocomplete characters with pair | |
Bundle 'Auto-Pairs' | |
"" Autocommenter code | |
Bundle 'scrooloose/nerdcommenter' | |
"" Langauge Bundles | |
"" Python support | |
"Bundle 'python-imports.vim' | |
Bundle 'python-mode/python-mode' | |
"" JavaScript support | |
"Bundle 'Javascript-OmniCompletion-with-YUI-and-j' | |
"Bundle 'JavaScript-Indent' | |
"Bundle 'jslint.vim' | |
"Bundle 'jsbeautify' | |
"Bundle 'Better-Javascript-Indentation' | |
Bundle "pangloss/vim-javascript" | |
"" SQL support | |
"Bundle 'SQLComplete.vim' | |
"" Golang support | |
Bundle 'fatih/vim-go' | |
"" Syntastic Bundles | |
Bundle 'vim-syntastic/syntastic' | |
"" Other Bundles | |
Bundle 'last_edit_marker.vim' | |
Bundle 'synmark.vim' | |
"Bundle 'Vim-Script-Updater' | |
"Bundle 'FredKSchott/CoVim' | |
"" Ctrlp support | |
"Bundle 'ctrlp.vim' | |
"Bundle 'ctrlp-modified.vim' | |
"Bundle 'tacahiroy/ctrlp-funky' | |
""}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR BUNDLES " | |
" Bundles相关设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
filetype plugin indent on " required! | |
"" settings for 'xolox/vim-easytags' | |
:autocmd FileType python let b:easytags_auto_highlight = 0 | |
:let g:easytags_cmd = '/usr/bin/ctags' | |
:let g:easytags_opts = ['--languages=-all','--languages=+python','--languages=+javascript'] | |
:let g:easytags_async = 1 | |
:let g:easytags_file = '~/.vim/tags' | |
"" settings for 'ctrlp.vim' | |
"let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' | |
"let g:ctrlp_custom_ignore = '\v\.(exe|so|dll)$' | |
"let g:ctrlp_extensions = ['funky'] | |
"map <leader>. :CtrlPTag<CR> | |
"map <leader>p :CtrlPMixed<CR> | |
"" settings for python-mode | |
set completeopt=menu | |
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif | |
autocmd InsertLeave * if pumvisible() == 0|pclose|endif | |
let g:pymode_rope = 1 | |
let g:pymode_rope_lookup_project = 1 | |
let g:pymode_rope_complete_on_dot = 1 | |
let g:pymode_rope_autoimport = 0 | |
let g:jedi#smart_auto_mappings = 0 | |
"" settings for html | |
let g:html_indent_inctags = "html,body,head,tbody" | |
let g:html_indent_script1 = "inc" | |
let g:html_indent_style1 = "inc" | |
"" settings of ctags Ctags的设定 | |
"" 设置tags | |
set autochdir | |
set tags+=$VIM/tags | |
"" set the taglist 默认打开Taglist | |
"let Tlist_Auto_Open=1 | |
let Tlist_Ctags_Cmd = '/usr/bin/ctags' | |
let Tlist_Show_One_File = 1 " 不同时显示多个文件的tag,只显示当前文件的 | |
let Tlist_File_Fold_Auto_Close = 1 " 不同时显示多个文件的tag,只显示当前文件的 | |
let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一个窗口,则退出vim | |
let Tlist_Use_Right_Window = 1 " 在右侧窗口中显示taglist窗口 | |
let Tlist_Sort_Type = 'name' " 按照名称排序 | |
let Tlist_Use_Right_Window = 1 " 在右侧显示窗口 | |
let Tlist_Compart_Format = 1 " 压缩方式 | |
let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer | |
"let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags | |
"let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树 | |
"let Tlist_Show_One_File=1 " 不同时显示多个文件的tag,只显示当前文件的 | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR UNKNOWN " | |
" 不知道怎么归类的设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
set viminfo+=! " 保存全局变量 | |
set lbr | |
set fo+=mB | |
set sm | |
set undofile | |
silent !mkdir ~/.undodir > /dev/null 2>&1 | |
set undodir=~/.undodir | |
"" 允许插件 | |
filetype plugin on | |
"" 共享剪贴板 | |
"set clipboard+=unnamed | |
set ruler " 打开状态栏标尺 | |
set guioptions-=T " 隐藏工具栏 | |
set guioptions-=m " 隐藏菜单栏 | |
set nocompatible " 不要使用vi的键盘模式,而是vim自己的 | |
set noeb " 去掉输入错误的提示声音 | |
set confirm " 在处理未保存或只读文件的时候,弹出确认 | |
set nobackup " 禁止生成临时文件 | |
set noswapfile " 禁止生成临时文件 | |
set linespace=0 | |
set wildmenu " 增强模式中的命令行自动完成操作 | |
set backspace=2 " 使回格键(backspace)正常处理indent, eol, start等 | |
"set mouse=a " enable mouse | |
set selection=exclusive | |
set selectmode=key | |
set report=0 " 通过使用: commands命令,告诉我们文件的哪一行被改变过 | |
"" 在被分割的窗口间显示空白,便于阅读 | |
set fillchars=vert:\ ,stl:\ ,stlnc:\ | |
set showmatch " 高亮显示匹配的括号 | |
set matchtime=1 " 匹配括号高亮的时间(单位是十分之一秒) | |
set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | |
"" Settings for editor | |
set foldenable " allow foldenable 允许折叠 | |
set foldmethod=syntax | |
set foldcolumn=0 | |
"set foldlevel=3 | |
"set foldmethod=manual " set foldenable to menual 手动折叠 | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.png,*.jpg,*.gif | |
"" 自动载入 | |
set autoread | |
"" 自动保存 | |
set autowrite | |
"" 代码补全 | |
set completeopt=menu | |
"" don't cover the edit buffer 粘贴不覆盖缓冲区 | |
xnoremap p pgvy | |
"" settings for searching 搜索相关设置 | |
"" 关闭环绕式搜索 | |
set nowrapscan | |
"" 搜索忽略大小写 | |
"set ignorecase | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR FILETYPE " | |
" 文件类型相关的设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
syntax on " | |
filetype on " 侦测文件类型 | |
filetype plugin on " 载入文件类型插件 | |
filetype indent on " 为特定文件类型载入相关缩进文件 | |
filetype plugin indent on " 打开文件类型检测, 加了这句才可以用智能补全 | |
:autocmd FileType php setlocal dict+=~/.vim/dict/php_funclist.dict | |
:autocmd FileType css setlocal dict+=~/.vim/dict/css.dict | |
:autocmd FileType c setlocal dict+=~/.vim/dict/c.dict | |
:autocmd FileType cpp setlocal dict+=~/.vim/dict/cpp.dict | |
:autocmd FileType scale setlocal dict+=~/.vim/dict/scale.dict | |
:autocmd FileType javascript setlocal dict+=~/.vim/dict/javascript.dict | |
:autocmd FileType javascript setlocal dict+=~/.vim/dict/css.dict | |
:autocmd FileType html setlocal dict+=~/.vim/dict/javascript.dict | |
:autocmd FileType html setlocal dict+=~/.vim/dict/css.dict | |
:autocmd FileType vim set foldmethod=marker | |
":autocmd BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=mkd | |
":autocmd BufRead,BufNewFile *.{go} set filetype=go | |
":autocmd BufRead,BufNewFile *.{js} set filetype=javascript | |
":autocmd BufRead,BufNewFile *.{html} set filetype=html | |
"set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割 | |
"" syntastic相关 | |
"let g:syntastic_python_checkers=['pylint'] | |
"" golang support | |
"let g:fencview_autodetect=0 | |
"set rtp+=$GOROOT/misc/vim | |
""}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR STYLES " | |
" 样式设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
"" choose the default colorscheme | |
colorscheme molokai | |
let g:molokai_original = 1 | |
"" settings for cursor 光标相关设置 | |
"" highlight for cursor | |
set cursorline | |
autocmd InsertLeave * set cursorline | |
autocmd InsertEnter * set nocursorline | |
set cursorcolumn | |
autocmd InsertLeave * set cursorcolumn | |
autocmd InsertEnter * set nocursorcolumn | |
"" settings for colors | |
set t_Co=256 " set the color bits | |
set go= " I don't know what is this | |
set ruler " show the ruler but not effective | |
"set showcmd " show the command, set to off if the terminal is slow | |
"set whichwrap+=<,>,h,l " allow the cursor move cross line, not recommend for default | |
set laststatus=2 " 2 stand for always show the statusline | (1)启动显示状态行 (2)总是显示状态行 | |
set nocompatible " I don't know what is this. 去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 | |
set autoindent " 自动缩进 | |
set cindent | |
"" settings for height or width | |
set smarttab " 在行和段开始处使用制表符 | |
set expandtab " 使用空格代替制表符 | |
set smartindent | |
set tabstop=4 | |
set shiftwidth=4 | |
set ts=4 | |
set softtabstop=4 " 统一缩进为4 | |
set shiftwidth=4 | |
set scrolloff=3 " set the margin to 3 lines 光标移动到buffer的顶部和底部时保持3行距离 | |
set cmdheight=1 " set the command height to 1 line | |
set number | |
set history=1000 | |
set hlsearch | |
set incsearch | |
set langmenu=zh_CN.UTF-8 | |
set helplang=cn | |
" settings of status line format status line格式 | |
set statusline= | |
set statusline+=%7*\|b:%n "buffernr | |
set statusline+=%3*\|%{''.(&fenc!=''?&fenc:&enc).''} "Encoding | |
set statusline+=%2*\|ft:%y "FileType | |
set statusline+=%4*\|%{&ff} "FileFormat (dos/unix..) | |
set statusline+=%1*\ \@%<%F "File+path | |
set statusline+=%8*\ %=\ row:(%03p%%)%l/%L\ \ "Rownumber/total (%) | |
set statusline+=%9*\ col:%03c\ "Colnr | |
set statusline+=%0*\ \ %m%r%w\ %P\ \ "Modified? Readonly? Top/bot. | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR KEY MAP " | |
" 快捷键设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
let mapleader="," | |
"" Toggle KeyMap | |
"" Toggle for NERDComment | 快速注释 | |
nmap <Leader>c <plug>NERDCommenterToggle | |
"" toggle for show line numbers | |
"" 行号显示开关 | |
nmap <Leader>N :set invnumber<CR> | |
"" toggle for the paste support | |
"" 粘贴模式开关 | |
:set pastetoggle=<Leader>y | |
"" tagbar toggle | |
"" tags窗口开关 | |
nmap <leader>T :TagbarToggle<CR> | |
"" toggle for nerdtree | |
"" 目录窗口开关 | |
nmap <leader>t :NERDTreeToggle<CR> | |
"" key map for fast edit | |
"" delete the empty lines | 去空行 | |
imap <C-d> <ESC>:g/^\s*$/d<CR>i | |
"" key map for wins, buffers, tabs | 切换快捷键 | |
"" win类 | |
nmap <C-h> <C-W><Left> | |
nmap <C-l> <C-W><Right> | |
nmap <C-j> <C-W><Down> | |
nmap <C-k> <C-W><Up> | |
nmap <leader>o :on!<CR> | |
"" buffer类 | |
nmap <leader>l :ls<CR> | |
nmap <leader>p :bp!<CR> | |
nmap <leader>n :bn!<CR> | |
"" tab类 | |
nmap <Tab> :tabn<CR> | |
nmap <F4> :tabclose<CR> | |
"" key map for tags | |
"" tags快捷键 | |
"nmap tl :Tlist<cr> | |
let NERDTreeRespectWildIgnore=1 | |
"" key-map for python-mode | |
"" KeyMap for fold | |
nmap zz za | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR AUTOCMD " | |
" 自动执行命令设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
"" Goto position of last edit | |
if has("autocmd") | |
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | |
\| exe "normal! g'\"" | endif | |
endif | |
"" 当打开vim且没有文件时自动打开NERDTree | |
:autocmd vimenter * if !argc() | NERDTree | endif | |
"" 只剩NERDTree时自动关闭 | |
:autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
"" quickfix模式 | |
"autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR LANGUAGE " | |
" 语言相关设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
"" Python Support | |
"" 补全 | |
" let g:pymode_python = 'python3' | |
" let g:syntastic_python_python_exec = '/usr/bin/python3' | |
let g:pydiction_location = '~/.vim/after/complete-dict' | |
let g:pydiction_menu_height = 20 | |
let g:miniBufExplMapWindowNavVim = 1 | |
let g:miniBufExplMapWindowNavArrows = 1 | |
let g:miniBufExplMapCTabSwitchBufs = 1 | |
let g:miniBufExplModSelTarget = 1 | |
" set iskeyword+=. | |
set termencoding=utf-8 | |
set encoding=utf8 | |
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030 | |
autocmd FileType python set omnifunc=pythoncomplete#Complete | |
"set nocompatible " be iMproved | |
"filetype off " required! | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" SETTINGS FOR FUNCTIONS " | |
" 函数设置 " | |
""""""""""""""""""""""""""""""""" | |
"{{{ | |
" func FormartSrc() | |
" exec "w" | |
"" if &filetype == 'py'||&filetype == 'python' | |
" exec "r !autopep8 -i --aggressive %" | |
"" elseif &filetype == 'java' | |
" exec "!astyle --style=java --suffix=none %" | |
"" elseif &filetype == 'jsp' | |
" exec "!astyle --style=gnu --suffix=none %" | |
"" elseif &filetype == 'xml' | |
" exec "!astyle --style=gnu --suffix=none %" | |
"" else | |
" exec "normal gg=G" | |
"" return | |
"" endif | |
" exec "e! %" | |
" endfunc | |
"}}} | |
""""""""""""""""""""""""""""""""" | |
" END OF VIMRC " | |
""""""""""""""""""""""""""""""""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment