Sunday, January 21, 2018

How To Manage Vim Plugins Using Vundle On Linux

https://www.ostechnix.com/manage-vim-plugins-using-vundle-linux

Vim, undoubtedly, is one of the powerful
and versatile tool to manipulate text files, manage the system
configuration files and writing code. The functionality of Vim can be
extended to different levels using plugins. Usually, all plugins and
additional configuration files will be stored in ~/.vim
directory. Since all plugin files are stored in a single directory, the
files from different plugins are mixed up together as you install more
plugins. Hence, it is going to be a daunting task to track and manage
all of them. This is where Vundle comes in help. Vundle, acronym of Vim Bundle, is an extremely useful plug-in to manage Vim plugins.

Vundle creates a separate directory tree for each plugin you install
and stores the additional configuration files in the respective plugin
directory. Therefore, there is no mix up files with one another. In a
nutshell, Vundle allows you to install new plugins, configure existing
plugins, update configured plugins, search for installed plugins and
clean up unused plugins. All actions can be done in a single keypress
with interactive mode. In this brief tutorial, let me show you how to
install Vundle and how to manage Vim plugins using Vundle in GNU/Linux.

Installing Vundle

If you need Vundle, I assume you have already installed vim on your system. If not, install vim and git
(to download vundle). Both packages are available in the official
repositories of most GNU/Linux distributions.For instance, you can use
the following command to install these packages on Debian based systems.

The lines which are marked as “required” are Vundle’s requirement.
The rest of the lines are just examples. You can remove those lines if
you don’t want to install that specified plugins. Once you finished,
type :wq to save and close file.
Finally, open vim:

vim

And type the following to install the plugins.

:PluginInstall

A new split window will open and all the plugins which we added in the .vimrc file will be installed automatically.
When the installation is completed, you can delete the buffer cache and close the split window by typing the following command:

:bdelete

You can also install the plugins without opening vim using the following command from the Terminal:

vim +PluginInstall +qall

For those using the fish shell, add the following line to your .vimrc file.

set shell=/bin/bash

Manage Vim Plugins Using Vundle

Add New Plugins
First, search for the available plugins using command:

:PluginSearch

To refresh the local list from the from the vimscripts site, add “!” at the end.

:PluginSearch!

A new split window will open list all available plugins.

You can also narrow down your search by using directly specifying the name of the plugin like below.

:PluginSearch vim

This will list the plugin(s) that contains the words “vim”
You can, of course, specify the exact plugin name like below.

:PluginSearch vim-dasm

To install a plugin, move the cursor to the correct line and hit “i”. Now, the selected plugin will be installed.
Similarly, install all plugins you wanted to have in your system. Once installed, delete the Vundle buffer cache using command:

:bdelete

Now the plugin is installed. To make it autoload correctly, we need to add the installed plugin name to .vimrc file.
To do so, type:

:e ~/.vimrc

Add the following line.

[...]
Plugin 'vim-dasm'
[...]

Replace vim-dasm with your plugin name. Then, hit ESC key and type :wq to save the changes and close the file.
Please note that all of your Plugins must be added before the following line in your .vimrc file.

[...]
filetype plugin indent on

List installed Plugins
To list installed plugins, type the following from the vim editor:

:PluginList

Update plugins
To update the all installed plugins, type:

:PluginUpdate

To reinstall all plugins, type:

:PluginInstall!

Uninstall plugins
First, list out all installed plugins:

:PluginList

Then place the cursor to the correct line, and press “SHITF+d”.
Then, edit your .vimrc file:

:e ~/.vimrc

And delete the Plugin entry. Finally, type :wq to save the changes and exit from vim editor.
Alternatively, you can uninstall a plugin by removing its line from .vimrc file and run:

:PluginClean

This command will remove all plugins which are no longer present in your .vimrc but still present the bundle directory.
At this point, you should have learned the basic usage about managing
plugins using Vundle. For details, refer the help section by typing the
following in your vim editor.