1、vim: Vundle
https://linux.cn/article-9416-1.html
如何在 Linux 上使用 Vundle 管理 Vim 插件
1.1 添加插件,以vim-dasm为例:
#vim ~/.vimrc
添加这一行:
[…]
Plugin ‘vim-dasm’
[…]
1.2 安装插件:
:PluginInstall
1.3 安装完毕之后,键入下列命令,可以删除高速缓存区缓存并关闭窗口:
:bdelete
1.4 搜索可以使用的插件:
:PluginSearch
1.5 要从 vimscripts 网站刷新本地的列表,请在命令之后添加 !。
:PluginSearch!
1.6 你还可以通过直接指定插件名的方式,缩小搜索范围。
:PluginSearch vim
这样将会列出包含关键词 “vim” 的插件。
[hillstone@hillstone Linux_MAIN]$ cat ~/.vimrc
set nocompatible " be iMproved, required
filetype off " required
" 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.
"++++++++++++++++++++++++++++++++++
" <1 github 仓库中的插件> "
"Plugin 'VundleVim/Vundle.vim'
" Plugin 'Valloric/YouCompleteMe'
Plugin 'ycm-core/YouCompleteMe'
" autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口"
" let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM基于标签引擎
" let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
" let g:syntastic_ignore_files=[".*\.py$"]
" let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
" let g:ycm_complete_in_comments = 1
" let g:ycm_confirm_extra_conf = 0 " 关闭加载.ycm_extra_conf.py提示
" let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
" let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
" let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
" let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
" let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
" let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
" let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
" inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" " 回车即选中当前项
" nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
" let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
"
Plugin 'majutsushi/tagbar' "显示文件的类、函数、变量"
Plugin 'MattesGroeger/vim-bookmarks'
Plugin 'vim-airline/vim-airline'
"vim-airline配置:优化vim界面"
"let g:airline#extensions#tabline#enabled = 1
" airline设置
" 显示颜色
set t_Co=256
set laststatus=2
" 使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
" 开启tabline
let g:airline#extensions#tabline#enabled = 1
" tabline中当前buffer两端的分隔字符
let g:airline#extensions#tabline#left_sep = ' '
" tabline中未激活buffer两端的分隔字符
let g:airline#extensions#tabline#left_alt_sep = ' '
" tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
" 映射切换buffer的键位
nnoremap [b :bp<CR>
nnoremap ]b :bn<CR>
" 映射<leader>num到num buffer
map <leader>1 :b 1<CR>
map <leader>2 :b 2<CR>
map <leader>3 :b 3<CR>
map <leader>4 :b 4<CR>
map <leader>5 :b 5<CR>
map <leader>6 :b 6<CR>
map <leader>7 :b 7<CR>
map <leader>8 :b 8<CR>
map <leader>9 :b 9<CR>
" vim-scripts 中的插件 "
Plugin 'taglist.vim'
"ctags 配置:F3快捷键显示程序中的各种tags,包括变量和函数等。
map <F3> :TlistToggle<CR>
let Tlist_Use_Right_Window=1
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_WinWidt=25
Plugin 'The-NERD-tree'
"NERDTree 配置:F2快捷键显示当前目录树
map <F2> :NERDTreeToggle<CR>
let NERDTreeWinSize=25
" <2 非github 仓库的插件>"
" Plugin 'git://git.wincent.com/command-t.git'
" <3 本地仓库的插件> "
"++++++++++++++++++++++++++++++++++
" 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
syntax enable
syntax on
colorscheme desert
set shiftwidth=4
set ts=4
set expandtab
set nu
set nocompatible
set history=500 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set backspace=indent,eol,start
" Set cscope
if has("cscope")
let current = "."
let num = 1
while num < 20
if filereadable(current . "/cscope.out")
let $CSCOPE_DB = current . "/cscope.out"
cs add $CSCOPE_DB
break
else
let current = current . "/.."
let num = num + 1
endif
endwhile
endif
set tags=/home/hillstone/projects/nginx-1.15.8/tags
[hillstone@hillstone Linux_MAIN]$
2、vim: bookmarks
https://blog.csdn.net/MDL13412/article/details/44081509
功能 快捷键 命令
添加/删除书签(当前行) mm :BookmarkToggle
添加/编辑/删除当前行注释书签 mi :BookmarkAnnotate
跳转到当前 buffer 的下一个书签 mn :BookmarkNext
跳转到当前 buffer 的前一个书签 mp :BookmarkPrev
在 quickfix 窗口中列出所有书签(toggle) ma :BookmarkShowAll
清除当前 buffer 内的所有书签 mc :BookmarkClear
清除所有 buffer 内的书签 mx :BookmarkClearAll
保存书签到文件 :BookmarkSave <FILE_PATH>
从文件加载书签 :BookmarkLoad <FILE_PATH>
3、YouCompleteMe安装
前面都是准备工作,接下来正式安装YCM
输入下面命令
cd ~/.vim/bundle
git clone https://github.com/ycm-core/YouCompleteMe.git
下载完成后进入到YCM目录下
cd ~/.vim/bundle/YouCompleteMe
输入以下命令
git submodule update --init --recursive
这个过程会比较长,耐心等待。
上面结束后,开始编译YCM支持的所有语言:
./install.py
安装过程同样比较慢,耐新等待。 编译完成后, 在.vimrc中添加:
Plugin 'ycm-core/YouCompleteMe'
再运行一遍:PluginInstall,安装完毕
4、vim在centos下升级到8.2
由于YouCompleteMe限制vim版本为8.1.*,下载官方vim最新代码(8.2.):
https://github.com/vim/vim.git
编译并安装vim 8.2
$ cd vim/
$ ./configure --prefix=$HOME/.local --enable-python3interp=yes && make && make install
注:
(1)用configure配置一下安装的路径,将Vim8安装到自己账户的目录下,避免干扰到系统上的其他用户
(2)–enable-python3interp=yes 添加 python3 支持
链接vim
利用alias将vim指令定向到刚刚安装的vim8,同时修改.bashrc确保之后一直能生效
alias vim='~/.local/bin/vim'
echo "alias vim='~/.local/bin/vim'" >> ~/.bashrc
检查vim版本
vim --version