@bergus
2017-02-15T16:15:26.000000Z
字数 7032
阅读 1802
vim
set nocompatible " be iMprovedfiletype off " required!" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vim" alternatively, pass a path where Vundle should install plugins" call vundle#begin('~/some/path/here')call vundle#begin()" let Vundle manage Vundle, requiredPlugin 'gmarik/Vundle.vim'Plugin 'Shougo/neocomplete.vim'Plugin 'majutsushi/tagbar.git'Plugin 'scrooloose/nerdtree.git'Plugin 'wincent/command-t'Plugin 'vim-airline/vim-airline'Plugin 'vim-airline/vim-airline-themes'Plugin 'nvie/vim-flake8'Plugin 'bash-support.vim'Bundle 'rking/ag.vim'Bundle 'scrooloose/syntastic'" thrift" Plugin 'solarnz/thrift.vim'" golang 插件" Plugin 'fatih/vim-go'"nim插件Bundle 'zah/nim.vim'"set runtimepath^=~/.vim/bundle/ag" requiredcall vundle#end()""""""""""""""""""""""""""""""""""""""""""" Jump to tagfun! JumpToDef()if exists("*GotoDefinition_" . &filetype)call GotoDefinition_{&filetype}()elseexe "norm! \<C-]>"endifendfnn <M-g> :call JumpToDef()<cr>ino <M-g> <esc>:call JumpToDef()<cr>i""""""""""""""""""""""""""""""""""""""""""" 代码自动提醒set tags=/usr/local/bin/ctags" requiredfiletype plugin indent on" To ignore plugin indent changes, instead use:"filetype plugin on"" Brief help" :PluginList - lists configured plugins" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate" :PluginSearch foo - searches for foo; append `!` to refresh local cache" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal"" see :h vundle for more details or wiki for FAQ" Put your non-Plugin stuff after this line"" 代码高亮用的let g:go_disable_autoinstall = 0let g:go_highlight_functions = 1let g:go_highlight_methods = 1let g:go_highlight_structs = 1let g:go_highlight_operators = 1let g:go_highlight_build_constraints = 1let g:go_fmt_command = "goimports" "保存的时候自动运行goimports" 自动补全自动启动let g:neocomplete#enable_at_startup = 1" 颜色配置colorscheme molokai" 标签分析let g:tagbar_type_go = {\ 'ctagstype' : 'go',\ 'kinds' : [\ 'p:package',\ 'i:imports:1',\ 'c:constants',\ 'v:variables',\ 't:types',\ 'n:interfaces',\ 'w:fields',\ 'e:embedded',\ 'm:methods',\ 'r:constructor',\ 'f:functions'\ ],\ 'sro' : '.',\ 'kind2scope' : {\ 't' : 'ctype',\ 'n' : 'ntype'\ },\ 'scope2kind' : {\ 'ctype' : 't',\ 'ntype' : 'n'\ },\ 'ctagsbin' : 'gotags',\ 'ctagsargs' : '-sort -silent'\ }" 标签映射execute "set <M-i>=\ei"execute "set <M-o>=\eo"execute "set <M-p>=\ep"execute "set <M-u>=\eu"execute "set <M-l>=\el"execute "set <M-n>=\en"execute "set <M-y>=\ey"execute "set <M-c>=\ec"nmap <M-p> :TagbarToggle<CR>imap <M-p> <esc>:TagbarToggle<CR>inmap <M-u> :NERDTreeToggle<CR>imap <M-u> <esc>:NERDTreeToggle<CR>nmap <C-c> :q<CR>nmap <M-o> :tabn<CR>imap <M-o> <esc>:tabn<CR>nmap <M-i> :tabp<CR>imap <M-i> <esc>:tabp<CR>nmap <M-l> :w<CR>:GoLint<CR>nmap <M-n> :GoDef<CR>nmap <C-z> :undo<CR>nmap <M-y> :GoErrCheck<CR>nmap <C-s> :w<CR>:GoMetaLinter<CR>imap <C-s> <esc>:w<CR>:GoMetaLinter<CR>imap <M-c> <esc>:pc<CR>nmap <M-c> :pc<CR>set backspace=indent,eol,start " 让backspace能正常工作的配置" 这是对PowerLine的设置set encoding=utf-8set laststatus=2let g:Powerline_symbols='unicode'" tab设置set ts=4set expandtab" 解决esc延迟问题set timeoutlen=1000 ttimeoutlen=0""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""实用设置""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""设置当文件被改动时自动载入set autoread"自动切换当前目录为当前文件所在的目录set autochdir"选中一段文字并全文搜索这段文字vmap <silent> ,/ y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>vmap <silent> ,? y?<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>"quickfix模式autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>"代码补全set completeopt=preview,menu"允许插件filetype plugin on"共享剪贴板set clipboard+=unnamed"从不备份set nobackup"make 运行:set makeprg=g++\ -Wall\ \ %"自动保存set autowriteset ruler " 打开状态栏标尺set cursorline " 突出显示当前行set magic " 设置魔术set guioptions-=T " 隐藏工具栏set guioptions-=m " 隐藏菜单栏set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\%{&encoding}\ %c:%l/%L%)\" 设置在状态行显示的信息set foldcolumn=0set foldmethod=indentset foldlevel=3" 开始折叠set foldenable" 不要使用vi的键盘模式,而是vim自己的set nocompatible" 语法高亮syntax enable" 去掉输入错误的提示声音"解决菜单乱码set encoding=utf-8"fileencodings需要注意顺序,前面的字符集应该比后面的字符集大set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1set imcmdlineset noeb" 在处理未保存或只读文件的时候,弹出确认set confirm" 自动缩进set autoindentset cindent" Tab键的宽度set tabstop=4" 统一缩进为4set softtabstop=4set shiftwidth=4" 不要用空格代替制表符set noexpandtab" 在行和段开始处使用制表符set smarttab" 显示行号set number" 历史记录数set history=1000"禁止生成临时文件set nobackupset noswapfile" 搜索忽略大小写set ignorecase" 搜索逐字符高亮set hlsearchset incsearch" 行内替换set gdefault" 编码设置set enc=utf-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936" 语言设置set langmenu=zh_CN.UTF-8set helplang=cn" 不自动换行set nowrap" 设置超过100字符自动换行set textwidth=100" 设置超过100列的字符带下划线au BufWinEnter * let w:m2=matchadd('Underlined', '\%>80v.\+', -1)syn match out80 /\%80v./ containedin=ALLhi out80 guifg=white guibg=red ctermfg=white ctermbg=red" 我的状态行显示的内容(包括文件类型和解码)" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}" 总是显示状态行set laststatus=2" 命令行(在状态行下)的高度,默认为1,这里是2set cmdheight=2" 侦测文件类型filetype on" 载入文件类型插件filetype plugin on" 为特定文件类型载入相关缩进文件filetype indent on" 保存全局变量set viminfo+=!" 带有如下符号的单词不要被换行分割set iskeyword+=_,$,@,%,#,-" 字符间插入的像素行数目set linespace=0" 增强模式中的命令行自动完成操作set wildmenu" 使回格键(backspace)正常处理indent, eol, start等set backspace=2" 允许backspace和光标键跨越行边界set whichwrap+=<,>,h,l" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)set mouse=aset selection=exclusiveset selectmode=mouse,key" 通过使用: commands命令,告诉我们文件的哪一行被改变过set report=0" 在被分割的窗口间显示空白,便于阅读set fillchars=vert:\ ,stl:\ ,stlnc:\" 高亮显示匹配的括号set showmatch" 匹配括号高亮的时间(单位是十分之一秒)set matchtime=1" 光标移动到buffer的顶部和底部时保持3行距离set scrolloff=3" 为C程序提供自动缩进set smartindent" 高亮显示普通txt文件(需要txt.vim脚本)au BufRead,BufNewFile * setfiletype txt"启动后最大化au GUIEnter * simalt ~x" 置粘贴模式,这样粘贴过来的程序代码就不会错位了。"set paste"设置字体if has("gui")if has("win32")"启动时会弹出字体选择框,如果取消,则采用系统默认字体set guifont=*"Windows默认使用的字体,字体较粗"set guifont=Fixedsys"中文显示变形,字体较粗"set guifont=Monospace:h9"中文显示变形,字体较细"set guifont=Consolas:h9"中文显示变形,字体较细"set guifont=Lucida\ Console:h9"中文显示变形,字体较细set guifont=Monaco:h9"中文显示变形,字体较细"set guifont=Andale\ Mono:h10"中文显示变形,字体较细"set guifont=Bitstream\ Vera\ Sans\ Mono:h9"需要运行修改版的gvim才能识别"set guifont=YaHei\ Consolas\ Hybrid:h9"如果guifontwide采用中文字体,汉字将自动使用guifontwide,英文自动使用guifontset guifontwide=YaHei\ Consolas\ Hybrid:h9elseset guifont=SimSun:h10endif"set columns=128 lines=36endif" 打开链接function! OpenUrl()let s:url = GetPatternAtCursor('\v(https?://|ftp://|file:/{3}|www\.)((\w|-)+\.)+(\w|-)+(:\d+)?(/(\w|[~@#$%^&+=/.?-])+)?')"echo s:urlif s:url == ""echohl WarningMsgechomsg '在光标处未发现URL!'echohl Noneelseif GetSystem() == "windows"call system("explorer " . s:url)elsecall system("firefox " . s:url . " &")endifendifunlet s:urlendfunctionnmap <C-LeftMouse> :call OpenUrl()<CR>set wildignore+=versions/*,cache/*"开启光亮光标行set cursorlinehi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white"开启高亮光标列set cursorcolumnhi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=whitelet g:airline_theme="luna""这个是安装字体后 必须设置此项"let g:airline_powerline_fonts = 1"打开tabline功能,方便查看Buffer和切换,这个功能比较不错""我还省去了minibufexpl插件,因为我习惯在1个Tab下用多个buffer"let g:airline#extensions#tabline#enabled = 1let g:airline#extensions#tabline#buffer_nr_show = 1"设置切换Buffer快捷键"nnoremap <C-N> :bn<CR>nnoremap <C-P> :bp<CR>" 关闭状态显示空白符号计数,这个对我用处不大"let g:airline#extensions#whitespace#enabled = 0let g:airline#extensions#whitespace#symbol = '!'set autochdir
