Vim plugins: Difference between revisions

From miki
Jump to navigation Jump to search
(→‎Plugin Managers: Plugins section from page Vim.)
Line 1: Line 1:
== Plugins ==
== Install a plugin ==
The best is to use a plugin manager (see below). Otherwise,
=== Install a plugin ===
* Unzip the plugin in <tt>~/.vim</tt> directory (or <tt>plugin</tt>, <tt>autoload</tt>...)
* Unzip the plugin in <tt>~/.vim</tt> directory (or <tt>plugin</tt>, <tt>autoload</tt>...)
* Generate the help tags with:
* Generate the help tags with:
Line 6: Line 6:
helptags ~/.vim/tags
helptags ~/.vim/tags
</source>
</source>
=== vim-latex ===
See page [[vim-latex]].


== Plugin Managers ==
== Plugin Managers ==

Revision as of 06:29, 10 November 2016

Install a plugin

The best is to use a plugin manager (see below). Otherwise,

  • Unzip the plugin in ~/.vim directory (or plugin, autoload...)
  • Generate the help tags with:
helptags ~/.vim/tags

Plugin Managers

Various plugin manager. My current favorite is vim-plug.

apt-vim

Fully-automated, Cross-platform Plugin Manager for Vim.

Pathogen

Plugin manager from Tim Pope.

VIM (vim-addon-manager)

VAM manage and install vim plugins (including their dependencies) in a sane way.

vim-plug

Plugin manager from junegunn, author of fzf, vim-easy-align.

Interaction with $HOME version control

If we store our HOME files (dot-files) in git, we can't store the plugins anymore because they are fetched and stored locally as squashed git submodules. We can circumvent this by managing these plugins as git submodules.

First create .gitmodules:

[submodule "ack.vim"]
    path = .vim/plugged/ack.vim
    url = ./.vim/plugged/ack.vim
[submodule "auto-pairs"]
    path = .vim/plugged/auto-pairs
    url = ./.vim/plugged/auto-pairs
[submodule "a.vim"]
    path = .vim/plugged/a.vim
    url = ./.vim/plugged/a.vim

Then create the bare repositories:

git clone --bare /home/peetersm home.git
cd home.git/
mkdir -p .vim/plugged
cd .vim/plugged
for g in ~/.vim/plugged/*; do git clone --bare $g; done

Then, to clone the HOME repository:

git clone --recursive .../home.git

Finally we must update the tags file in vim. Start vim and run PlugInstall!. Ignore the error messages.


Troubleshooting
  • Using short path may fail if plugin name has an extension. For instance:
" The following FAILS because of trailing .vim
Plug 'ctrlpvim/ctrlp.vim'
" Use the following instead.
Plug 'https://github.com/ctrlpvim/ctrlp.vim.git'
  • Conditional plugin activation.
See the FAQ.

Plugins

Repositories

A mirror of all plugins originally found on http://www.vim.org/scripts/ ;
  • GitHub.

Getting help

  • Most plugins come with local help files. Do :help local-additions to get a list of help files for locally installed plugins.

Installed

Not yet installed

Some videos that illustrates those plugins:

Uninstalled

  • easytags.vim : Automated tag file generation and syntax highlighting of tags in Vim
    • Replaced by AutoTag — syntax highlighting of tags is limited to c files; moreover AutoTag has a clever way to look for the tags file in project hierarchy.
  • AutoClose : Inserts matching bracket, paren, brace or quote
    Don't like it much because inserting the closing pair will jump out of nested pair, which is annoying when one try to simply insert a closing brace (but a solution is to use the Surrond plugin to surround some selected text with braces).
  • trinity.vim : Build the trinity of srcexpl, taglist, NERD_tree to be a good IDE
  • minibufexpl.vim : Elegant buffer explorer - takes very little screen space
    • 1st attempt: No real tab support. Seems to interfere with trinity plugin. Interesting key bindings inside though. To reassess...
    • 2nd attempt: Don't care about tabs, the idea is to fully replace tabs with buffers since most plugins interface better with buffers. Disabled
    trinity plugin.
    • Closing a buffer: Use d in minibufexpl window to close a buffer, or :bd[elete] seems to work most of the time.
    • Uninstalled because found better alternative (bufstat)
  • LustyJuggler: Switch very quickly among your active buffers
    • Removed because I don't use it (LustyExplorer, NERDTree and FuzzyFinder are much better alternatives)
  • Latex Text Formatter : This scripts makes it easier to format latex text
    • Does not work well (line too short, line merge too aggressive)
  • calendar.vim - A calendar application for Vim
    • :Calendar to launch. < and > to cycle through views, E and T to view Event list or Task list.
    • :Calendar 2001 1 1 to focus a specific date.
    My settings in .vimrc:
    " ----- Vim-Calendar ---------------------------------------------------------
    let g:calendar_week_number=1
    let g:calendar_first_day='monday'
    
  • diffchanges.vim : Show changes made to current buffer since the last save
    • Never used. Functionality quite limited (only compared with last save). And if file is stored in Git, plugin fugitive is a much better alternative.
  • mru.vim : Plugin to manage Most Recently Used (MRU) files
    • Never used. And same functionality is available in Ctrl-P plugin anyway.
  • git:file.vim : open any version of a file in git
  • For instance, to open file filename.c at commit HEAD~4:
    vim HEAD~4:./filename.c
    
    • Never used. Similar functionality available in plugin fugitive.