vim配置——c++代码自动补全
O 简介
自己配置vim主要分为两大部分:一个是通过set设置vim的属性;另一个是插件下载
一 、插件管理器及clangd代码补全
vim插件管理器与其他软件包管理器如yum, apt, 以及python中的pip等相同,都为软件包管理器,vim的软件包管理器又称插件管理器,常见的vim插件管理器有:
- vim-plug junegunn/vim-plug: Minimalist Vim Plugin Manager (github.com)
- VundleVim : VundleVim/Vundle.vim: Vundle, the plug-in manager for Vim (github.com)
本文安装的是vim-plug,操作系统是WSL Ubuntu20.04
1. vim-plug安装
GitHub的项目给出了两种方法,一种是在命令行直接下载,另一种是在vim的配置文件.vimrc中下载
在命令行直接下载的方法:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
需要注意的是:raw.githubusercontent.com 可能会访问不到,参考连接:彻底解决【“curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused”】错误_donaldsy的技术博客_51CTO博客
需要修改一下网络的配置文件,修改方法为在/etc/hosts文件里添加raw.githubusercontent.com的ip地址
网站ip地址的查询网站:The Best IP Address, Email and Networking Tools - IPAddress.com
2. 通过vim-plug下载vim插件
在.vimrc中增加要下载的插件名或插件地址,默认地址为github,
以call plug#begin()开头
中间为要下载的插件
最后以call plug#end()结尾
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle&#