【Ubuntu】常用Vim插件

  • Post author:
  • Post category:其他




一、YouCompleteMe

号称Vim中最好的

自动补全插件

,大名鼎鼎的YCM,不需多说。

只是最新版的YCM需要Linux中的gcc和g++支持C++17,且需要Vim版本为8.2.0及以上,需升级一下。

补全效果如下:
在这里插入图片描述



二、NERDTree

目录树插件,可以在Vim中直接看到

目录

,并打开

选中的文件

,效果如下图中的

左边栏



在这里插入图片描述



三、 highlight

语法高亮插件,可以使

STL中的类型名等

高亮,如string的效果如下(但貌似不能使

自己写的类

高亮):

在这里插入图片描述



四、vim-airline, vim-airline-themes,powerline-fonts


vim-airline

用于在Vim中美化

上下标签栏

(如下图中的

绿色

标签);但美化的主题需要通过

vim-airline-themes

下载;同时,想用如下图所示的小箭头标志的话,还要下载

powerline-fonts

以提供箭头字符的支持。最终效果如下:

在这里插入图片描述

上下绿色的标签就是vim-airline的作用了。如果用

NERDTree

打开多个标签,那么Vim的上边栏将是这个样子:

在这里插入图片描述



五、Vim更换主题


这个其实就不是插件了

。只要到github把喜欢的主题文件下载下来,把其中的颜色配置文件

xxx.vim

拷贝到

~/.vim/colors

文件夹中,然后在

~/.vimrc

中加入一行命令:

"xxx为颜色配置文件`xxx.vim`中的xxx"
colorscheme xxx 

就可以了。

如我用的

janah

主题颜色如下:







注:上面提到的所有Vim插件不止要下载,还要在

~/.vimrc

中配置一些选项。因此在这里附上我的

~/.vimrc

配置文件供大家参考:

set nocompatible              " be iMproved, required
filetype off                  " required

"设置编码"
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 
set termencoding=utf-8 
set encoding=utf-8

"如此设置,vim-airline可显示顶端左箭头" 
set t_Co=256
"set laststatus=2
"set lazyredraw
let g:airline_theme='powerlineish'
" 使用powerline打过补丁的字体
let g:airline_powerline_fonts=1
if !exists('g:airline_symbols')
    let g:airline_symbols={} 
endif
" 关闭空白符检测
let g:airline#extensions#whitespace#enabled=0


"语法高亮"
syntax on

"命令模式在底部显示"
set showcmd 

"显示行号"
set nu

"突出显示当前行"
set cul          "cursorline的缩写形式"

"显示括号匹配"
set showmatch

"设置缩进" "设置Tab长度为4空格"
set tabstop=4

"设置自动缩进长度为4空格"
set shiftwidth=4

"设置粘贴模式"
set nopaste

"总是显示状态栏"
set laststatus=2

"显示光标当前位置"
set ruler

"关掉 [草稿][预览]" set completeopt=noselect

"让vimrc配置变更立即生效"
autocmd BufWritePost $MYVIMRC source $MYVIMRC

"配色"
colorscheme janah


" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.  " Plugin 'ascenator/L9', {'name': 'newL9'}
Plugin 'Valloric/YouCompleteMe'

Plugin 'preservim/nerdtree'

Bundle 'taglist.vim'

Plugin 'octol/vim-cpp-enhanced-highlight'

Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" 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




"ycm相关"
let g:ycm_show_diagnostics_ui = 0
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings=1
let g:ycm_key_invoke_completion = '<c-z>'
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
 
"noremap <c-z> <NOP>
 
let g:ycm_semantic_triggers =  {
			\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
			\ 'cs,lua,javascript': ['re!\w{2}'],
			\ }


"vim-cpp-enhanced-highlight相关"
let g:cpp_class_decl_highlight = 1
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1

"vim-airline相关"
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_detect_modified = 1
let g:airline_detect_paste = 1

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!' 
let g:airline_theme='base16_bright'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1



版权声明:本文为qq_39642978原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。