Radek Sprta (Posts about plugins)https://radeksprta.eu/categories/plugins.atom2024-01-07T02:28:55ZRadek SprtaNikolaManaging Vim Plugins Easily Using Githttps://radeksprta.eu/posts/managing-vim-plugins-easily-using-git/2017-08-05T23:21:52+02:002017-08-05T23:21:52+02:00Radek Sprta<p>Managing Vim plugins can quickly get messy. Fortunately, there are several
solutions to this problem. My favorite one is
<a href="https://github.com/tpope/vim-pathogen">Pathogen</a> by Tim Pope. It makes it
easy to install plugins in their own private directories and automatically
load them. And combining it with Git will make your Vim configuration easily
portable across computers.</p>
<h3>Install Pathogen</h3>
<p>So how do we set it up? First of all, prepare a Git repository for your Vim
plugins:</p>
<div class="code"><pre class="code literal-block">$ git init .vim
$ mkdir .vim/bundle
</pre></div>
<p>Next, get Pathogen. To makes things easier, we will add it as Git submodule:</p>
<div class="code"><pre class="code literal-block">$ git submodule add https://github.com/tpope/vim-pathogen bundle/pathogen
$ ln -s autoload bundle/pathogen/autoload
</pre></div>
<p>Furthermore, to enable Pathogen, you must add the following lines to your
<code>.vimrc</code>:</p>
<div class="code"><pre class="code literal-block">execute pathogen#infect<span class="p">()</span> <span class="nb">syntax</span> <span class="k">on</span> <span class="k">filetype</span> plugin indent <span class="k">on</span>
</pre></div>
<h3>Managing Vim plugins</h3>
<p>Now you can happily start adding other plugins as submodules. Here is an
example using <a href="https://github.com/tpope/vim-sensible">Vim Sensible</a>:</p>
<div class="code"><pre class="code literal-block">$ git submodule add https://github.com/tpope/vim-sensible bundle/vim-sensible
</pre></div>
<p>In order to update them later, just run:</p>
<div class="code"><pre class="code literal-block">$ git submodule update --remote --merge
</pre></div>
<p>Finally, if you ever need to delete them later, follow these steps:</p>
<div class="code"><pre class="code literal-block">$<span class="w"> </span>git<span class="w"> </span>submodule<span class="w"> </span>init<span class="w"> </span>bundle/vim-sensible
$<span class="w"> </span>git<span class="w"> </span>rm<span class="w"> </span>bundle/vim-sensible
$<span class="w"> </span>rm<span class="w"> </span>-Rf<span class="w"> </span>.git/modules/bundle/vim-airline
$<span class="w"> </span>git<span class="w"> </span>commit
</pre></div>
<h3>Synchronize everything</h3>
<p>Just one thing is missing to make the setup perfect. Ideally, your vimrc would
be stored along with the plugins. I prefer
<a href="https://pypi.python.org/pypi/dotfiles/">dotfiles</a> for the job. For it is
simple and ready to install using pip. So let's do that:</p>
<div class="code"><pre class="code literal-block">$ sudo pip install dotfiles
</pre></div>
<p>Then create a folder for your Vim configuration
(which you can use for other configurations as well):</p>
<div class="code"><pre class="code literal-block">$ git init Dotfiles
</pre></div>
<p>Finally, add the Vim configuration files:</p>
<div class="code"><pre class="code literal-block">$<span class="w"> </span>dotfiles<span class="w"> </span>--add<span class="w"> </span>~/.vimrc
$<span class="w"> </span>dotfiles<span class="w"> </span>--add<span class="w"> </span>~/.vim
</pre></div>
<p>VoilĂ . At last, you can keep the changes to your Vim
settings and plugins safely versioned now. And to set them up on a new
computer, you just need to clone the repository, install dotfiles and run:</p>
<div class="code"><pre class="code literal-block">$ dotfiles --sync
</pre></div>
<p>Can't get easier than that. Now, head over to see <a href="https://radeksprta.eu/vim-tips-increased-productivity">some of my Vim
tips</a>.</p>