cabin

Source code for personal website
git clone git://git.dimitrijedobrota.com/cabin.git
Log | Files | Refs

VimPugins.md (5822B)


      1 @title: Vim Plugins - Installation guide
      2 @language: en
      3 @date: 2021-08-19
      4 @categories: linux, vim
      5 
      6 # Vim Plugins - Installation guide
      7 
      8 In preparation for 'Vim Showcase' series, were I'll be showcasing plugins and other vim tricks, I've decided to dedicate this short
      9 article to the process of setting up vim for installing plugins, as a reference to those of you who haven't done it already.
     10 
     11 Vim is a great tool with a lot of amazing features that come out of the box.
     12 Sometimes, though, a little push is needed to take the experience to a whole new level.
     13 
     14 This article expects the readers to be familiar with running basic commands in
     15 the terminal as well as basic vim knowledge including running vim commands.
     16 
     17 
     18 ## Introduction
     19 
     20 - _What are vim plugins_?<br>
     21   Vim plugins are, in essence, scripts that are used to add new features to the
     22   editor or extend the already existing ones
     23 - _What are plugins used for_?<br>
     24   Plugins are used to bring anything from color schemes to providing full fledged IDE-like features to vim editor.
     25 - _How are vim plugins written?_<br>
     26   Vim plugins are written using Vim Script
     27 - _What is Vim Script_?<br>
     28   Vim Script is a language used by vim for startup files, syntax files, plugins and any other configuration of the editor<br> 
     29   For more info you can reference [vim help](https://vim.help/41-write-a-vim-script)
     30 - _How to get vim plugins_?<br>
     31   Staring from Vim 8 plugins are supported and should be placed in `~/.vim/pack/vendor/`.<br>
     32   There is also a possibility of using a plugin manager to streamline the process of installing, using, updating and removing plugins
     33 
     34   
     35 In this article I am going to explain how to use [Vundle](https://github.com/VundleVim/Vundle.vim), short for vim bundle, as the plugin manager
     36 
     37 As taken from their help page:
     38   
     39 Vundle allows you to...
     40 
     41   - keep track of and configure your scripts right in the `.vimrc`
     42   - install configured scripts (a.k.a. bundle)
     43   - update configured scripts
     44   - search by name all available Vim scripts
     45   - clean unused scripts up
     46   - run the above actions in a single keypress with interactive mode
     47 
     48 Vundle automatically...
     49 
     50   - manages the runtime path of your installed scripts
     51   - regenerates help tags after installing and updating
     52 
     53 
     54 ## Installing Vundle
     55 
     56 In order to install Vundle `git` must be present on the system, which you can check by running:
     57 
     58     git
     59     bash: git: command not found
     60 
     61 If you get `command not found` you will need to install it using your distribution package manager.
     62 
     63 ***
     64 
     65 With that out of the way, we are ready to install Vundle. All you have to do is run:
     66 
     67      git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
     68      
     69      
     70 After the Vundle has installed, there is a little configuration that needs to
     71 be done, in order for vim to recognize Vundle and start loading the plugins
     72 
     73 ## Configuring Vundle
     74 
     75 Open your `vimrc` file, which will most likely be `~/.vimrc`, and paste the following boilerplate code at the beginning:
     76 
     77 ```
     78 set nocompatible              " be iMproved, required
     79 filetype off                  " required
     80 
     81 set rtp+=~/.vim/bundle/Vundle.vim
     82 call vundle#begin()
     83 
     84 Plugin 'VundleVim/Vundle.vim'   " leave as first item
     85 
     86 " All of your Plugins must be added here
     87 
     88 call vundle#end()            " required
     89 filetype plugin indent on    " required"
     90 ```
     91 
     92 This code ensures that Vundle is started with vim, and to keep track of the installed plugins.
     93 
     94 **Note**: As the comment in the boilerplate suggests, all of the Plugins must be added
     95 after `call vundle#begin()` and before `call vundle#end()` in order for them to
     96 be recognized by Vundle, and not cause error when starting vim.
     97 
     98 
     99 With this out of the way, we are ready to install some plugins
    100 
    101 
    102 ## Installing Plugins
    103 
    104 
    105 To install a plugin from github, do the following:
    106 
    107 1. Find the plugin you want to install and note the URL.<br> Example: `https://github.com/kana/vim-textobj-user`
    108 2. Take the `author/name` portion of the URL.<br> In this case: `kana/vim-textobj-user`
    109 3. Put `Plugin 'author/name'` in the designated area in `vimrc` file.<br> Example: `Plugin 'kana/vim-textobj-user'`
    110 
    111 **Note**: To see all of the URLs supported, reference `:h vundle-plugins-uris`
    112 
    113 After, we have put in the list of plugins we want, vim needs to be
    114 reloaded.<br> We can do it by simply exiting and entering vim again or by running
    115 `:source %` directly in vim.
    116 
    117 Finally to instruct Vundle to download the necessary plugins run
    118 `:PluginInstall`.<br> You will see a new window pop up on the side, with the
    119 list of all the plugins, and each line will be highlighted one by one as the
    120 plugin is being installed.
    121 
    122 **Note**: This window can be closed like any other, using `:q` or `Ctrl + zz`.
    123 
    124 After vim is restarted the plugin will be loaded and ready to use.
    125 
    126 For any plugin specific configuration reference the specific usage guide.
    127 
    128 
    129 ## Vundle Commands
    130 
    131 For reference purposes, I will list all of the commands that are available after configuring Vundle.
    132 
    133 - `:PluginInstall`: Will install all plugins configured in your `.vimrc`. Newly installed plugins will be automatically enabled.
    134 - `:PluginUpdatate`: Install or update the configured plugins.
    135 - `:PluginSearch`: Search [Vim Scripts](http://vim-scripts.org/vim/scripts.html) for matching plugins.
    136 - `:PluginClean`: Requests confirmation for the removal of all plugins no longer configured - in your `.vimrc` but present in your bundle installation directory.
    137 - `:PluginList`: Displays a list of installed bundles.
    138 
    139 **Note**: For more information about any of these commands, reference `:h command`
    140 
    141 
    142 ## Conclusion
    143 
    144 With this one time setup out of the way, you are ready to explore the wonderful world of vim plugins.
    145 
    146 Stay tuned for 'Vim Showcase' series to learn more about vim, and to discover some great vim plugins to boost your productivity.