安裝 vim 插件管理工具 #vim插件管理-插件 https://github.com/VundleVim/Vundle.vim git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 編寫 vi ...
安裝 vim 插件管理工具
#vim插件管理-插件 https://github.com/VundleVim/Vundle.vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
編寫 vim 配置文件
vim ~/.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'
" 這裡填寫你將使用的插件
Plugin 'Chiel92/vim-autoformat'
call vundle#end() " required
filetype plugin indent on " required
" 自動格式化插件配置 "
" Ctrl+shift+i 自動格式化代碼
noremap <C-S-i> :Autoformat<CR>
let g:autoformat_verbosemode=1
" 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
安裝格式化工具:
-
C/C++
apt install clang-format
插件管理:
進入 vim
後,在命令模式輸入 :PluginInstall
安裝插件,當下麵出現 done 的時候,表示插件安裝完成。
插件管理命令:
PluginInstall
:插件更新,安裝~/.vimrc
中"call vundle#begin()"到"call vundle#end()"
範圍內配置好的插件。PluginClear
:插件清理,清理call vundle#begin() ... call vundle#end()
之間的插件。PluginUpdate
:插件更新PluginSearch
:插件搜索
最後,進入 vim
後,進行插件更新 :PluginInstall
,使用快捷鍵 Ctrl+shift+i
就可以格式化 C/C++
代碼了。
參考文檔:
- vundle官方文檔
- vim-autoformat 官方文檔
- Linux Vim插件管理器Vundle安裝和使用 - 作者:llsx520
- Linux Vim代碼格式化/美化插件vim-autoformat安裝 - 作者 :劉昭廷
- vim插件--代碼格式化工具 - 作者 :zlcook