Vim 插件管理器 vim-plug


建立時間: 2023年9月7日 22:11
更新時間: 2023年9月11日 08:39

說明

插件管理器或套件管理器這類的技術相當常見,例如: python 的 pip。這次要介紹的 vim-plug 用途是方便管理 vim 插件。

本篇將簡單介紹安裝和使用,詳細的內容請參考 vim-plug

安裝

主要安裝方式就是下載 plug.vim 放到 “autoload” 目錄裡面。

autoload 位置

  • mac: ~/.vim/autoload
  • windows: $HOME/vimfiles/autoload

用指令下載

Unix 系統

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

其它作業系統,或 Neovim 請參考官方文件。

使用

~/.vimrc 配置

.vimrc

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'

" 確定你使用單引號

" help 幫助文件中文版
Plug 'yianwillis/vimcdoc'

" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" You can revert the settings after the call like so:
"   filetype indent off   " Disable file-type-specific indentation
"   syntax off            " Disable syntax highlighting

將要安裝的插件放在 call plug#begin()call plug#end() 之間。

初始化插件系統會自動執行 filetype plugin indent onsyntax enable,如果不想這樣設定可以在 call plug#end() 之後輸入 filetype indent offsyntax off

重新載入 .vimrc 然後在 vim 輸入 :PlugInstall 安裝插件。

指令

指令 描述
PlugInstall [name ...] [#threads] 安裝插件
PlugUpdate [name ...] [#threads] 安裝或更新插件
PlugClean[!] 刪除未列出的插件 (bang版本將在沒有提示的情況下清理)
PlugUpgrade 升級 vim-plug 本身

插件推薦

前往 Vim 擴充功能 搜尋頁面查看我推薦的插件。

參考

觀看次數: 809
managerplugplugingvim
按讚追蹤 Enjoy 軟體 Facebook 粉絲專頁
每週分享資訊技術

一杯咖啡的力量,勝過千言萬語的感謝。

支持我一杯咖啡,讓我繼續創作優質內容,與您分享更多知識與樂趣!