CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置 您所在的位置:网站首页 vundle安装代码补全插件 CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置

CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置

2023-10-20 23:49| 来源: 网络整理| 查看: 265

  备注:现在对于 YouCompleteMe 的安装应采用更为简单的方法,即利用 Vundle 来安装这个插件。具体方法可见:

  Vundle 主页

  YouCompleteMe 主页

  而 .vimrc 的设置如下即可:

CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置_bundleCentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置_bundle_02 1 " Vundle Setting 2 3 set nocompatible 4 filetype off 5 set rtp+=~/.vim/bundle/Vundle.vim 6 call vundle#begin() 7 8 " Let Vundle manage itself 9 Plugin 'gmarik/Vundle.vim' 10 " Plugins 11 Plugin 'Valloric/YouCompleteMe' 12 Plugin 'scrooloose/syntastic' 13 Plugin 'bling/vim-airline' 14 Plugin 'SirVer/ultisnips' 15 Plugin 'edsono/vim-matchit' 16 Plugin 'elzr/vim-json' 17 Plugin 'honza/vim-snippets' 18 Plugin 'justinmk/vim-sneak' 19 Plugin 'kien/ctrlp.vim' 20 Plugin 'ludovicchabant/vim-lawrencium' 21 Plugin 'majutsushi/tagbar' 22 Plugin 'mhinz/vim-signify' 23 Plugin 'plasticboy/vim-markdown' 24 Plugin 'scrooloose/nerdcommenter' 25 Plugin 'sjl/gundo.vim' 26 Plugin 'tpope/vim-sleuth' 27 Plugin 'tpope/vim-surround' 28 Plugin 'tpope/vim-fugitive' 29 Plugin 'tyru/open-browser.vim' 30 Plugin 'vim-scripts/a.vim' 31 32 " Color schemes 33 Plugin 'tomasr/molokai' 34 Plugin 'flazz/vim-colorschemes' 35 36 call vundle#end() 37 filetype plugin indent on 38 39 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 40 " => YouCompleteMe 代码自动补全 Begin 41 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 42 " Plugin 'Valloric/YouCompleteMe' 43 " youcompleteme 默认tab s-tab 和自动补全冲突 44 " let g:ycm_key_list_select_completion=[''] 45 " let g:ycm_key_list_select_completion = [''] 46 " let g:ycm_key_list_previous_completion=[''] 47 " let g:ycm_key_list_previous_completion = [''] 48 " let g:ycm_confirm_extra_conf=0 " 关闭加载.ycm_extra_conf.py提示 49 let g:ycm_complete_in_comments = 1 "在注释输入中也能补全 50 let g:ycm_complete_in_strings = 1 "在字符串输入中也能补全 51 let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎 52 let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全 53 let g:ycm_seed_identifiers_with_syntax=1 "语言关键字补全, 不过python关键字都很短,所以,需要的自己打开 54 let g:ycm_collect_identifiers_from_tags_files = 1 55 let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项 56 " 引入,可以补全系统,以及python的第三方包 针对新老版本YCM做了兼容 57 " old version 58 if !empty(glob("~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py")) 59 let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py" 60 endif 61 " new version 62 if !empty(glob("~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py")) 63 let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" 64 endif 65 "mapping 66 nmap gd :YcmDiags 67 nnoremap gl :YcmCompleter GoToDeclaration " 跳转到申明处 68 nnoremap gf :YcmCompleter GoToDefinition " 跳转到定义处 69 nnoremap gg :YcmCompleter GoToDefinitionElseDeclaration 70 " 直接触发自动补全 71 let g:ycm_key_invoke_completion = '' 72 " 黑名单,不启用 73 let g:ycm_filetype_blacklist = { 74 \ 'tagbar' : 1, 75 \ 'gitcommit' : 1, 76 \} 77 map :call SaveInputData() 78 func! SaveInputData() 79 exec "tabnew" 80 exec 'normal "+gP' 81 exec "w! /tmp/input_data" 82 endfunc 83 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 84 " => YouCompleteMe 代码自动补全 End 85 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 86 87 " 设置配色方案 88 colorscheme torte 89 " colorscheme murphy 90 " colorscheme desert 91 92 "字体 93 "if (has("gui_running")) 94 " set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 95 "endif 96 97 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 98 " 显示相关 99 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 100 "set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示 101 "winpos 5 5 " 设定窗口位置 102 "set lines=40 columns=155 " 设定窗口大小 103 set go= " 不要图形按钮 104 "color asmanian2 " 设置背景主题 105 "set guifont=Courier_New:h10:cANSI " 设置字体 106 "syntax on " 语法高亮 107 autocmd InsertLeave * se nocul " 用浅色高亮当前行 108 autocmd InsertEnter * se cul " 用浅色高亮当前行 109 "set ruler " 显示标尺 110 set showcmd " 输入的命令显示出来,看的清楚些 111 "set cmdheight=1 " 命令行(在状态行下)的高度,设置为1 112 "set whichwrap+=,h,l " 允许backspace和光标键跨越行边界(不建议) 113 "set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 114 set novisualbell " 不要闪烁(不明白) 115 set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 116 set laststatus=1 " 启动显示状态行(1),总是显示状态行(2) 117 set foldenable " 允许折叠 118 set foldmethod=manual " 手动折叠 119 "set background=dark "背景使用黑色 120 " 显示中文帮助 121 if version >= 603 122 set helplang=cn 123 set encoding=utf-8 124 endif 125 126 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 127 """""新文件标题 128 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 129 "新建.c,.h,.sh,.java文件,自动插入文件头 130 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 131 ""定义函数SetTitle,自动插入文件头 132 func SetTitle() 133 "如果文件类型为.sh文件 134 if &filetype == 'sh' 135 call setline(1,"\#########################################################################") 136 call append(line("."), "\# File Name: ".expand("%")) 137 call append(line(".")+1, "\# Author: xiehongfeng") 138 call append(line(".")+2, "\# mail: [email protected]") 139 call append(line(".")+3, "\# Created Time: ".strftime("%c")) 140 call append(line(".")+4, "\#########################################################################") 141 call append(line(".")+5, "\#!/bin/bash") 142 call append(line(".")+6, "") 143 else 144 call setline(1, "/*************************************************************************") 145 call append(line("."), " > File Name: ".expand("%")) 146 call append(line(".")+1, " > Author: xiehongfeng") 147 call append(line(".")+2, " > Mail: [email protected]") 148 call append(line(".")+3, " > Created Time: ".strftime("%c")) 149 call append(line(".")+4, " ************************************************************************/") 150 call append(line(".")+5, "") 151 endif 152 if &filetype == 'cpp' 153 call append(line(".")+6, "#include ") 154 call append(line(".")+7, "using namespace std;") 155 call append(line(".")+8, "") 156 endif 157 if &filetype == 'c' 158 call append(line(".")+6, "#include ") 159 call append(line(".")+7, "") 160 endif 161 " if &filetype == 'java' 162 " call append(line(".")+6,"public class ".expand("%")) 163 " call append(line(".")+7,"") 164 " endif 165 "新建文件后,自动定位到文件末尾 166 autocmd BufNewFile * normal G 167 endfunc 168 169 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 170 "键盘命令 171 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 172 nmap w :w! 173 nmap f :find 174 " 映射全选+复制 ctrl+a 175 map ggVGY 176 map! ggVGY 177 map gg=G 178 " 选中状态下 Ctrl+c 复制 179 vmap "+y 180 "去空行 181 nnoremap :g/^\s*$/d 182 "比较文件 183 nnoremap :vert diffsplit 184 "新建标签 185 map :tabnew 186 "列出当前目录文件 187 map :tabnew . 188 "打开树状文件目录 189 map \be 190 "C,C++ 按F5编译运行 191 map :call CompileRunGcc() 192 func! CompileRunGcc() 193 exec "w" 194 if &filetype == 'c' 195 exec "!g++ % -o %


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有