Ubuntu vim 插件配置
最近在学习使用vim,想要改善一下vim的工作环境,所以配置了一下vim的插件,感觉还是很nice的。
(1)配置过程
安装ctags,其他插件依赖该插件
sudo apt-get install ctags
#vim插件apt-vim管理:)
curl -sL https://raw.githubusercontent.com/egalpin/apt-vim/master/install.sh | sh
#(github地址是这个:https://github.com/egalpin/apt-vim)
#安装nerdtree#文件列表
apt-vim install -y https://github.com/scrooloose/nerdtree.git
#安装YouCompleteMe#自动补全工具
apt-vim install -y https://github.com/Valloric/YouCompleteMe.git#自动安装
#如果YouCompleteMe无法正常使用执行(一般运行上一条命令如果无法使用,会有提示,按照提示做就好了)
#执行该命令来更新子模组
git submodule update --init --recursive
#进行安装
cd /home/username/.vim/bundle/YouCompleteMe #username 是你的用户名
./install.py --clang-completer#安装完三方库后,手动安装
(2)根据需要配置插件(直接接在.vimrc文件的最后就可以了)
gedit~ / .vimrc
syntax on"语法高亮
set mouse=a " always use mouse
set number"显示行号
"自动缩进与C语言风格缩进
set autoindent
set cindent
"缩进宽度
set tabstop=4
set softtabstop=4
set shiftwidth=4
"switch case 对齐风格
set cino=g0,:0
"Tagbar
let g:tagbar_width=35 "宽度
let g:tagbar_ctags_bin='/usr/bin/ctags' "设置tagbar使用的ctags的插件
let g:tagbar_right=1 "位置在右侧
let g:tagbar_autofocus=0 "是否自动聚焦
autocmd BufReadPost *.cpp,*.c,*.h,*.hpp,*.cc,*.cxx call tagbar#autoopen() "打开文件自动打开tagbar
nmap <F6> :TagbarToggle<CR> "快捷键
" NERD tree
let NERDChristmasTree=0
let NERDTreeWinSize=35
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="left"
" Automatically open a NERDTree if no files where specified
autocmd vimenter * if !argc() | NERDTree | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Open a NERDTree
nmap <F5> :NERDTreeToggle<cr>
"YouCompleteMe
"自动开启语义补全
let g:ycm_seed_identifiers_with_syntax = 1
"在注释中也开启补全
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
"字符串中也开启补全
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_tags_files = 1
"开启基于tag的补全,可以在这之后添加需要的标签路径
let g:ycm_collect_identifiers_from_tags_files = 1
"开始补全的字符数
let g:ycm_min_num_of_chars_for_completion = 2
"补全后自动关闭预览窗口
let g:ycm_autoclose_preview_window_after_completion = 1
"禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
"离开插入模式后自动关闭预览窗口
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"语法关键字补全
let g:ycm_seed_identifiers_with_syntax = 1
"在实现和声明之间跳转,并分屏打开
let g:ycm_goto_buffer_command = 'horizontal-split'
nnoremap <Leader>g :YcmCompleter GoTo<CR>
execute pathogen#infect()
call pathogen#helptags()
然后,执行vim就可以看到界面已经发生变化了。
posted on 2022-08-13 16:15 DylanYeung 阅读(112) 评论(0) 编辑 收藏 举报