mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
translated
This commit is contained in:
parent
6add6ef49d
commit
e9e089564c
@ -1,122 +0,0 @@
|
||||
translating----geekpi
|
||||
|
||||
Vim-plug : A Minimalist Vim Plugin Manager
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/06/vim-plug-720x340.png)
|
||||
|
||||
When there were no plugin managers, the Vim users had to manually download the Plugins distributed as tarballs and extract them in a directory called **~/.vim**. It was OK for few plugins. When they installed more plugins, it became a mess. All plugin files scattered in a single directory and the users couldn’t find which file belongs to which plugin. Further more, they could not find which file they should remove to uninstall a plugin. There is where Vim plugin managers comes in handy. The plugin managers saves the files of installed plugins in separate directory, so it is became very easy to manage all plugins. We already wrote about [**Vundle**][1] few months ago. Today, we will see yet another Vim plugin manager named **“Vim-plug”**.
|
||||
|
||||
Vim-plug is a free, open source, very fast, minimalist vim plugin manager. It can install or update plugins in parallel. You can also rollback the updates. It creates shallow clones to minimize disk space usage and download time. It supports on-demand plugin loading for faster startup time. Other notable features are branch/tag/commit support, post-update hooks, support for externally managed plugins etc.
|
||||
|
||||
### Vim-plug : A Minimalist Vim Plugin Manager
|
||||
|
||||
#### **Installation**
|
||||
|
||||
It is very easier to setup and use. All you have to do is to open your Terminal and run the following command:
|
||||
```
|
||||
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
```
|
||||
|
||||
The Neovim users can install Vim-plug using the following command:
|
||||
```
|
||||
$ curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
**Installing Plugins**
|
||||
|
||||
To install plugins, you must first declare them in Vim configuration file as shown below. The configuration file for ordinary Vim is **~/.vimrc** and the config file for Neovim is **~/.config/nvim/init.vim**. Please remember that when you declare the plugins in configuration file, the list should start with **call plug#begin(PLUGIN_DIRECTORY)** and end with call **plug#end()**.
|
||||
|
||||
For example, let us install “lightline.vim” plugin. To do so, add the following lines on top of your **~/.vimrc** file.
|
||||
```
|
||||
call plug#begin('~/.vim/plugged')
|
||||
Plug 'itchyny/lightline.vim'
|
||||
call plug#end()
|
||||
|
||||
```
|
||||
|
||||
After adding the above lines in vim configuration file, reload by entering the following:
|
||||
```
|
||||
:source ~/.vimrc
|
||||
|
||||
```
|
||||
|
||||
Or, simply reload the Vim editor.
|
||||
|
||||
Now, open vim editor:
|
||||
```
|
||||
$ vim
|
||||
|
||||
```
|
||||
|
||||
Check the status using command:
|
||||
```
|
||||
:PlugStatus
|
||||
|
||||
```
|
||||
|
||||
And type following command and hit ENTER to install the plugins that you have declared in the config file earlier.
|
||||
```
|
||||
:PlugInstall
|
||||
|
||||
```
|
||||
|
||||
**Update Plugins**
|
||||
|
||||
To update plugins, run:
|
||||
```
|
||||
:PlugUpdate
|
||||
|
||||
```
|
||||
|
||||
After updating the plugins, press **d** to review the changes. Or, you can do it later by typing **:PlugDiff**.
|
||||
|
||||
**Review Plugins**
|
||||
|
||||
Some times, the updated plugins may have new bugs or no longer work correctly. To fix this, you can simply rollback the problematic plugins. Type **:PlugDiff** command and hit ENTER to review the changes from the last **:PlugUpdate** and roll each plugin back to the previous state before the update by pressing **X** on each paragraph.
|
||||
|
||||
**Removing Plugins**
|
||||
|
||||
To remove a plugin delete or comment out the **plug** commands that you have added earlier in your vim configuration file. Then, run **:source ~/.vimrc** or restart Vim editor. Finally, run the following command to uninstall the plugins:
|
||||
```
|
||||
:PlugClean
|
||||
|
||||
```
|
||||
|
||||
This command will delete all undeclared plugins in your vim config file.
|
||||
|
||||
**Upgrade Vim-plug**
|
||||
|
||||
To upgrade vim-plug itself, type:
|
||||
```
|
||||
:PlugUpgrade
|
||||
|
||||
```
|
||||
|
||||
As you can see, managing plugins using Vim-plug is not a big deal. It simplifies the plugin management a lot easier. Now go and find out your favorite plugins and install them using Vim-plug.
|
||||
|
||||
**Suggested read:**
|
||||
|
||||
And, that’s all for now. I will be soon here with another interesting topic. Until then, stay tuned with OSTechNix.
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/vim-plug-a-minimalist-vim-plugin-manager/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:https://www.ostechnix.com/manage-vim-plugins-using-vundle-linux/
|
@ -0,0 +1,120 @@
|
||||
Vim-plug:极简 Vim 插件管理器
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/06/vim-plug-720x340.png)
|
||||
|
||||
当没有插件管理器时,Vim 用户必须手动下载 tarball 包的插件并将它们解压到 **~/.vim** 目录中。在少量插件的时候可以。当他们安装更多的插件时,就会变得一团糟。所有插件文件分散在单个目录中,用户无法找到哪个文件属于哪个插件。此外,他们无法找到他们应该删除哪个文件来卸载插件。这时 Vim 插件管理器就可以派上用场。插件管理器将安装插件的文件保存在单独的目录中,因此管理所有插件变得非常容易。我们几个月前已经写了关于 [**Vundle**][1] 的文章。今天,我们将看到又一个名为 **“Vim-plug”** 的 Vim 插件管理器。
|
||||
|
||||
Vim-plug 是一个免费、开源、速度非常快的、极简的 vim 插件管理器。它可以并行安装或更新插件。你还可以回滚更新。它创建浅层克隆以最小化磁盘空间使用和下载时间。它支持按需加载插件以加快启动时间。其他值得注意的特性是分支/标签/提交支持、post-update hook、支持外部管理的插件等。
|
||||
|
||||
### Vim-plug:一个极简的 Vim 插件管理器
|
||||
|
||||
#### **安装**
|
||||
|
||||
安装和使用起来非常容易。你只需打开终端并运行以下命令:
|
||||
```
|
||||
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
```
|
||||
|
||||
Neovim 用户可以使用以下命令安装 Vim-plug:
|
||||
```
|
||||
$ curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
```
|
||||
|
||||
#### 用法
|
||||
|
||||
**安装插件**
|
||||
|
||||
要安装插件,你必须如下所示首先在 Vim 配置文件中声明它们。一般 Vim 的配置文件是 **~/.vimrc**,Neovim 的配置文件是 **~/.config/nvim/init.vim**。请记住,当你在配置文件中声明插件时,列表应该以 **call plug#begin(PLUGIN_DIRECTORY)** 开始,并以 **plug#end()** 结束。
|
||||
|
||||
例如,我们安装 “lightline.vim” 插件。为此,请在 **~/.vimrc** 的顶部添加以下行。
|
||||
```
|
||||
call plug#begin('~/.vim/plugged')
|
||||
Plug 'itchyny/lightline.vim'
|
||||
call plug#end()
|
||||
|
||||
```
|
||||
|
||||
在 vim 配置文件中添加上面的行后,通过输入以下命令重新加载:
|
||||
```
|
||||
:source ~/.vimrc
|
||||
|
||||
```
|
||||
|
||||
或者,只需重新加载 Vim 编辑器。
|
||||
|
||||
现在,打开 vim 编辑器:
|
||||
```
|
||||
$ vim
|
||||
|
||||
```
|
||||
|
||||
使用以下命令检查状态:
|
||||
```
|
||||
:PlugStatus
|
||||
|
||||
```
|
||||
|
||||
然后输入下面的命令,然后按 ENTER 键安装之前在配置文件中声明的插件。
|
||||
```
|
||||
:PlugInstall
|
||||
|
||||
```
|
||||
|
||||
**更新插件**
|
||||
|
||||
要更新插件,请运行:
|
||||
```
|
||||
:PlugUpdate
|
||||
|
||||
```
|
||||
|
||||
更新插件后,按下 **d** 查看更改。或者,你可以之后输入 **:PlugDiff**。
|
||||
|
||||
**审查插件**
|
||||
|
||||
有时,更新的插件可能有新的 bug 或无法正常工作。要解决这个问题,你可以简单地回滚有问题的插件。输入 **:PlugDiff** 命令,然后按 ENTER 键查看上次 **:PlugUpdate**的更改,并在每个段落上按 **X** 将每个插件回滚到更新前的前一个状态。
|
||||
|
||||
**删除插件**
|
||||
|
||||
删除一个插件删除或注释掉你以前在你的 vim 配置文件中添加的 **plug** 命令。然后,运行 **:source ~/.vimrc** 或重启 Vim 编辑器。最后,运行以下命令卸载插件:
|
||||
```
|
||||
:PlugClean
|
||||
|
||||
```
|
||||
|
||||
该命令将删除 vim 配置文件中所有未声明的插件。
|
||||
|
||||
**升级 Vim-plug**
|
||||
|
||||
要升级vim-plug本身,请输入:
|
||||
```
|
||||
:PlugUpgrade
|
||||
|
||||
```
|
||||
|
||||
如你所见,使用 Vim-plug 管理插件并不难。它简化了插件管理。现在去找出你最喜欢的插件并使用 Vim-plug 来安装它们。
|
||||
|
||||
**建议阅读:**
|
||||
|
||||
就是这些了。我将很快在这里发布另一个有趣的话题。在此之前,请继续关注 OSTechNix。
|
||||
|
||||
干杯!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/vim-plug-a-minimalist-vim-plugin-manager/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:https://www.ostechnix.com/manage-vim-plugins-using-vundle-linux/
|
Loading…
Reference in New Issue
Block a user