Vim plugins: Difference between revisions
(Original section from Vim page) |
|||
Line 1: | Line 1: | ||
== Plugin Managers == |
|||
Various plugin manager. My current favorite is '''[[#vim-plug|vim-plug]]'''. |
|||
=== [https://github.com/egalpin/apt-vim apt-vim] === |
|||
Fully-automated, Cross-platform Plugin Manager for Vim. |
|||
=== [http://www.bestofvim.com/plugin/pathogen/ Pathogen] === |
|||
Plugin manager from Tim Pope. |
|||
=== [https://github.com/marcweber/vim-addon-manager VIM (vim-addon-manager)] === |
|||
VAM manage and install vim plugins (including their dependencies) in a sane way. |
|||
=== [https://github.com/junegunn/vim-plug vim-plug] === |
|||
Plugin manager from [https://github.com/junegunn junegunn], author of [https://github.com/junegunn/fzf fzf], [https://github.com/junegunn/vim-easy-align 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 {{file|.gitmodules}}: |
|||
<source lang=text> |
|||
[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 |
|||
</source> |
|||
Then create the bare repositories: |
|||
<source lang=bash> |
|||
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 |
|||
</source> |
|||
Then, to clone the HOME repository: |
|||
<source lang=bash> |
|||
git clone --recursive .../home.git |
|||
</source> |
|||
Finally we must update the tags file in vim. Start vim and run <code>PlugInstall!</code>. Ignore the error messages. |
|||
;Troubleshooting |
|||
* Using short path may fail if plugin name has an extension. For instance: |
|||
<source lang=vim> |
|||
" The following FAILS because of trailing .vim |
|||
Plug 'ctrlpvim/ctrlp.vim' |
|||
" Use the following instead. |
|||
Plug 'https://github.com/ctrlpvim/ctrlp.vim.git' |
|||
</source> |
|||
* Conditional plugin activation. |
|||
:See the '''[https://github.com/junegunn/vim-plug/wiki/faq#Conditional_activation FAQ]'''. |
|||
== Plugins == |
== Plugins == |
||
=== Repositories === |
=== Repositories === |
Revision as of 06:24, 10 November 2016
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
- snipMate : TextMate-style snippets for Vim
- Engine in VimL: https://github.com/garbas/vim-snipmate (garbas' fork), http://github.com/msanders/snipmate.vim (original, stalled)
- Engine in Python: https://github.com/SirVer/ultisnips
- Snippets definition: https://github.com/honza/vim-snippets
- Another engine, also very powerful but different syntax (not compatible with vim-snippets): https://github.com/drmingdrmer/xptemplate
- a.vim : Alternate Files quickly (.c --> .h etc) (forked version, the original version)
- AutoTag : Updates entries in a tags file automatically when saving
- surround.vim : Delete/change/add parentheses/quotes/XML-tags/much more with ease (github)
- tComment : An extensible & universal comment plugin that also handles embedded filetypes
- Smart Tabs : Use tabs for indent, spaces for alignment
- See also Indent with tabs & align with spaces
- cpp.vim: General C++ Settings (no indentation for namespace...) (disabled highlight of leading tabs, line length overruns, unit test header test + nice
- CScope (also mirrored on GitHub)
- Cscope page is available on SourceForge.
- See the tutorial here
- Cscope on Vim Wiki
- One can also use cscope and ctags together
- ClosePairs : Auto closes pairs of characters (simpler than AutoClose, and can also delete pair of braces at once with <BS>).
Below is a patch that learns ClosePairs to push down the closing brace when typing { twice (inspired from AutoClose plugin). - Tested on NeoVim: undo broken but dot-repeatable (
.
). - delimitMate by Israel Chauca Fuentes, https://github.com/Raimondi/delimitMate [1]
- AutoClose by Karl Guertin, https://github.com/vim-scripts/AutoClose [2]
- AutoClose by Thiago Alves, https://github.com/vim-scripts/AutoClose--Alves [3]
- Best so far — Auto Pairs by Miao Jiang, https://github.com/jiangmiao/auto-pairs
- Tested on NeoVim: undoable and dot-repeatable (
.
) (and should be the same on vim 7.4.849+). - ClosePairs by Edoardo Vacchi, https://github.com/vim-scripts/ClosePairs [4]
- Smartinput by Kana Natsuno, https://github.com/kana/vim-smartinput
- breaks undo / dot-repeat (tested on neovim). Nice support of triple apostrophe.
- Simple pairs by Orestis Markou, https://github.com/vim-scripts/simple-pairs [5]
- Requires Python.
- vim-autoclose by Townk, https://github.com/Townk/vim-autoclose
- Tested on NeoVim: undo broken but dot-repeatable (
.
). - Vim BufStat
- MiniBufExplorer questions (closing a buffer, making it invisible, etc.) (use d in minibufexpl, :set hidden to navigate to other buf even if current modified)
- Can we remap :q to :bd only when 2 or more buffer opened?
- An alternative is buftabs: Minimalistic buffer tabs saving screen space (more at StackOverflow - An alternative to minibufexplorer (vim)?)
- StackOverflow - MiniBufExplorer and NERD_Tree closing buffers unexpected behavior: See tip165 - bclose + custom mapping below, :bd might just be good enough though...
- LustyExplorer : Dynamic filesystem and buffer explore
- FuzzyFinder : buffer/file/command/tag/etc explorer with fuzzy matching
- Alternative, Command-T (inspired from TextMate)
- See also Super-Finder in Vim (using FuzzyFinder)
- After
:set path=/path/to/project/**
, one can do:find filename.ext
(See [6], more details at [7]) - To find a file in a sub-directory, use the fuzzy query **/filename
- vim-latex (documentation
- Align : Help folks to align text, eqns, declarations, tables, etc (see examples)
- Sparkup — A parser for a condensed HTML format Use ^e in edit mode to extend sparkup text, and ^n to go to next empty item. Some examples (more at Zen Coding:
AlterColour
function that computes new colour...)
--- a/.vim/plugin/closepairs.vim
+++ b/.vim/plugin/closepairs.vim
@@ -10,7 +10,7 @@
inoremap ( ()<left>
-inoremap { {}<left>
+inoremap <expr> { <SID>openpair('{','}')
inoremap [ []<left>
vnoremap <leader>" "zdi"<c-r>z"
@@ -44,6 +44,16 @@ function! s:delpair()
return "\<bs>"
endf
+function! s:openpair(left,right)
+ let l:col = col('.')
+ let l:lchr = getline('.')[l:col-2]
+ let l:rchr = getline('.')[l:col-1]
+ if a:left == l:lchr && a:right == l:rchr
+ return "\<esc>a\<CR>;\<CR>".a:right."\<esc>\"_xk$\"_xa"
+ endif
+ return a:left.a:right."\<left>"
+endf
+
function! s:escapepair(right)
More auto-close plugins or similar:
More on auto-close:
More on the issue of dot-repeat (with list of plugins):
" GRB: use fancy buffer closing that doesn't close the split
cnoremap <expr> bd (getcmdtype() == ':' ? 'Bclose' : 'bd')
div#page.section.main div[title] a[title="Hello world" rel] td[colspan=2] ul > li*5 li.item$$$*3 div#page>(div#header>ul#nav>li*4>a)+(div#page>(h1>span)+p*2)+div#footer #content>.section div#content>div.section p>{Click }+a{here}+{ to continue}
- S-CR to continue list.
{{{ ... }}}
in visual mode, add to ~/.vim/ftplugin/vimwiki_custom.vim:
" Quote a block of text with {{{ }}} in visual mode
:vmap gq DO {{{<CR><ESC>P
- Add this to bundle/ag/plugin/ag.vim to add command
:ag
instead of:Ag
[8]:
cboreabbrev ag <c-r>=(getcmdtype()=':' && getcmdpos()==1 ? 'Ag' : 'ag')<CR>
- And combined with plugin Ctrl-P (see below):
" CtrlP
" -----
" Use AG for look-up. See https://robots.thoughtbot.com/faster-grepping-in-vim
if executable('ag')
" Use ag over grep - See ag man page for option '--vimgrep'
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
" AG
" --
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
endif
:nmap <F5> :wa<CR>:Make<CR>:cw<CR> # Note the capital M to Make
To build a custom target:
:Make <targetname> # first invocation. Store targetname for future use
<F5> # next
Not yet installed
- OmniCppComplete : C/C++ omni-completion with ctags database
- c.vim : C/C++ IDE -- Write and run programs. Insert statements, idioms, comments etc.
- winmanager : A windows style IDE for Vim 6.0 (Referenced in TagList plugin help)
- bufexplorer.zip : Buffer Explorer / Browser
- neocomplcache : Ultimate auto completion system for Vim
- project.tar.gz : Organize/Navigate projects of files (like IDE/buffer explorer)
- AutoClose : Auto close pair of characters (Another version with same name than the one I tried below)
- See also dedicated tip entry: Automatically append closing characters
- SuperTab continued : Do all your insert-mode completion with Tab
- Tim Pope's commentary: comment stuff out (referenced from Practical Vim)
- textobj-entire: Text objects for entire buffer (referenced from Practical Vim)
- LaTeX Box : Lightweight Toolbox for LaTeX
- unite.vim : Unite and create user interfaces (for more WOW factor, check this blog or the homepage)
- Plugin from OSCON 2013: "More Instantly Better Vim" - Damian Conway:
- autoswap.mac (manage automatically swap file — Mac only)
- vmath.mac (compute sums, averages, min and max)
- vis.vim (let : commands to act on visual blocks, not the full lines)
- visualdrags (allows moving / duplicate visual)
- closeb : Close complex brackets or tags An extended version of closetag.vim. Press ^_ to automatically close current tag (HTML, XML, LaTeX...)
- Gist : vimscript for gist
- functionlist.vim : This plugin makes it easy to navigate between functions in a long file.
- ShowFunc.vim : Creates a list of all tags / functions from a window, all windows or buffers.
- taglist.vim : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
- DeleteTrailingWhitespace : Delete unwanted whitespace at the end of lines Currently using custom mapping / autocmd (see below).
- vim-easy-align
Some videos that illustrates those plugins:
- Top Vim Plugins (YouTube), showing Surround, SnipMate, TComment, MRU, FuzzyFinder, NerdTree, MatchIt
- Another list of nice plugins (MRU, SnipMate, VimExplorer)
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
- Source Explorer (srcexpl.vim) : A Source code Explorer based on tags works like context window in Source Insight
- taglist.vim : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
- The NERD tree : A tree explorer plugin for navigating the filesystem
- 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
- 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)
- Someone is working on improving minibufexpl (v6.4)
- 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.- 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:
- Never used. Similar functionality available in plugin fugitive.
--- trinity.vim 2009-12-22 19:50:06.000000000 +0100
+++ trinity-new.vim 2010-07-06 01:24:28.000000000 +0200
@@ -90,7 +90,7 @@
" Set the window width
let g:Tlist_WinWidth = 24
" Sort by the order
- let g:Tlist_Sort_Type = "order"
+ let g:Tlist_Sort_Type = "name"
" Do not display the help info
let g:Tlist_Compact_Format = 1
" If you are the last, kill yourself
@@ -100,7 +100,7 @@
" Do not show folding tree
let g:Tlist_Enable_Fold_Column = 0
" Always display one file tags
- let g:Tlist_Show_One_File = 1
+ let g:Tlist_Show_One_File = 0
endfunction " }}}
--- taglist.vim 2007-09-21 18:11:20.000000000 +0200
+++ taglist-new.vim 2010-07-06 01:08:11.000000000 +0200
@@ -3207,14 +3207,7 @@
if a:win_ctrl == 'newwin'
split
endif
+ " 20100706 - MIP PATCH BEGIN - USE badd / buffer! so that we can
+ " switch files even when current buffer changes are not written ----
+ if !bufexists(a:filename)
+ exe "badd " . escape(a:filename, ' ')
+ endif
+ exe "buffer! " . escape(a:filename, ' ')
+ " exe "edit " . escape(a:filename, ' ')
+ " 20100706 - MIP PATCH END -----
- exe "edit " . escape(a:filename, ' ')
else
" Open a new window
if g:Tlist_Use_Horiz_Window
--- taglist.vim 2011-06-27 00:32:33.000000000 +0200
+++ taglist-new.vim 2011-06-27 00:37:23.000000000 +0200
@@ -1552,6 +1552,8 @@
\ :call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
nnoremap <buffer> <silent> o
\ :call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR>
+ nnoremap <buffer> <silent> O
+ \ :call <SID>Tlist_Window_Jump_To_Tag('newwinv')<CR>
nnoremap <buffer> <silent> p
\ :call <SID>Tlist_Window_Jump_To_Tag('preview')<CR>
nnoremap <buffer> <silent> P
@@ -1592,6 +1594,8 @@
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('useopen')<CR>
inoremap <buffer> <silent> o
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newwin')<CR>
+ inoremap <buffer> <silent> O
+ \ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('newwinv')<CR>
inoremap <buffer> <silent> p
\ <C-o>:call <SID>Tlist_Window_Jump_To_Tag('preview')<CR>
inoremap <buffer> <silent> P
@@ -3206,6 +3210,10 @@
" the existing window into two.
if a:win_ctrl == 'newwin'
split
+ " 20110627 - MIP PATCH BEGIN - Allow vertical split -----
+ elseif a:win_ctrl == 'newwinv'
+ vsplit
+ " 20110627 - MIP PATCH END -----
endif
" 20100706 - MIP PATCH BEGIN - USE badd / buffer! so that we can
" switch files even when current buffer changes are not written ----
@@ -3265,6 +3273,10 @@
" existing window into two.
if a:win_ctrl == 'newwin'
split
+ " 20110627 - MIP PATCH BEGIN - Allow vertical split -----
+ elseif a:win_ctrl == 'newwinv'
+ vsplit
+ " 20110627 - MIP PATCH END -----
endif
endif
endif
@@ -3313,6 +3325,7 @@
" Jump to the location of the current tag
" win_ctrl == useopen - Reuse the existing file window
" win_ctrl == newwin - Open a new window
+" win_ctrl == newwinv - Open a new window (vertical)
" win_ctrl == preview - Preview the tag
" win_ctrl == prevwin - Open in previous window
" win_ctrl == newtab - Open in new tab
" ----- Vim-Calendar ---------------------------------------------------------
let g:calendar_week_number=1
let g:calendar_first_day='monday'
--- mru-old.vim 2010-06-29 00:45:59.000000000 +0200
+++ mru.vim 2010-07-22 14:14:19.000000000 +0200
@@ -657,7 +657,12 @@
let wcmd = '+buffer' . bufnum
endif
- exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd
+ " MIP PATCH BEGIN - :botright conflicts with TagList + QuickFix windows
+ " if I have TagList + QuickFix window opened, calling :MRU multiple times makes the QuickFix window to grow
+ " endlessly
+ " exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd
+ exe 'silent! ' . g:MRU_Window_Height . 'split ' . wcmd
+ " MIP PATCH END
endif
endif
vim HEAD~4:./filename.c