Vim plugins: Difference between revisions
(→Vimtex) |
|||
(136 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This page is about [[Vim]] plugins. |
|||
== Install a plugin == |
|||
== Overview == |
|||
=== Find a plugin === |
|||
Most plugins are found on '''vim.org''' or '''GitHub''': |
|||
* https://github.com/vim-scripts?tab=repositories |
|||
: A mirror of all plugins originally found on http://www.vim.org/scripts/ ; |
|||
* '''GitHub'''. |
|||
=== Install a plugin === |
|||
The best is to use a plugin manager (see below). Otherwise, |
The best is to use a plugin manager (see below). Otherwise, |
||
* Unzip the plugin in |
* Unzip the plugin in {{file|~/.vim}} directory (or {{file|plugin}}, {{file|autoload}}...) |
||
* Generate the help tags with: |
* Generate the help tags with: |
||
<source lang="bash"> |
<source lang="bash"> |
||
helptags ~/.vim/tags |
helptags ~/.vim/tags |
||
</source> |
</source> |
||
=== Getting help === |
|||
Most plugins come with local help files. Do <code>:help local-additions</code> to get a list of help files for locally installed plugins. |
|||
== Plugin Managers == |
== Plugin Managers == |
||
Here I list various plugin managers. My current favorite is '''[[#vim-plug|vim-plug]]'''. |
|||
=== [https://github.com/egalpin/apt-vim apt-vim] === |
=== [https://github.com/egalpin/apt-vim apt-vim] === |
||
Line 16: | Line 31: | ||
Plugin manager from Tim Pope. |
Plugin manager from Tim Pope. |
||
=== [https://github.com/marcweber/vim-addon-manager |
=== [https://github.com/marcweber/vim-addon-manager VAM (vim-addon-manager)] === |
||
VAM manage and install vim plugins (including their dependencies) in a sane way. |
VAM manage and install vim plugins (including their dependencies) in a sane way. |
||
=== [https://github.com/junegunn/vim-plug vim-plug] === |
=== [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]. |
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]. |
||
;Install |
|||
<source lang=bash> |
|||
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ |
|||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
|||
</source> |
|||
;Update plugins on offline computer |
|||
To update plugins on a computer that has no internet access, the simplest solution is to clone all repositories in a folder accessible by the offline computer, and use the git URL rewriting feature to point to this folder instead. |
|||
Use the following script to sync the folder, {{file|vim-plug-mirror.sh}}: |
|||
<source lang="bash"> |
|||
#! /bin/bash |
|||
die() |
|||
{ |
|||
CODE=$1 |
|||
shift |
|||
>&2 echo "ERROR -- $@" |
|||
exit $CODE |
|||
} |
|||
usage() |
|||
{ |
|||
echo "Usage: $(basename $0) <mirror_dir>" |
|||
die 1 "$*" |
|||
} |
|||
DIR=${1%%/} |
|||
echo $DIR |
|||
[ -n "$DIR" -a -d "$(dirname "$DIR")" ] || usage "Missing <mirror_dir>" |
|||
if ! [ -d "$DIR" ]; then |
|||
echo "Creating $DIR" |
|||
mkdir "$DIR" || die 1 "Cannot create '$DIR'" |
|||
fi |
|||
PLUGINS_DIR=$(find ~/.vim/plugged -name .git|sed -r 's_/\.git__') |
|||
for plugin_dir in $PLUGINS_DIR; do |
|||
echo "Processing '$plugin_dir'" |
|||
URL=$(git -C "$plugin_dir" remote get-url origin) |
|||
plugin=$(echo $URL|sed -r 's_https://github.com/__; s_github\.com:__; s_\.git__') |
|||
PLUGINDIR=$DIR/${plugin}.git |
|||
PARENTDIR=$(dirname $PLUGINDIR) |
|||
if [ -d "$PLUGINDIR" ]; then |
|||
false && echo git -C "$PLUGINDIR" fetch --all |
|||
else |
|||
mkdir -p "$PARENTDIR" || die 1 "Cannot create '$PARENTDIR'" |
|||
git clone --mirror $URL "$PLUGINDIR" |
|||
fi |
|||
done |
|||
</source> |
|||
To use the script, simply give a folder path: |
|||
<source lang="bash"> |
|||
vim-plug-mirror.sh /smb/some/path |
|||
</source> |
|||
Then, on the offline machine: |
|||
<source lang="bash"> |
|||
sudo git config --system url./smb/some/path/.insteadOf https://github.com/ |
|||
</source> |
|||
;Interaction with $HOME version control |
;Interaction with $HOME version control |
||
Line 46: | Line 126: | ||
for g in ~/.vim/plugged/*; do git clone --bare $g; done |
for g in ~/.vim/plugged/*; do git clone --bare $g; done |
||
</source> |
</source> |
||
Then, to clone the HOME repository: |
Then, to clone the HOME repository: |
||
<source lang=bash> |
<source lang=bash> |
||
Line 66: | Line 146: | ||
:See the '''[https://github.com/junegunn/vim-plug/wiki/faq#Conditional_activation FAQ]'''. |
:See the '''[https://github.com/junegunn/vim-plug/wiki/faq#Conditional_activation FAQ]'''. |
||
== |
== Installed plugins == |
||
Plugins I'm currently using. |
|||
=== Repositories === |
|||
=== A === |
|||
* https://github.com/vim-scripts?tab=repositories |
|||
[https://github.com/nacitar/a.vim '''a.vim''' : Alternate Files quickly (.c --> .h etc)] (forked version, the [http://www.vim.org/scripts/script.php?script_id=31 original version]) |
|||
: A mirror of all plugins originally found on http://www.vim.org/scripts/ ; |
|||
{| class=wikitable width=100% |
|||
* '''GitHub'''. |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=31 vim.org] |
|||
|width=72pt|[https://github.com/xeyownt/a.vim GitHub] |
|||
!width=15%|a.vim |
|||
|Alternate Files quickly (.c --> .h etc) ([https://github.com/nacitar/a.vim original]) |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|<code>:A</code> || Switch between header / source file |
|||
|- |
|||
|<code>:AS</code> || Split and Switch |
|||
|- |
|||
|<code>:AV</code> || Vertical split and Switch |
|||
|- |
|||
|<code>:AT</code> || New Tab and Switch |
|||
|- |
|||
|<code>:AN</code> || Cycles through matches |
|||
|- |
|||
|<code>:IH</code> {{bk|Cih}}|| switches to file under cursor |
|||
|- |
|||
|<code>:IHS</code> || splits and switches |
|||
|- |
|||
|<code>:IHV</code> || vertical splits and switches |
|||
|- |
|||
|<code>:IHT</code> || new tab and switches |
|||
|- |
|||
|<code>:IHN</code> {{kb|{{kbname|Leader}}ihn}} || cycles through matches |
|||
|- |
|||
|{{kbname|Leader}}is || switches to the alternate file of file under cursor |
|||
|} |
|||
|} |
|||
Plugin high-level description, or comment on the configuration. |
|||
<source lang="vim"> |
|||
" Plug 'nacitar/a.vim' " Alternate Files quickly (.c --> .h etc) - fork of original |
|||
Plug 'xeyownt/a.vim' " Alternate Files quickly (.c --> .h etc) - fork of original |
|||
</source> |
|||
=== |
=== ack.vim === |
||
* Most plugins come with local help files. Do <code>:help local-additions</code> to get a list of help files for locally installed plugins. |
|||
{| class=wikitable width=100% |
|||
=== Installed === |
|||
|- |
|||
<ul> |
|||
|width=72pt| |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2540 '''snipMate''' : TextMate-style snippets for Vim]</li> |
|||
|width=72pt|[https://github.com/mileszs/ack.vim GitHub] |
|||
* Engine in VimL: https://github.com/garbas/vim-snipmate (garbas' fork), http://github.com/msanders/snipmate.vim (original, stalled) |
|||
!width=15%|ack.vim |
|||
* Engine in Python: https://github.com/SirVer/ultisnips |
|||
|Vim plugin for the Perl module / CLI script 'ack' |
|||
* Snippets definition: https://github.com/honza/vim-snippets |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
| || |
|||
|} |
|||
|} |
|||
I fell back to this plugin because [https://github.com/rking/ag.vim ag.vim] is stalled. But we can still use '''ag''' as search engine. |
|||
My settings [http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev]: |
|||
<source lang=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 |
|||
" bind K to grep word under cursor |
|||
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR> |
|||
let g:ackprg = 'ag --vimgrep' |
|||
" Allow lowercase command 'ag' - see http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev |
|||
cnoreabbrev ag <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'Ack' : 'ag')<CR> |
|||
endif |
|||
</source> |
|||
=== Auto-Pairs === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=3599 vim.org] |
|||
|width=72pt|[https://github.com/jiangmiao/auto-pairs GitHub] |
|||
!width=15%|auto-pairs |
|||
|Vim plugin, insert or delete brackets, parens, quotes in pair |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|M-e}}||Fast wrap (e.g. <code><nowiki>(|)wrapme</nowiki></code>) |
|||
|- |
|||
|{{kb|M-n}}||Jump to next closed pair |
|||
|} |
|||
|} |
|||
'''Tested''' on NeoVim: '''{{green|undoable}}''' and '''{{green|dot-repeatable}}''' (<code>.</code>) (and should be the same on vim 7.4.849+). |
|||
Works better than ''ClosePairs'' and similar. |
|||
More auto-close plugins or similar: |
|||
* https://github.com/cohama/lexima.vim |
|||
:'''Tested''' on NeoVim: '''{{red|undo broken}}''' but '''{{green|dot-repeatable}}''' (<code>.</code>). |
|||
* delimitMate by Israel Chauca Fuentes, https://github.com/Raimondi/delimitMate [http://www.vim.org/scripts/script.php?script_id=2754] |
|||
* AutoClose by Karl Guertin, https://github.com/vim-scripts/AutoClose [http://www.vim.org/scripts/script.php?script_id=1849] |
|||
* AutoClose by Thiago Alves, https://github.com/vim-scripts/AutoClose--Alves [http://www.vim.org/scripts/script.php?script_id=2009] |
|||
* '''{{red|Best so far}}''' — '''Auto Pairs''' by Miao Jiang, https://github.com/jiangmiao/auto-pairs |
|||
:'''Tested''' on NeoVim: '''{{green|undoable}}''' and '''{{green|dot-repeatable}}''' (<code>.</code>) (and should be the same on vim 7.4.849+). |
|||
* ClosePairs by Edoardo Vacchi, https://github.com/vim-scripts/ClosePairs [http://www.vim.org/scripts/script.php?script_id=2373] |
|||
* 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 [http://www.vim.org/scripts/script.php?script_id=2339] |
|||
:Requires Python. |
|||
* vim-autoclose by Townk, https://github.com/Townk/vim-autoclose |
|||
:'''Tested''' on NeoVim: '''{{red|undo broken}}''' but '''{{green|dot-repeatable}}''' (<code>.</code>). |
|||
More on auto-close plugins: |
|||
* Explanations on the issue by [http://sharats.me/vim-undo-breaks-with-auto-close-plugins.html sharat78]. |
|||
* All tips and plugins on [http://vim.wikia.com/wiki/Automatically%5Fappend%5Fclosing%5Fcharacters wikia.com] |
|||
More on the issue of dot-repeat (with list of plugins): |
|||
* http://stackoverflow.com/questions/883437/how-do-i-get-vim-to-automatically-put-ending-braces |
|||
=== AutoSave === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=4521 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/vim-auto-save GitHub] |
|||
!width=15%|auto-pairs |
|||
|Automatically save changes to disk |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|M-e}}||Fast wrap (e.g. <code><nowiki>(|)wrapme</nowiki></code>) |
|||
|- |
|||
|{{kb|M-n}}||Jump to next closed pair |
|||
|} |
|||
|} |
|||
Useful in particular when editing TeX file with continuous compilation to view changes live in PDF viewer. |
|||
;Configuration |
|||
<source lang="vim"> |
|||
let g:auto_save = 1 " enable AutoSave on Vim startup |
|||
" Optional: |
|||
let g:auto_save_no_updatetime = 1 " do not change the 'updatetime' option |
|||
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode |
|||
let g:auto_save_silent = 1 " do not display the auto-save notification |
|||
let g:auto_save_postsave_hook = 'TagsGenerate' " this will run :TagsGenerate after each save |
|||
</source> |
|||
=== AutoTag === |
|||
[http://www.vim.org/scripts/script.php?script_id=1343 '''AutoTag''' : Updates entries in a tags file automatically when saving] |
|||
=== Cpp.vim === |
|||
[http://www.derekwyatt.org/vim/working-with-vim-and-cpp/general-cpp-settings/ '''cpp.vim''': General C++ Settings (no indentation for namespace...)] |
|||
:'' (disabled highlight of leading tabs, line length overruns, unit test header test + nice <code>AlterColour</code> function that computes new colour...)'' |
|||
=== cpsm === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/nixprime/cpsm GitHub] |
|||
!width=15%|cpsm |
|||
|A CtrlP matcher, specialized for paths. |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|C-p}} |
|||
|Ctrl-P file mode |
|||
|- |
|||
|{{kb|C-o}} |
|||
|Ctrl-P MRU mode |
|||
|} |
|||
|} |
|||
To install: |
|||
<source lang=bash> |
|||
sudo apt install libboost-all-dev cmake python-dev libicu-dev |
|||
cd ~/.vim/plugged/cpsm |
|||
./install.sh |
|||
</source> |
|||
=== Cscope_maps === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://cscope.sourceforge.net/cscope_maps.vim SF] |
|||
|width=72pt|[xeyownt/cscope_maps.vim GitHub] |
|||
!width=15%|cscope_maps |
|||
|Some boilerplate settings and keyboard mappings for cscope |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kbname|Leader}}cs {{kbctrl|{{kbname|Space}}}}s || <u>symbol</u>: Find all references to token, split |
|||
|- |
|||
|{{kbname|Leader}}cg {{kbctrl|{{kbname|Space}}}}g || <u>global</u>: Find all global definitions, split |
|||
|- |
|||
|{{kbname|Leader}}cc {{kbctrl|{{kbname|Space}}}}c || <u>call</u>: Find all calls to function, split |
|||
|- |
|||
|{{kbname|Leader}}ct {{kbctrl|{{kbname|Space}}}}t || <u>text</u>: Find all instance of text, split |
|||
|- |
|||
|{{kbname|Leader}}ce {{kbctrl|{{kbname|Space}}}}e || <u>egrep</u>: egrep search, split |
|||
|- |
|||
|{{kbname|Leader}}cf {{kbctrl|{{kbname|Space}}}}f || <u>file</u>: open filename, split |
|||
|- |
|||
|{{kbname|Leader}}ci {{kbctrl|{{kbname|Space}}}}i || <u>includes</u>: Find all files that include fname, split |
|||
|- |
|||
|{{kbname|Leader}}cd {{kbctrl|{{kbname|Space}}}}d || <u>called</u>: Find functions that function calls, hsplit |
|||
|- |
|||
|{{kbctrl|{{kbname|Space}}}}{{kbctrl|{{kbname|Space}}}} s || Same but vsplit |
|||
|- |
|||
|<nowiki>:</nowiki>cs f s foo || Same but as command (use :scs for split) |
|||
|- |
|||
|{{kbctrl|]}} || Jump to symbol {{red|'''declaration'''}} (ctags shortcut) |
|||
|} |
|||
|} |
|||
Cscope page is available on [http://cscope.sourceforge.net/ SourceForge]. |
|||
* See the [http://cscope.sourceforge.net/cscope_vim_tutorial.html tutorial here] |
|||
* [http://vim.wikia.com/wiki/Cscope Cscope on Vim Wiki] |
|||
* One can also use [http://stackoverflow.com/questions/934233/cscope-or-ctags-why-choose-one-over-the-other cscope and ctags together] |
|||
<source lang="vim"> |
|||
" Plug 'simplyzhao/cscope_maps.vim' " Some boilerplate settings and keyboard mappings for cscope |
|||
Plug 'xeyownt/cscope_maps.vim' " Some boilerplate settings and keyboard mappings for cscope |
|||
</source> |
|||
=== ctrlp.vim === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=3736 vim.org] |
|||
|width=72pt|[https://github.com/ctrlpvim/ctrlp.vim GitHub] |
|||
!width=15%|ctrlp.vim |
|||
|Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder. [http://ctrlpvim.github.io/ctrlp.vim/ home] |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kbkey|^p}} || Invoke CtrlP |
|||
|{{kbkey|^j}} {{kbkey|^k}} || Navigate list |
|||
|{{kbkey|^z}} {{kbkey|^o}} || Mark/unmark, open |
|||
|- |
|||
|{{kbkey|F5}} || Refresh cache |
|||
|{{kbkey|^t}} || Open new tab |
|||
|<code>:diffthis</code> || Compare marked files |
|||
|- |
|||
|{{kbkey|^f}} {{kbkey|^b}} || Cycle between modes |
|||
|{{kbkey|^v}} {{kbkey|^x}} || Open new split |
|||
| || |
|||
|- |
|||
|{{kbkey|^d}} || Switch filename/full |
|||
|{{kbkey|^n}} {{kbkey|^p}} || Next/prev hist |
|||
| || |
|||
|- |
|||
|{{kbkey|^r}} || Switch regexp mode |
|||
|{{kbkey|^y}} || Create new file |
|||
| || |
|||
|} |
|||
|} |
|||
Currently works best using '''ag''' ([http://stackoverflow.com/questions/18285751/use-ag-in-ctrlp-vim this] and [https://robots.thoughtbot.com/faster-grepping-in-vim]) as file scanner and '''cpsm''' as match engine. |
|||
My settings: |
|||
<source lang=vim> |
|||
" Set root directory |
|||
let g:ctrlp_working_path_mode = 'rwa' |
|||
" Enable filename search (instead of full path) - Ctrl-D to switch |
|||
let g:ctrlp_by_filename = 1 |
|||
" |
|||
" Use AG for look-up. See https://robots.thoughtbot.com/faster-grepping-in-vim |
|||
if executable('ag') |
|||
" Use ag in CtrlP for listing files. Lightning fast and DOESN'T respect .gitignore |
|||
let g:ctrlp_user_command = 'ag %s -U -l --nocolor -g ""' |
|||
" ag is fast enough that CtrlP doesn't need to cache - BUT we are on a slow filesystem |
|||
" let g:ctrlp_use_caching = 0 |
|||
endif |
|||
</source> |
|||
=== DoxygenToolkit.vim === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/vim-scripts/DoxygenToolkit.vim GitHub] |
|||
!width=15%|DoxygenToolkit.vim |
|||
| Simplify Doxygen documentation in C, C++, Python |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|<code>:Dox</code> |
|||
|Fill doxygen for function declaration. |
|||
|} |
|||
|} |
|||
My configuration |
|||
<source lang="vim"> |
|||
" --- DoxygenToolkit --------------------------------------------------------------------------{{{ |
|||
let g:DoxygenToolkit_briefTag_pre="@Synopsis " |
|||
let g:DoxygenToolkit_paramTag_pre="@Param " |
|||
let g:DoxygenToolkit_returnTag="@Returns " |
|||
let g:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------" |
|||
let g:DoxygenToolkit_blockFooter="----------------------------------------------------------------------------" |
|||
let g:DoxygenToolkit_authorName="Michael Peeters" |
|||
" let g:DoxygenToolkit_licenseTag="" |
|||
</source> |
|||
=== FastFold === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/Konfekt/FastFold GitHub] |
|||
!width=15%|FastFold |
|||
|Speed up Vim by updating folds only when called-for |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|zuz}} || Force fold update (same as <code>:FastFoldUpdate</code>) |
|||
|} |
|||
|} |
|||
<source lang="vim"> |
|||
Plug 'Konfekt/FastFold' " Speed up Vim by updating folds only when called-for |
|||
</source> |
|||
=== Fugitive === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2975 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-fugitive GitHub] |
|||
!width=15%|fugitive.vim |
|||
|A Git wrapper so awesome, it should be illegal |
|||
|} |
|||
Add to {{file|.vimrc}}: |
|||
<source lang=vim> |
|||
set diffopt+=vertical " Favor vertical split for vimdiff |
|||
</source> |
|||
;Some commands: |
|||
<source lang=vim> |
|||
" Gdiff |
|||
:Gdiff " View differences with index |
|||
:Gdiff HEAD " View differences with HEAD |
|||
:Gdiff - " View differences with HEAD |
|||
:Gdiff ^ " View differences with previous commit |
|||
:Gdiff ~3 " View differences with 3 commits ago |
|||
" Glog |
|||
:Glog " Load previous file revision in quickfix. :cn / :cp for next/previous |
|||
:Glog -- % " Load commits (i.e. diff) impacting current file. |
|||
:Glog -Sfindme -- " Pickaxe string 'findme' |
|||
" Gedit |
|||
:Gedit " Edit back current file |
|||
</source> |
|||
;Typical workflow |
|||
* View history of changes on a file |
|||
<source lang=vim> |
|||
:Glog " Load previous file revision in quickfix |
|||
:cn " next revision (or open quickfix window and <CR> to select) |
|||
:cp " previous revision (or open quickfix window and <CR> to select) |
|||
:Gdiff " View diff with version in work tree |
|||
:q " Quit diff, and return to selected revision |
|||
:Gdiff ^ " View diff with previous version |
|||
:q |
|||
:Gedit " Edit back original file |
|||
</source> |
|||
=== fzf.vim === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/junegunn/fzf.vim GitHub] |
|||
!width=15%|fzf.vim |
|||
|fzf :heart: vim |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|C-p}} |
|||
|Ctrl-P file mode |
|||
|- |
|||
|{{kb|C-o}} |
|||
|Ctrl-P MRU mode |
|||
|} |
|||
|} |
|||
;Neovim |
|||
fzf.vim uses neovim terminal emulator. Use this mapping to have {{kb|esc}} key leave fzf, but go to normal mode in other terminals [https://github.com/junegunn/fzf/issues/576]: |
|||
<source lang=vim> |
|||
tnoremap <expr> <esc> &filetype == 'fzf' ? "\<esc>" : "\<c-\>\<c-n>" |
|||
</source> |
|||
=== IndentTab === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=4243 vim.org] |
|||
|width=72pt|[https://github.com/xeyownt/IndentTab.git GitHub] |
|||
!width=15%|IndentTab |
|||
|Use tabs for indent at the beginning, spaces for alignment in the rest of a line |
|||
|- |
|||
|} |
|||
This plugin works better than [http://www.vim.org/scripts/script.php?script_id=231 ''Smart-Tabs'' (ctab.vim)]. |
|||
See also [http://vim.wikia.com/wiki/Indent_with_tabs%2C_align_with_spaces Indent with tabs & align with spaces]. |
|||
;Configuration |
|||
We must make sure that it is loaded before plugin ''SuperTab'' (so that the latter can record IndentTab maps for {{kb|Tab}}). |
|||
<source lang=vim> |
|||
Plug 'xeyownt/IndentTab' | " Use tabs for indent at the beginning, spaces for alignment in the rest of a line |
|||
Plug 'ervandew/supertab' " Perform all your vim insert mode completions with Tab |
|||
</source> |
|||
<source lang=vim> |
|||
" --- IndentTab -------------------------------------------------------------------------------{{{ |
|||
let g:IndentTab = 1 " Enable the plugin |
|||
let g:IndentTab_IsSuperTab = 1 " Enable integration with supertab |
|||
let g:IndentTab_scopes = 'indent' " Disable 'commentprefix' and 'string', which require ingo-library |
|||
" }}} |
|||
</source> |
|||
=== MatchIt === |
|||
[http://www.vim.org/scripts/script.php?script_id=39 '''matchit.zip''' : extended % matching for HTML, LaTeX, and many other languages] |
|||
=== Mcf-make-target === |
|||
[https://github.com/taketwo/mcf/blob/master/.vim/plugin/mcf-make-target.vim '''mcf-make-target''': Persistent make target in Vim] |
|||
This plugin lets Vim to store the last arguments passed to make, and use that argument when make is invoked without arguments. For ease, define the following macro: |
|||
<source lang=vim> |
|||
:nmap <F5> :wa<CR>:Make<CR>:cw<CR> # Note the capital M to Make |
|||
</source> |
|||
To build a custom target: |
|||
<source lang=vim> |
|||
:Make <targetname> # first invocation. Store targetname for future use |
|||
<F5> # next |
|||
</source> |
|||
=== Repeat === |
|||
Install [http://www.vim.org/scripts/script.php?script_id=2136 '''repeat.vim''' : Use the repeat command (.) with supported plugins] |
|||
=== SparkUp === |
|||
[https://github.com/rstacruz/sparkup '''Sparkup''' — A parser for a condensed HTML format] |
|||
Use {{kb|^e}} in edit mode to extend sparkup text, and {{kb|^n}} to go to next empty item. Some examples (more at [https://code.google.com/p/zen-coding/ Zen Coding]: |
|||
<pre> |
|||
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} |
|||
</pre> |
|||
=== Supertab === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1643 vim.org] |
|||
|width=72pt|[https://github.com/ervandew/supertab GitHub] |
|||
!width=15%|Supertab |
|||
|Perform all your vim insert mode completions with Tab |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|Tab}} |
|||
|Complete, insert |
|||
|} |
|||
|} |
|||
<source lang=vim> |
|||
Plug 'ervandew/supertab' " Perform all your vim insert mode completions with Tab |
|||
</source> |
|||
<source lang=vim> |
|||
" --- SuperTab---------------------------------------------------------------------------------{{{ |
|||
let g:SuperTabDefaultCompletionType = '<C-n>' |
|||
let g:SuperTabCrMapping = 0 |
|||
" }}} |
|||
</source> |
|||
;Issues |
|||
* {{kb|Tab}} does not work in vimwiki files |
|||
: This is because {{kb|Tab}} is mapped by vimwiki plugin to jump to next table cell. The best work-around is to use {{kb|C-n}} / {{kb|C-p}} to trigger YCM completion. Alternative we can disable table mapping [https://github.com/vimwiki/vimwiki/issues/131] |
|||
<source lang=vim> |
|||
let g:vimwiki_table_mappings = 0 |
|||
</source> |
|||
=== Surround === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1697 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-surround GitHub] |
|||
!width=15%|Surround |
|||
|quoting/parenthesizing made simple. |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|cs"'}} || Change surrounding " to ' |
|||
|- |
|||
|{{kb|cs'<q>}} || Change surrounding ' to <q>...</q> |
|||
|- |
|||
|{{kb|cst"}} || Change surrounding tag back to " |
|||
|- |
|||
|{{kb|ds"}} || Remove the surrounding " |
|||
|- |
|||
|{{kb|ysiw]}} || Add [ ] around word (motion iw) |
|||
|- |
|||
|{{kb|yssb}} {{kb|yss)}} || Add ( ) around current line (ignoring leading ws) |
|||
|- |
|||
|{{kb|1=V<span style="color:green;">''m''</span>S<p id="a">}} || Add surrounding tag to selected lines |
|||
|- |
|||
|{{kb|ysib{{kbname|space}}}} || Add surrounding blank inside current () block |
|||
|} |
|||
|} |
|||
<source lang="vim"> |
|||
Plug 'tpope/vim-surround' " quoting/parenthesizing made simple. |
|||
</source> |
|||
<source lang="vim"> |
|||
" --- Vim-Surround ----------------------------------------------------------------------------{{{ |
|||
" Use lowercase 's' instead of 'S' to surround in visual mode |
|||
xmap s <Plug>VSurround |
|||
" }}} |
|||
</source> |
|||
=== tComment === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1173 vim.org] |
|||
|width=72pt|[https://github.com/tomtom/tcomment_vim GitHub] |
|||
!width=15%|tComment |
|||
|An extensible & universal comment plugin that also handles embedded filetypes |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|1=gc<span style="color:green;">''m''</span>}} || Toggle comments motion |
|||
|- |
|||
|{{kb|gcc}} || Toggle comment for the current line |
|||
|- |
|||
|{{kb|1=gC<span style="color:green;">''m''</span>}} || Comment region motion |
|||
|- |
|||
|{{kb|gCc}} || Comment the current line |
|||
|} |
|||
|} |
|||
<source lang="vim"> |
|||
Plug 'tomtom/tcomment_vim' " An extensible & universal comment vim-plugin that also handles embedded filetypes |
|||
</source> |
|||
=== Ultisnips === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/SirVer/ultisnips GitHub] |
|||
!width=15%|ultisnips |
|||
| UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips! |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/honza/vim-snippets GitHub] |
|||
!width=15%|vim-snippets |
|||
| vim-snipmate default snippets (Previously snipmate-snippets) |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|^J}} |
|||
|Expand snippet / go to next placeholder |
|||
|- |
|||
|{{kb|^K}} |
|||
| Go to previous placeholder |
|||
|} |
|||
|} |
|||
Ultisnips is a snippet engine written in Python. Other snippet plugins: |
|||
* [http://www.vim.org/scripts/script.php?script_id=2540 '''snipMate'''], inspired from TextMate. |
|||
* https://github.com/garbas/vim-snipmate (garbas' fork), http://github.com/msanders/snipmate.vim (original, stalled) |
|||
* Another engine, also very powerful but different syntax (not compatible with vim-snippets): https://github.com/drmingdrmer/xptemplate |
* Another engine, also very powerful but different syntax (not compatible with vim-snippets): https://github.com/drmingdrmer/xptemplate |
||
Some snippets: |
|||
;Configuration |
|||
* We configure ultisnips to use {{kb|^J}} / {{kb|^K}} for expansion and next/previous, and leave {{kb|Tab}} key for completion with plugin SuperTab (which will trigger YouCompleteMe as well). |
|||
* Another option is to use {{kb|Tab}} for expansion (see [https://github.com/christoomey/dotfiles/blob/master/vim/rcplugins/youcompleteme-ultisnips-supertab these] [http://stackoverflow.com/questions/14896327/ultisnips-and-youcompleteme/22253548#22253548 posts] for instance). |
|||
<source lang=vim> |
|||
" --- Ultisnips / vim-snippets-----------------------------------------------------------------{{{ |
|||
" Use C-j/C-k for snippet expansion and next/previous. |
|||
" To use 'tab', see https://github.com/christoomey/dotfiles/blob/master/vim/rcplugins/youcompleteme-ultisnips-supertab |
|||
let g:UltiSnipsEditSplit = 'vertical' |
|||
let g:UltiSnipsExpandTrigger = '<C-j>' |
|||
let g:UltiSnipsJumpForwardTrigger = '<C-j>' |
|||
let g:UltiSnipsJumpBackwardTrigger = '<C-k>' |
|||
</source> |
|||
;Writing snippets |
|||
* Use command <code>:UltiSnipsEdit</code> to start editing snippets for current filetype. |
|||
: This will automatically opens a ''private'' snippet definition file for the current filetype. Use <code>:UltiSnipsEdit!</code> to add snippet in ''public'' definition files. |
|||
* For advanced snippets (Python, auto-expand, use of context), see LaTeX snippets from [https://castel.dev/post/lecture-notes-1/ Gilles Castel]. |
|||
;Snippets |
|||
Snippets must be installed separately. Some snippets from [https://github.com/honza/vim-snippets vim-snippets]: |
|||
#### C #### |
#### C #### |
||
Line 95: | Line 762: | ||
'''#if''' #if ... #endif |
'''#if''' #if ... #endif |
||
'''once''' #ifndef HEADER_H .... # define HEADER_H ... #endif (Header Include-Guard) |
'''once''' #ifndef HEADER_H .... # define HEADER_H ... #endif (Header Include-Guard) |
||
'''if''' If (...) { ... } |
'''if''' If (...) { ... } |
||
'''el''' else { ... } |
'''el''' else { ... } |
||
'''t''' ... ? ... : ... (tertiary conditional) |
'''t''' ... ? ... : ... (tertiary conditional) |
||
'''do''' do ... while ( ... ) |
'''do''' do ... while ( ... ) |
||
Line 121: | Line 788: | ||
'''cl''' class { public: ... private: }; |
'''cl''' class { public: ... private: }; |
||
=== vim-airline === |
|||
<li> [https://github.com/nacitar/a.vim '''a.vim''' : Alternate Files quickly (.c --> .h etc)] (forked version, the [http://www.vim.org/scripts/script.php?script_id=31 original version])</li> |
|||
{| class=wikitable width=100% |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1343 '''AutoTag''' : Updates entries in a tags file automatically when saving]</li> |
|||
|- |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1697 '''surround.vim''' : Delete/change/add parentheses/quotes/XML-tags/much more with ease] ([https://github.com/tpope/vim-surround github])</li> |
|||
|width=72pt| |
|||
* Install [http://www.vim.org/scripts/script.php?script_id=2136 '''repeat.vim''' : Use the repeat command (.) with supported plugins] |
|||
|width=72pt|[https://github.com/vim-airline/vim-airline GitHub] |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1173 '''tComment''' : An extensible & universal comment plugin that also handles embedded filetypes]</li> |
|||
!width=15%|vim-airline |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=231 '''Smart Tabs''' : Use tabs for indent, spaces for alignment]</li> |
|||
|lean & mean status/tabline for vim that's light as air |
|||
* See also [http://vim.wikia.com/wiki/Indent_with_tabs%2C_align_with_spaces Indent with tabs & align with spaces] |
|||
|- |
|||
<li> [http://www.derekwyatt.org/vim/working-with-vim-and-cpp/general-cpp-settings/ '''cpp.vim''': General C++ Settings (no indentation for namespace...)]</li> |
|||
|width=72pt| |
|||
'' (disabled highlight of leading tabs, line length overruns, unit test header test + nice <code>AlterColour</code> function that computes new colour...)'' |
|||
|width=72pt|[https://github.com/vim-airline/vim-airline-themes GitHub] |
|||
<li> '''[http://cscope.sourceforge.net/cscope_maps.vim CScope]''' (also mirrored on [https://github.com/simplyzhao/cscope_maps.vim GitHub])</li> |
|||
!width=15%|vim-airline-themes |
|||
* Cscope page is available on [http://cscope.sourceforge.net/ SourceForge]. |
|||
|A collection of themes for vim-airline |
|||
* See the [http://cscope.sourceforge.net/cscope_vim_tutorial.html tutorial here] |
|||
|- |
|||
* [http://vim.wikia.com/wiki/Cscope Cscope on Vim Wiki] |
|||
|colspan=4| |
|||
* One can also use [http://stackoverflow.com/questions/934233/cscope-or-ctags-why-choose-one-over-the-other cscope and ctags together] |
|||
|} |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2373 '''ClosePairs''' : Auto closes pairs of characters] (simpler than AutoClose, and can also delete pair of braces at once with <BS>).<br/>Below is a patch that learns ''ClosePairs'' to push down the closing brace when typing <tt>{</tt> twice (inspired from ''AutoClose'' plugin).</li> |
|||
'''vim-airline-themes''' is optional, and here not needed since I use '''gruvbox''' for the theme. |
|||
<source lang=vim> |
|||
" ----- Vim-airline ---------------------------------------------------------- |
|||
let g:airline_theme= 'gruvbox' |
|||
let g:airline_section_c = '%F' |
|||
let g:airline_section_y = '' |
|||
let g:airline_section_error = '' |
|||
let g:airline_section_warning = '' |
|||
let g:airline_section_x = '' |
|||
</source> |
|||
=== Vim-auto-save === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/vim-scripts/vim-auto-save GitHub] |
|||
!width=15%|vim-auto-save |
|||
| Automatically save changes to disk |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
;Configuration |
|||
<source lang="vim"> |
|||
let g:auto_save = 1 " enable AutoSave on Vim startup |
|||
let g:auto_save_no_updatetime = 1 " do not change the 'updatetime' option |
|||
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode |
|||
let g:auto_save_silent = 1 " do not display the auto-save notification |
|||
</source> |
|||
=== Vim-easy-align === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/junegunn/vim-easy-align GitHub] |
|||
!width=15%|vim-easy-align |
|||
|A Vim alignment plugin |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kbkey|1=gaip*=}} |
|||
|Auto-align around all occurences of <code>=</code> |
|||
|- |
|||
|<code>:%EasyAlign /;;/</code> |
|||
|Align on <code>;;</code>. This allows using any delimiter. |
|||
|} |
|||
|} |
|||
=== Vim-easymotion === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=3526 vim.org] |
|||
|width=72pt|[https://github.com/easymotion/vim-easymotion GitHub] |
|||
!width=15%|vim-easymotion |
|||
|Vim motions on speed! |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kbkey|\\w}} {{kbkey|\\f}} |
|||
|Horizontal move |
|||
|- |
|||
| {{kbkey|\\j}} {{kbkey|\\k}} |
|||
|Vertical move |
|||
|} |
|||
|} |
|||
;Example configuration |
|||
<source lang=vim> |
|||
" <Leader>f{char} to move to {char} |
|||
map <Leader>f <Plug>(easymotion-bd-f) |
|||
nmap <Leader>f <Plug>(easymotion-overwin-f) |
|||
" s{char}{char} to move to {char}{char} |
|||
nmap s <Plug>(easymotion-overwin-f2) |
|||
" Move to line |
|||
map <Leader>L <Plug>(easymotion-bd-jk) |
|||
nmap <Leader>L <Plug>(easymotion-overwin-line) |
|||
" Move to word |
|||
map <Leader>w <Plug>(easymotion-bd-w) |
|||
nmap <Leader>w <Plug>(easymotion-overwin-w) |
|||
</source> |
|||
=== Vim-gitgutter === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/airblade/vim-gitgutter GitHub] |
|||
!width=15%|vim-gitgutter |
|||
|A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks |
|||
|} |
|||
=== Vim-incsearch === |
|||
{{warn|vim-incsearch is dead and create conflicts. Core is now part of vim/neovim. Use vim-is instead for extra features.}} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=5038 vim.org] |
|||
|width=72pt|[https://github.com/haya14busa/incsearch.vim GitHub] |
|||
!width=15%|incsearch.vim |
|||
|Improved incremental searching for Vim |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/haya14busa/incsearch-easymotion.vim GitHub] |
|||
!width=15%|incsearch-easymotion.vim |
|||
|''Integration between incsearch and easymotion'' |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|Tab}} |
|||
|Move cursor to next match |
|||
|- |
|||
| {{kb|S-Tab}} |
|||
|Move cursor to previous match |
|||
|} |
|||
|} |
|||
See website for more features (including fuzzy search, etc.). |
|||
;Integration with easy-motion: |
|||
<source lang=vim> |
|||
" You can use other keymappings like <C-l> instead of <CR> if you want to |
|||
" use these mappings as default search and somtimes want to move cursor with |
|||
" EasyMotion. |
|||
function! s:incsearch_config(...) abort |
|||
return incsearch#util#deepextend(deepcopy({ |
|||
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})], |
|||
\ 'keymap': { |
|||
\ "\<CR>": '<Over>(easymotion)' |
|||
\ }, |
|||
\ 'is_expr': 0 |
|||
\ }), get(a:, 1, {})) |
|||
endfunction |
|||
noremap <silent><expr> / incsearch#go(<SID>incsearch_config()) |
|||
noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'})) |
|||
noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1})) |
|||
</source> |
|||
=== Vim-LaTeX === |
|||
'''[http://vim-latex.sourceforge.net/ vim-latex]''' ([http://vim-latex.sourceforge.net/documentation/latex-suite.html documentation]) |
|||
See page [[vim-latex]]. |
|||
=== vim-mundo === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/simnalamburt/vim-mundo.git GitHub] |
|||
!width=15%|vim-mundo |
|||
| Vim undo tree visualizer https://simnalamburt.github.io/vim-mundo |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|F12}} |
|||
|Open mundo |
|||
|} |
|||
|} |
|||
vim-mundo is a fork of plugin ''gundo'' (originally written by Steve Losh) that is up-to-date and works on neovim. |
|||
<source lang=vim> |
|||
" --- Vim-mundo -------------------------------------------------------------------------------{{{ |
|||
let g:mundo_verbose_graph = 0 " Create shorter graph |
|||
let g:mundo_inline_undo = 1 " Show a small one line diff at each node |
|||
set undofile " Enable persistent undo so that undo history persists across vim sessions |
|||
set undodir=~/.vim/undo |
|||
nnoremap <F12> :MundoToggle<CR> |
|||
" }}} |
|||
</source> |
|||
=== vim-ps1 === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/PProvost/vim-ps1 GitHub] |
|||
!width=15%|vim-ps1 |
|||
|A Vim plugin for Windows PowerShell support |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
| |
|||
| |
|||
|} |
|||
|} |
|||
<source lang=vim> |
|||
Plug 'PProvost/vim-ps1' " A Vim plugin for Windows PowerShell support |
|||
</source> |
|||
<source lang=vim> |
|||
" --- PS1.vim ---------------------------------------------------------------------------------{{{ |
|||
" Source: https://robindouglas.uk/powershell/vim/2018/04/05/PowerShell-with-Vim.html |
|||
if has('win32') |
|||
set shell=powershell.exe |
|||
set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command |
|||
set shellpipe=| |
|||
set shellredir=> |
|||
endif |
|||
" }}} |
|||
</source> |
|||
;Troubleshooting |
|||
* Bad indentation of closing braces: check that <code>equalprg</code> is not set in {{file|.vimrc}}. |
|||
=== Vimtex === |
|||
See also [[Vim-tex]] for usage. |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/lervag/vimtex GitHub] |
|||
!width=15%|vim-mundo |
|||
|A modern vim plugin for editing LaTeX files. ([https://github.com/lervag/vimtex/wiki wiki]) |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
| |
|||
| |
|||
Delete / change surrounding... |
|||
| |
|||
| |
|||
Text objects... |
|||
|- |
|||
| {{kb|dsc csc}} |
|||
| command |
|||
| {{kb|ic ac}} |
|||
| Commands |
|||
|- |
|||
| |
|||
| |
|||
| {{kb|id ad}} |
|||
| Delimiters |
|||
|- |
|||
| {{kb|dse cse}} |
|||
| environment |
|||
| {{kb|ie ae}} |
|||
| LaTeX environments |
|||
|- |
|||
| {{kb|ds$ cs$}} |
|||
| math structure |
|||
| {{kb|i$ a$}} |
|||
| Inline math structures |
|||
|- |
|||
| {{kb|tsd}} |
|||
| Toggle delimiters, eg. <code>()</code> / <code>\left(\right)</code> |
|||
|- |
|||
| {{kb|]]}} |
|||
| (insert) Close current environment/delimiter |
|||
|- |
|||
| {{kb|F7}} |
|||
| Insert new command |
|||
|} |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|<code>:VimtexImapsList</code> |
|||
|View current insert-mode mappings. |
|||
|} |
|||
|} |
|||
;Install (using Plug) |
|||
* Add to {{file|.vimrc}} |
|||
<source lang="vim"> |
|||
Plug 'lervag/vimtex' " A modern vim plugin for editing LaTeX files. |
|||
</source> |
|||
* On [[Neovim]], install [https://github.com/mhinz/neovim-remote neovim-remote]. |
|||
<source lang=bash> |
|||
pip3 install neovim-remote |
|||
</source> |
|||
;Configuration |
|||
<source lang="vim"> |
|||
" --- VimTex ----------------------------------------------------------------------------------{{{ |
|||
" Inspired from https://castel.dev/post/lecture-notes-1/ |
|||
let g:tex_flavor='latex' |
|||
let g:vimtex_view_method='zathura' |
|||
let g:vimtex_quickfix_mode=0 |
|||
set conceallevel=1 |
|||
let g:tex_conceal='abdmg' |
|||
if has('nvim') |
|||
let g:vimtex_compiler_progname='nvr' |
|||
endif |
|||
" }}} |
|||
</source> |
|||
In addition, the following helps for insert-mode mappings: |
|||
<source lang="vim"> |
|||
imap ² ` |
|||
</source> |
|||
Install [https://github.com/vim-scripts/vim-auto-save vim-auto-save] plugin to save the file and trigger compilation regularly. |
|||
=== VimWiki === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2226 vim.org] |
|||
|width=72pt|[https://github.com/vimwiki/vimwiki GitHub] |
|||
!width=15%|vimwiki |
|||
|Personal Wiki for Vim |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|S-CR}} || Continue list |
|||
|- |
|||
|{{kb|gq}} || Quote text block with <code>{{{ ... }}}</code> |
|||
|} |
|||
|} |
|||
To quote a text block with <code>{{{ ... }}}</code> in visual mode, add to {{file|~/.vim/ftplugin/vimwiki_custom.vim}}: |
|||
<source lang=vim> |
|||
" Quote a block of text with {{{ }}} in visual mode |
|||
:vmap gq DO {{{<CR><ESC>P |
|||
</source> |
|||
;Troubleshooting |
|||
* {{kb|Tab}} not working anymore on <code>dev</code> branch. This is because {{kb|tab}} is already mapped by plugin SuperTab, and Vimwiki refuses to remap. |
|||
<source lang="diff"> |
|||
--- a/ftplugin/vimwiki.vim |
|||
+++ b/ftplugin/vimwiki.vim |
|||
@@ -532,13 +532,9 @@ endfunction |
|||
" insert mode table mappings |
|||
if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings) |
|||
- if maparg('<Tab>', 'i') ==# '' |
|||
inoremap <expr><buffer> <Tab> vimwiki#tbl#kbd_tab() |
|||
- endif |
|||
- if maparg('<S-Tab>', 'i') ==# '' |
|||
inoremap <expr><buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab() |
|||
endif |
|||
-endif |
|||
</source> |
|||
* <code>Exception not caught: VimwikiTags5: Metadata file corrupted"</code> [https://github.com/vimwiki/vimwiki/issues/1286] |
|||
:The fix is simply to delete the file {{file|vimwiki/.vimwiki_tags}}, and optionally run the command <code>:VimwikiRebuildTags</code>. |
|||
=== YouCompleteMe === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/Valloric/YouCompleteMe GitHub] |
|||
!width=15%|YouCompleteMe |
|||
|A code-completion engine for Vim http://valloric.github.io/YouCompleteMe/ |
|||
* Fast fuzzy auto-completion engine (suggest as you type). |
|||
* Semantic completion using clang. |
|||
* Instant diagnostics (errors and warnings reporting). |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|^n}} |
|||
|Next completion (also {{kb|Tab}} using SuperTab plugin) |
|||
|- |
|||
|{{kb|^p}} |
|||
|Previous completion (also {{kb|S-Tab}} using SuperTab plugin) |
|||
|- |
|||
|<code>:YcmDiags</code> |
|||
|Fill location lists with current error and warnings. |
|||
|- |
|||
|<code>:YcmCompleter FixIt</code> |
|||
|Fix current warning / error. |
|||
|} |
|||
|} |
|||
;Installation |
|||
<source lang=bash> |
|||
cd .vim/plugged/YouCompleteMe |
|||
./install.py |
|||
</source> |
|||
;Configuration (without semantic completion) |
|||
* We don't configure YCM to use {{kb|Tab}} for completion but the usual vim's map {{kb|^n}} and {{kb|^p}}. |
|||
* Instead, we install ''SuperTab'' plugin, which will also trigger YCM completion with {{kb|Tab}} and {{kb|S-Tab}} (thanks [https://github.com/christoomey/dotfiles/blob/master/vim/rcplugins/youcompleteme-ultisnips-supertab Christoomey]). |
|||
<source lang=vim> |
|||
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } " A code-completion engine for Vim |
|||
" ... |
|||
" --- YouCompleteMe----------------------------------------------------------------------------{{{ |
|||
let g:ycm_autoclose_preview_window_after_completion = 1 " Auto-close preview window on completion |
|||
let g:ycm_dont_warn_on_startup = 0 |
|||
let g:ycm_complete_in_comments = 1 |
|||
let g:ycm_complete_in_strings = 1 |
|||
let g:ycm_collect_identifiers_from_comments_and_strings = 1 |
|||
let g:ycm_filetype_blacklist = {} |
|||
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>'] |
|||
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] |
|||
" Bug workaround - avoid spurious scrolling on completion when typing '.' |
|||
let g:ycm_filetype_specific_completion_to_disable = { |
|||
\ 'cpp': 1, |
|||
\ 'gitcommit': 1 |
|||
\} |
|||
" }}} |
|||
</source> |
|||
;Configuration (semantic completion) |
|||
Add the default compilation flags files (see manual for more details [http://valloric.github.io/YouCompleteMe/#ubuntu-linux-x64]): |
|||
<source lang="python"> |
|||
# file .ycm_extra_conf_cpp.py |
|||
def FlagsForFile( filename, **kwargs ): |
|||
return { |
|||
'flags': [ '-x', 'c++', '-std=gnu++14', '-Wall', '-Wextra', '-Werror', '-I.', '-Iinclude', '-I../include' ], |
|||
} |
|||
</source> |
|||
<source lang="python"> |
|||
# file .ycm_extra_conf_c.py |
|||
def FlagsForFile( filename, **kwargs ): |
|||
return { |
|||
'flags': [ '-x', 'c', '-gnu11', '-Wall', '-Wextra', '-Werror', '-I.', '-Iinclude', '-I../include' ], |
|||
} |
|||
</source> |
|||
Then in {{file|.vimrc}}: |
|||
<source lang="diff"> |
|||
-Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } " A code-completion engine for Vim |
|||
+Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clang-completer' } " A code-completion engine for Vim |
|||
-let g:ycm_filetype_specific_completion_to_disable = { |
|||
- \ 'cpp': 1, |
|||
- \ 'gitcommit': 1 |
|||
- \} |
|||
+let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py" |
|||
</source> |
|||
{{Warn|Care must be taken with space in the option list. When using clang options like <code>-I</code>, <code>-iquote</code> the directory argument can be collated to the flag, like in <code>'-Iinclude', </code> or <code>'-iquoteinclude', </code>. Alternatively the flag and argmument must be split on two array element (<code>'-iquote', 'include'</code>). But <code>'-iquote include', </code> doesn't work.}} |
|||
;Project-specific configuration |
|||
YCM can use project-specific compilation flags to report warnings / errors that are relevant to your project. YCM can either use a compilation database (such as BEAR, cmake, ninja...), or use manually defined flags. For the latter, just define a file {{file|.ycm_extra_conf.py}} in the root of your project: |
|||
<source lang="python"> |
|||
import os |
|||
def IsCPPFile(filename): |
|||
extension = os.path.splitext(filename)[1] |
|||
return extension in ['.cpp','.cxx','.hpp','.hxx'] |
|||
FLAGS_CPP = [ \ |
|||
'-x', 'c++', '-Wall', '-Werror', '-std=gnu++14', '-funsigned-char', '-fshort-enums', '-fno-common', \ |
|||
'-I.', '-Iinclude', '-I../include' \ |
|||
] |
|||
FLAGS_C = [ \ |
|||
'-x', 'c', '-Wall', '-Werror', '-std=gnu11', '-funsigned-char', '-fshort-enums', '-fno-common', \ |
|||
'-I.', '-Iinclude', '-I../include' \ |
|||
] |
|||
def FlagsForFile( filename, **kwargs ): |
|||
return { 'flags': FLAGS_CPP } if IsCPPFile(filename) else { 'flags': FLAGS_C } |
|||
</source> |
|||
;Configuration - offline install |
|||
* When installing on a computer without internet access, transfer the file {{file|clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz}} from {{file|~/.vim/plugged/YouCompleteMe/third_party/ycmd/clang_archives/}} manually. |
|||
=== VisIncr === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[https://www.vim.org/scripts/script.php?script_id=670 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/VisIncr GitHub] |
|||
!width=15%|VisIncr |
|||
|Produce increasing/decreasing columns of numbers, dates, or daynames |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|<code>:I [#]</code> |
|||
|Increment by 1 (or by #) |
|||
|- |
|||
|<code>:II [#]</code> |
|||
|Justified increment by 1 (or by #) |
|||
|- |
|||
|<code>:IX [#]</code> |
|||
|Increment (hex) by 1 (or by #) |
|||
|- |
|||
|<code>:IIX [#]</code> |
|||
|Justified increment (hex) by 1 (or by #) |
|||
|} |
|||
|} |
|||
More tips about visual increment [https://vim.fandom.com/wiki/Making_a_list_of_numbers here]. |
|||
=== Visual-increment === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/triglav/vim-visual-increment GitHub] |
|||
!width=15%|visual-increment.vim |
|||
|use CTRL+A/X to create increasing sequence of numbers or letters via visual mode |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kbctrl|A}} |
|||
|Increment |
|||
|- |
|||
|{{kbctrl|X}} |
|||
|Decrement |
|||
|} |
|||
|} |
|||
== Plugins to try == |
|||
=== Language Server === |
|||
* [https://github.com/neoclide/coc.nvim '''coc.nvim'''] — Intellisense engine for vim8 & neovim, full language server protocol support as VSCode |
|||
:Related posts [https://www.reddit.com/r/neovim/comments/bw0did/using_youcompleteme_considering_switching_to/] |
|||
* [https://github.com/autozimu/LanguageClient-neovim/ '''LanguageClient'''] — [https://github.com/Microsoft/language-server-protocol Language Server Protocol] (LSP) support for vim and neovim. |
|||
:To be combined with ''deoplete'', and ''UltiSnips'' [https://news.ycombinator.com/item?id=19530423]. |
|||
* List of LSP-compatible implementations: https://langserver.org/ |
|||
* Typescript server: https://github.com/neoclide/coc-tsserver |
|||
=== Misc === |
|||
Plugins I need to try or install some day. |
|||
* Other completion plugins, but probably not as good as YouCompleteMe (which also integrates nicely with Ultisnips and SuperTab) |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1520 vim.org] |
|||
|width=72pt| |
|||
!width=15%|OmniCppComplete |
|||
|C/C++ omni-completion with ctags database |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2620 vim.org] |
|||
|width=72pt| |
|||
!width=15%|neocomplcache |
|||
|Ultimate auto completion system for Vim |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
* [http://www.vim.org/scripts/script.php?script_id=213 '''c.vim''' : C/C++ IDE -- Write and run programs. Insert statements, idioms, comments etc.] |
|||
* [http://www.vim.org/scripts/script.php?script_id=95 '''winmanager''' : A windows style IDE for Vim 6.0] (''Referenced in TagList plugin help'') |
|||
* [http://www.vim.org/scripts/script.php?script_id=42 '''bufexplorer.zip''' : Buffer Explorer / Browser] |
|||
* [http://www.vim.org/scripts/script.php?script_id=69 '''project.tar.gz''' : Organize/Navigate projects of files (like IDE/buffer explorer)] |
|||
* [http://www.vim.org/scripts/script.php?script_id=2610 '''textobj-entire''': Text objects for entire buffer] (referenced from ''Practical Vim'') |
|||
* [http://www.vim.org/scripts/script.php?script_id=3109 '''LaTeX Box''' : Lightweight Toolbox for LaTeX] |
|||
* [http://www.vim.org/scripts/script.php?script_id=3396 '''unite.vim''' : Unite and create user interfaces] (for more WOW factor, check [http://bling.github.io/blog/2013/06/02/unite-dot-vim-the-plugin-you-didnt-know-you-need/ this blog] or the [https://github.com/Shougo/unite.vim homepage]) |
|||
* Plugin from [https://www.youtube.com/watch?v=aHm36-na4-4 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) |
|||
* [http://vim.sourceforge.net/scripts/script.php?script_id=226 '''closeb''' : Close complex brackets or tags] |
|||
: An extended version of [http://vim.sourceforge.net/scripts/script.php?script_id=13 closetag.vim]. Press {{kb|^_}} to automatically close current tag (HTML, XML, LaTeX...) |
|||
* [http://www.vim.org/scripts/script.php?script_id=2423 '''Gist''' : vimscript for gist] |
|||
* [http://www.vim.org/scripts/script.php?script_id=3681 '''functionlist.vim''' : This plugin makes it easy to navigate between functions in a long file.] |
|||
* [http://www.vim.org/scripts/script.php?script_id=397 '''ShowFunc.vim''' : Creates a list of all tags / functions from a window, all windows or buffers.] |
|||
* [http://www.vim.org/scripts/script.php?script_id=273 '''taglist.vim''' : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)] |
|||
* [http://www.vim.org/scripts/script.php?script_id=3967 '''DeleteTrailingWhitespace''' : Delete unwanted whitespace at the end of lines] |
|||
: Currently using custom mapping / ''autocmd'' (see below). |
|||
* [https://github.com/vim-syntastic/syntastic '''syntastic'''] — Syntax checking hacks for vim |
|||
* [https://github.com/rickhowe/diffchar.vim '''diffchar.vim'''] — Highlight the exact differences, based on characters and words |
|||
=== Tim Pope === |
|||
Plugins from Tim Pope: |
|||
* [https://github.com/tpope/vim-commentary '''Tim Pope's commentary''': comment stuff out] (referenced from ''Practical Vim'') |
|||
:However tComment seems more complete, and works fine for me. |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=4359 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-rsi GitHub] |
|||
!width=15%|vim-rsi '''{{red|TRY_ME}}''' |
|||
|rsi.vim: Readline style insertion |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1545 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-abolish GitHub] |
|||
!width=15%|vim-abolish |
|||
|abolish.vim: easily search for, substitute, and abbreviate multiple variants of a word |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=4472 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-obsession GitHub] |
|||
!width=15%|vim-obsession |
|||
|obsession.vim: continuously updated session files |
|||
|- |
|||
|colspan=4| |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/tpope/vim-ragtag GitHub] |
|||
!width=15%|vim-ragtag |
|||
|ragtag.vim: ghetto HTML/XML mappings (formerly allml.vim) |
|||
|- |
|||
|colspan=4|A set of mappings for HTML, XML, PHP, ASP, eRuby, JSP, and more (formerly allml) |
|||
|} |
|||
=== Videos === |
|||
Some videos that illustrates those plugins: |
|||
* [http://www.youtube.com/watch#!v=_galFWwSDt0 Top Vim Plugins (YouTube), showing Surround, SnipMate, TComment, MRU, FuzzyFinder, NerdTree, MatchIt] |
|||
* [http://alexkrispin.wordpress.com/2010/10/07/writing-latex-files-with-gvim/ Another list of nice plugins (MRU, SnipMate, VimExplorer)] |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1590 vim.org] |
|||
|width=72pt|[https://github.com/tpope/vim-unimpaired GitHub] |
|||
!width=15%|unimpaired.vim |
|||
|Pairs of handy bracket mappings |
|||
|- |
|||
|colspan=4|For interaction with plugin '''fugitive''', and quickfix mappings {{kb|[q}}, {{kb|]q}}, {{kb|[Q}}, and {{kb|]Q}}. |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=7 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/ifdef-highlighting GitHub] |
|||
!width=15%|ifdef-highlighting |
|||
|#ifdef highlighting in c/c++/idl |
|||
|} |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/LucHermitte/VimFold4C GitHub] |
|||
!width=15%|VimFold4C |
|||
|Vim folding ftplugin for C & C++ (and similar langages) |
|||
|} |
|||
Interesting plugin, but does not handle well nested <code>#ifdef</code> it seems. |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/zhaocai/GoldenView.Vim GitHub] |
|||
!width=15%|GoldenView.Vim |
|||
|Always have a nice view for vim split windows! http://zhaocai.github.io/GoldenView.Vim/ |
|||
|} |
|||
;Doxygen support |
|||
* https://github.com/vim-scripts/doxygen-support.vim (currently using DoxygenToolkit.vim). |
|||
== Uninstalled plugins == |
|||
Plugins I'm no longer using (with uninstalled date/year when available). |
|||
=== Align === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://vim.sourceforge.net/scripts/script.php?script_id=294 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/Align GitHub] |
|||
!width=15%|Align |
|||
|Help folks to align text, eqns, declarations, tables, etc |
|||
|- |
|||
|colspan=4|see [http://www.drchip.org/astronaut/vim/align.html#Examples examples]. |
|||
|} |
|||
Let's give '''vim-easy-align''' a try instead. |
|||
=== AutoClose === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1849 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/AutoClose GitHub] |
|||
!width=15%|AutoClose |
|||
|Inserts matching bracket, paren, brace or quote |
|||
|} |
|||
{| class="wikitable" width="100%" |
|||
|+Plugin - autoclose |
|||
|- |
|||
|width="120px"| |
|||
<nowiki>{{</nowiki> |
|||
| |
|||
Insert & push closing brace down a new line |
|||
|} |
|||
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 Surround plugin to surround some selected text with braces). |
|||
=== Calendar === |
|||
[https://github.com/itchyny/calendar.vim '''calendar.vim''' - A calendar application for Vim] |
|||
* <code>:Calendar</code> to launch. {{kbkey|<}} and {{kbkey|>}} to cycle through views, {{kbkey|E}} and {{kbkey|T}} to view Event list or Task list. |
|||
* <code>:Calendar 2001 1 1</code> to focus a specific date. |
|||
My settings in {{file|.vimrc}}: |
|||
<source lang=vim> |
|||
" ----- Vim-Calendar --------------------------------------------------------- |
|||
let g:calendar_week_number=1 |
|||
let g:calendar_first_day='monday' |
|||
</source> |
|||
=== ClosePairs === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2373 vim.org] |
|||
|width=72pt|[https://github.com/jiangmiao/auto-pairs GitHub] |
|||
!width=15%|ClosePairs |
|||
|Auto closes pairs of characters |
|||
|} |
|||
simpler than AutoClose, and can also delete pair of braces at once with <BS>. However breaks undo and not dot-repeatable. |
|||
Below is a patch to push down the closing brace when typing <tt>{</tt> twice (inspired from ''AutoClose'' plugin). |
|||
{{hiddenSourceFile|~/.vim/plugin/|closepairs.vim.diff|content=<source lang="diff" class="closepairs.vim.diff"> |
{{hiddenSourceFile|~/.vim/plugin/|closepairs.vim.diff|content=<source lang="diff" class="closepairs.vim.diff"> |
||
--- a/.vim/plugin/closepairs.vim |
--- a/.vim/plugin/closepairs.vim |
||
Line 164: | Line 1,538: | ||
function! s:escapepair(right) |
function! s:escapepair(right) |
||
</source>}} |
</source>}} |
||
More auto-close plugins or similar: |
|||
* https://github.com/cohama/lexima.vim |
|||
:'''Tested''' on NeoVim: '''{{red|undo broken}}''' but '''{{green|dot-repeatable}}''' (<code>.</code>). |
|||
* delimitMate by Israel Chauca Fuentes, https://github.com/Raimondi/delimitMate [http://www.vim.org/scripts/script.php?script_id=2754] |
|||
* AutoClose by Karl Guertin, https://github.com/vim-scripts/AutoClose [http://www.vim.org/scripts/script.php?script_id=1849] |
|||
* AutoClose by Thiago Alves, https://github.com/vim-scripts/AutoClose--Alves [http://www.vim.org/scripts/script.php?script_id=2009] |
|||
* '''{{red|Best so far}}''' — '''Auto Pairs''' by Miao Jiang, https://github.com/jiangmiao/auto-pairs |
|||
:'''Tested''' on NeoVim: '''{{green|undoable}}''' and '''{{green|dot-repeatable}}''' (<code>.</code>) (and should be the same on vim 7.4.849+). |
|||
* ClosePairs by Edoardo Vacchi, https://github.com/vim-scripts/ClosePairs [http://www.vim.org/scripts/script.php?script_id=2373] |
|||
* 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 [http://www.vim.org/scripts/script.php?script_id=2339] |
|||
:Requires Python. |
|||
* vim-autoclose by Townk, https://github.com/Townk/vim-autoclose |
|||
:'''Tested''' on NeoVim: '''{{red|undo broken}}''' but '''{{green|dot-repeatable}}''' (<code>.</code>). |
|||
=== Conque Shell === |
|||
More on auto-close: |
|||
{| class=wikitable width=100% |
|||
* Explanations on the issue by [http://sharats.me/vim-undo-breaks-with-auto-close-plugins.html sharat78]. |
|||
|- |
|||
* All tips and plugins on [http://vim.wikia.com/wiki/Automatically%5Fappend%5Fclosing%5Fcharacters wikia.com] |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2771 vim.org] |
|||
|width=72pt|[https://github.com/wkentaro/conque.vim/blob/master/plugin/conque_term.vim GitHub] |
|||
!width=15%|Conque Shell |
|||
|Run interactive commands inside a Vim buffer. |
|||
|} |
|||
I'm using mostly ''NeoVim'' now, and neovim native command <code>:term</code> offers a much better alternative. |
|||
=== DiffChanges === |
|||
More on the issue of dot-repeat (with list of plugins): |
|||
[http://www.vim.org/scripts/script.php?script_id=2158 '''diffchanges.vim''' : Show changes made to current buffer since the last save] |
|||
* http://stackoverflow.com/questions/883437/how-do-i-get-vim-to-automatically-put-ending-braces |
|||
* Never used. Functionality quite limited (only compared with last save). And if file is stored in Git, plugin '''fugitive''' is a much better alternative. |
|||
{| class="wikitable" width="100%" |
|||
|+Plugin - diffchanges |
|||
|- |
|||
|width="120px"| |
|||
{{kbname|Leader}}dcd<br/> |
|||
{{kbname|Leader}}dcp |
|||
| |
|||
DiffChangesDiffToggle<br/> |
|||
DiffChangesPatchToggle |
|||
|} |
|||
=== EasyTags === |
|||
<li>[https://github.com/rson/vim-bufstat '''Vim BufStat''']</li> |
|||
[http://www.vim.org/scripts/script.php?script_id=3114 '''easytags.vim''' : Automated tag file generation and syntax highlighting of tags in Vim] |
|||
*[http://vim.1045645.n5.nabble.com/MiniBufExplorer-questions-closing-a-buffer-making-it-invisible-etc-td1181293.html MiniBufExplorer questions (closing a buffer, making it invisible, etc.)] (use '''d''' in minibufexpl, :set hidden to navigate to other buf even if current modified) |
|||
* Replaced by '''AutoTag''' — syntax highlighting of tags is limited to ''c'' files; moreover ''AutoTag'' has a clever way to look for the <tt>tags</tt> file in project hierarchy. |
|||
*[http://vim.1045645.n5.nabble.com/MiniBufExplorer-question-td1163160.html Can we remap :q to :bd only when 2 or more buffer opened]? |
|||
*An alternative is [http://www.vim.org/scripts/script.php?script_id=1664 '''buftabs''': Minimalistic buffer tabs saving screen space] (more at [http://stackoverflow.com/questions/4865132/an-alternative-to-minibufexplorer-vim StackOverflow - An alternative to minibufexplorer (vim)?]) |
|||
=== FuzzyFinder (2016) === |
|||
*[http://stackoverflow.com/questions/1250943/minibufexplorer-and-nerd-tree-closing-buffers-unexpected-behavior StackOverflow - MiniBufExplorer and NERD_Tree closing buffers unexpected behavior]: See [http://vim.wikia.com/wiki/VimTip165 tip165 - bclose] + custom mapping below, :bd might just be good enough though... |
|||
[http://www.vim.org/scripts/script.php?script_id=1984 '''FuzzyFinder''' : buffer/file/command/tag/etc explorer with fuzzy matching] |
|||
<source lang="vim"> |
|||
" GRB: use fancy buffer closing that doesn't close the split |
|||
cnoremap <expr> bd (getcmdtype() == ':' ? 'Bclose' : 'bd') |
|||
</source> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1890 '''LustyExplorer''' : Dynamic filesystem and buffer explore]</li> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1984 '''FuzzyFinder''' : buffer/file/command/tag/etc explorer with fuzzy matching]</li> |
|||
* Alternative, [https://wincent.com/products/command-t Command-T] (inspired from TextMate) |
* Alternative, [https://wincent.com/products/command-t Command-T] (inspired from TextMate) |
||
* See also [http://linsong.github.com/2010/03/20/super-finder-in-vim.html Super-Finder in Vim] (using FuzzyFinder) |
* See also [http://linsong.github.com/2010/03/20/super-finder-in-vim.html Super-Finder in Vim] (using FuzzyFinder) |
||
* After <code>:set path=/path/to/project/**</code>, one can do <code>:find filename.ext</code> (See [http://stackoverflow.com/questions/3241566/is-there-a-quick-way-with-macvim-nerdtree-plugin-to-find-a-file], more details at [http://vim.wikia.com/wiki/Find_files_in_subdirectories]) |
* After <code>:set path=/path/to/project/**</code>, one can do <code>:find filename.ext</code> (See [http://stackoverflow.com/questions/3241566/is-there-a-quick-way-with-macvim-nerdtree-plugin-to-find-a-file], more details at [http://vim.wikia.com/wiki/Find_files_in_subdirectories]) |
||
* To find a file in a sub-directory, use the fuzzy query <tt>**/filename</tt> |
* To find a file in a sub-directory, use the fuzzy query <tt>**/filename</tt> |
||
<li>'''[http://vim-latex.sourceforge.net/ vim-latex]''' ([http://vim-latex.sourceforge.net/documentation/latex-suite.html documentation]</li> |
|||
Removed because superseeded by fzf.vim. |
|||
<li> [http://vim.sourceforge.net/scripts/script.php?script_id=294 '''Align''' : Help folks to align text, eqns, declarations, tables, etc] (see [http://www.drchip.org/astronaut/vim/align.html#Examples examples])</li> |
|||
<li>[https://github.com/rstacruz/sparkup '''Sparkup''' — A parser for a condensed HTML format]</li> |
|||
;Troubleshooting |
|||
Use {{kb|^e}} in edit mode to extend sparkup text, and {{kb|^n}} to go to next empty item. Some examples (more at [https://code.google.com/p/zen-coding/ Zen Coding]: |
|||
* FuzzyFinder plugin complains about: |
|||
<pre> |
|||
<source lang="text"> |
|||
div#page.section.main |
|||
Error detected while processing function 148..229..fuf#openTag: |
|||
div[title] |
|||
line 1: |
|||
a[title="Hello world" rel] |
|||
E432: Tags file not sorted: tags |
|||
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} |
|||
</pre> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=39 '''matchit.zip''' : extended % matching for HTML, LaTeX, and many other languages]</li> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2226 '''vimwiki''' : Personal Wiki for Vim ] ([https://github.com/vimwiki/vimwiki on GitHub])</li> |
|||
* {{kb|S-CR}} to continue list. |
|||
To quote a text block with <code>{{{ ... }}}</code> in visual mode, add to {{file|~/.vim/ftplugin/vimwiki_custom.vim}}: |
|||
<source lang=vim> |
|||
" Quote a block of text with {{{ }}} in visual mode |
|||
:vmap gq DO {{{<CR><ESC>P |
|||
</source> |
</source> |
||
:Tags were generated with <code>ctags --sort=foldcase -R .</code> |
|||
<li>[https://github.com/rking/ag.vim '''Silver search''' Vim plugin for the_silver_searcher, 'ag']</li> |
|||
:Solution is to set option <code>:set ignorecase</code> |
|||
* Add this to {{file|bundle/ag/plugin/ag.vim}} to add command <code>:ag</code> instead of <code>:Ag</code> [http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev]: |
|||
<source lang=vim> |
|||
=== Git-file === |
|||
cboreabbrev ag <c-r>=(getcmdtype()=':' && getcmdpos()==1 ? 'Ag' : 'ag')<CR> |
|||
[http://www.vim.org/scripts/script.php?script_id=2185 '''git:file.vim : open any version of a file in git] |
|||
For instance, to open file <tt>filename.c</tt> at commit ''HEAD~4'': |
|||
<source lang=bash> |
|||
vim HEAD~4:./filename.c |
|||
</source> |
</source> |
||
* Never used. Similar functionality available in plugin '''fugitive'''. |
|||
:And combined with plugin Ctrl-P (see below): |
|||
<source lang=vim> |
|||
" 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 |
|||
=== Hexman === |
|||
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore |
|||
{| class=wikitable width=100% |
|||
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' |
|||
|- |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=666 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/hexman.vim GitHub] |
|||
!width=15%|Hexman |
|||
|Simpler Hex viewing and editing |
|||
|} |
|||
Uninstalled because it contains the sign of the devil... Well, no, in fact because I don't use it much and standard mappings interfere with '''vim-gitgutter'''. |
|||
" ag is fast enough that CtrlP doesn't need to cache |
|||
let g:ctrlp_use_caching = 0 |
|||
=== LaTeX Text Formatter === |
|||
" AG |
|||
[http://www.vim.org/scripts/script.php?script_id=2187 '''Latex Text Formatter''' : This scripts makes it easier to format latex text] |
|||
" -- |
|||
* Does not work well (line too short, line merge too aggressive) |
|||
" bind K to grep word under cursor |
|||
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR> |
|||
endif |
|||
</source> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=3736 '''Ctrl-P''' : Fuzzy file, buffer, mru, tag, ... finder with regexp support] ([http://kien.github.io/ctrlp.vim/ home],[https://github.com/kien/ctrlp.vim/ github],[https://github.com/ctrlpvim/ctrlp.vim active fork]) (if using ''ag'', see [http://stackoverflow.com/questions/18285751/use-ag-in-ctrlp-vim this] and [https://robots.thoughtbot.com/faster-grepping-in-vim])</li> |
|||
<li>[https://github.com/wkentaro/conque.vim/blob/master/plugin/conque_term.vim '''conque.vim''': Run interactive commands inside a Vim buffer.]</li> |
|||
<li>[https://github.com/taketwo/mcf/blob/master/.vim/plugin/mcf-make-target.vim '''mcf-make-target''': Persistent make target in Vim]</li> |
|||
This plugin lets Vim to store the last arguments passed to make, and use that argument when make is invoked without arguments. For ease, define the following macro: |
|||
<source lang=vim> |
|||
:nmap <F5> :wa<CR>:Make<CR>:cw<CR> # Note the capital M to Make |
|||
</source> |
|||
To build a custom target: |
|||
<source lang=vim> |
|||
:Make <targetname> # first invocation. Store targetname for future use |
|||
<F5> # next |
|||
</source> |
|||
</ul> |
|||
=== |
=== LustyExplorer (2016) === |
||
{| class=wikitable width=100% |
|||
<ul> |
|||
|- |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1520 '''OmniCppComplete''' : C/C++ omni-completion with ctags database]</li> |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=1890 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/LustyExplorer GitHub] |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=95 '''winmanager''' : A windows style IDE for Vim 6.0] (''Referenced in TagList plugin help'')</li> |
|||
!width=15%|LustyExplorer |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=42 '''bufexplorer.zip''' : Buffer Explorer / Browser]</li> |
|||
|Dynamic filesystem and buffer explore |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2620 '''neocomplcache''' : Ultimate auto completion system for Vim]</li> |
|||
|- |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=69 '''project.tar.gz''' : Organize/Navigate projects of files (like IDE/buffer explorer)]</li> |
|||
|colspan=4|[https://github.com/sjbach/lusty More recent GitHub (merged with LustyJuggler)] |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2009 '''AutoClose''' : Auto close pair of characters] (Another version with same name than the one I tried below)</li> |
|||
|} |
|||
* See also dedicated tip entry: [http://vim.wikia.com/wiki/Automatically_append_closing_characters Automatically append closing characters] |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1643 '''SuperTab continued''' : Do all your insert-mode completion with Tab]</li> |
|||
<li> [https://github.com/tpope/vim-commentary '''Tim Pope's commentary''': comment stuff out] (referenced from ''Practical Vim'')</li> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2610 '''textobj-entire''': Text objects for entire buffer] (referenced from ''Practical Vim'')</li> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=3109 '''LaTeX Box''' : Lightweight Toolbox for LaTeX]</li> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=3396 '''unite.vim''' : Unite and create user interfaces] (for more WOW factor, check [http://bling.github.io/blog/2013/06/02/unite-dot-vim-the-plugin-you-didnt-know-you-need/ this blog] or the [https://github.com/Shougo/unite.vim homepage])</li> |
|||
<li> Plugin from [https://www.youtube.com/watch?v=aHm36-na4-4 OSCON 2013: "More Instantly Better Vim" - Damian Conway]:</li> |
|||
* 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) |
|||
<li> [http://vim.sourceforge.net/scripts/script.php?script_id=226 '''closeb''' : Close complex brackets or tags]</li> |
|||
An extended version of [http://vim.sourceforge.net/scripts/script.php?script_id=13 closetag.vim]. Press {{kb|^_}} to automatically close current tag (HTML, XML, LaTeX...) |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=2423 '''Gist''' : vimscript for gist]</li> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=3681 '''functionlist.vim''' : This plugin makes it easy to navigate between functions in a long file.]</li> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=397 '''ShowFunc.vim''' : Creates a list of all tags / functions from a window, all windows or buffers.]</li> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=273 '''taglist.vim''' : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)]</li> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=3967 '''DeleteTrailingWhitespace''' : Delete unwanted whitespace at the end of lines]</li> |
|||
Currently using custom mapping / ''autocmd'' (see below). |
|||
<li>[https://github.com/junegunn/vim-easy-align vim-easy-align]</li> |
|||
</ul> |
|||
Some videos that illustrates those plugins: |
|||
* [http://www.youtube.com/watch#!v=_galFWwSDt0 Top Vim Plugins (YouTube), showing Surround, SnipMate, TComment, MRU, FuzzyFinder, NerdTree, MatchIt] |
|||
* [http://alexkrispin.wordpress.com/2010/10/07/writing-latex-files-with-gvim/ Another list of nice plugins (MRU, SnipMate, VimExplorer)] |
|||
Removed because frequent segfaults in Neovim. Superseeded by fzf.vim. |
|||
=== Uninstalled === |
|||
<ul> |
|||
=== LustyJuggler === |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=3114 '''easytags.vim''' : Automated tag file generation and syntax highlighting of tags in Vim]</li> |
|||
{| class=wikitable width=100% |
|||
* Replaced by '''AutoTag''' — syntax highlighting of tags is limited to ''c'' files; moreover ''AutoTag'' has a clever way to look for the <tt>tags</tt> file in project hierarchy. |
|||
|- |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=1849 '''AutoClose''' : Inserts matching bracket, paren, brace or quote]<br/>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).</li> |
|||
|width=72pt|[http://www.vim.org/scripts/script.php?script_id=2050 vim.org] |
|||
|width=72pt|[https://github.com/vim-scripts/LustyJuggler GitHub] |
|||
!width=15%|LustyJuggler |
|||
|Switch very quickly among your active buffers |
|||
|- |
|||
|colspan=4|[https://github.com/sjbach/lusty More recent GitHub (merged with LustyExplorer] |
|||
|} |
|||
Removed because I don't use it. ''LustyExplorer'', ''NERDTree'' and ''FuzzyFinder'' are much better alternatives. |
|||
=== MiniBufExpl === |
|||
[http://www.vim.org/scripts/script.php?script_id=159 '''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 <tt>:bd[elete]</tt> seems to work most of the time. |
|||
* Uninstalled because found better alternative (bufstat) |
|||
:* Someone is working on improving [http://fholgado.com/minibufexpl minibufexpl (v6.4)] |
|||
=== MRU === |
|||
[http://www.vim.org/scripts/script.php?script_id=521 '''mru.vim''' : Plugin to manage Most Recently Used (MRU) files] |
|||
* Never used. And same functionality is available in '''Ctrl-P''' plugin anyway. |
|||
{{hiddenSourceFile|~/.vim/plugin/|mru.vim.diff|content=<source lang="diff" class="mru.vim.diff"> |
|||
--- 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 |
|||
</source>}} |
|||
{| class="wikitable" width="100%" |
|||
|+Plugin - MRU |
|||
|- |
|||
|width="120px"| |
|||
<nowiki>:MRU</nowiki><br/> |
|||
<nowiki>:MRU</nowiki> ''p''<br/> |
|||
{{kb|CR}}<br/> |
|||
o<br/> |
|||
t<br/> |
|||
v |
|||
| |
|||
Open MRU file list<br/> |
|||
Open MRU file list, only files containing ''p''<br/> |
|||
Open file in previous window if possible<br/> |
|||
Open file in a new window<br/> |
|||
Open file in a new tab<br/> |
|||
Open file read-only (view) |
|||
|} |
|||
=== Trinity.vim (2011) === |
|||
[http://www.vim.org/scripts/script.php?script_id=2347 '''trinity.vim''' : Build the trinity of srcexpl, taglist, NERD_tree to be a good IDE] |
|||
* [http://www.vim.org/scripts/script.php?script_id=2179 '''Source Explorer (srcexpl.vim)''' : A Source code Explorer based on tags works like context window in Source Insight] |
* [http://www.vim.org/scripts/script.php?script_id=2179 '''Source Explorer (srcexpl.vim)''' : A Source code Explorer based on tags works like context window in Source Insight] |
||
* [http://www.vim.org/scripts/script.php?script_id=273 '''taglist.vim''' : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)] |
* [http://www.vim.org/scripts/script.php?script_id=273 '''taglist.vim''' : Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)] |
||
Line 328: | Line 1,709: | ||
- let g:Tlist_Show_One_File = 1 |
- let g:Tlist_Show_One_File = 1 |
||
+ let g:Tlist_Show_One_File = 0 |
+ let g:Tlist_Show_One_File = 0 |
||
endfunction " }}} |
endfunction " }}} |
||
</source>}} |
</source>}} |
||
{{hiddenSourceFile| ~/.vim/plugin/|taglist.vim.diff|content=<source lang="diff" class="taglist.vim.diff"> |
{{hiddenSourceFile| ~/.vim/plugin/|taglist.vim.diff|content=<source lang="diff" class="taglist.vim.diff"> |
||
Line 404: | Line 1,785: | ||
" win_ctrl == newtab - Open in new tab |
" win_ctrl == newtab - Open in new tab |
||
</source>}} |
</source>}} |
||
<li> [http://www.vim.org/scripts/script.php?script_id=159 '''minibufexpl.vim''' : Elegant buffer explorer - takes very little screen space]</li> |
|||
{| class="wikitable" width="100%" |
|||
* 1st attempt: No real tab support. Seems to interfere with trinity plugin. Interesting key bindings inside though. To reassess... |
|||
|+Plugin - taglist window (:help taglist-keys) |
|||
* 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. |
|||
|width="120px"| |
|||
* '''Closing a buffer''': Use '''d''' in minibufexpl window to close a buffer, or <tt>:bd[elete]</tt> seems to work most of the time. |
|||
[[ ''or'' {{kbname|BS}}<br/> |
|||
* Uninstalled because found better alternative (bufstat) |
|||
]] ''or'' {{kbname|Tab}}<br/> |
|||
:* Someone is working on improving [http://fholgado.com/minibufexpl minibufexpl (v6.4)] |
|||
{{kbname|Space}}<br/> |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2050 '''LustyJuggler''': Switch very quickly among your active buffers]</li> |
|||
- ''or'' zc<br/> |
|||
* Removed because I don't use it (''LustyExplorer'', ''NERDTree'' and ''FuzzyFinder'' are much better alternatives) |
|||
+ ''or'' zo<br/> |
|||
<li>[http://www.vim.org/scripts/script.php?script_id=2187 '''Latex Text Formatter''' : This scripts makes it easier to format latex text]</li> |
|||
<nowiki>*</nowiki> ''or'' zR<br/> |
|||
* Does not work well (line too short, line merge too aggressive) |
|||
= ''or'' zM<br/> |
|||
<li>[https://github.com/itchyny/calendar.vim '''calendar.vim''' - A calendar application for Vim]</li> |
|||
x<br/> |
|||
* <code>:Calendar</code> to launch. {{kbkey|<}} and {{kbkey|>}} to cycle through views, {{kbkey|E}} and {{kbkey|T}} to view Event list or Task list. |
|||
{{kbname|CR}} ''or'' {{kbname|LMouse}}*2<br/> |
|||
* <code>:Calendar 2001 1 1</code> to focus a specific date. |
|||
o O<br/> |
|||
My settings in {{file|.vimrc}}: |
|||
P<br/> |
|||
p<br/> |
|||
t<br/> |
|||
u<br/> |
|||
s |
|||
| |
|||
Previous file<br/> |
|||
Next file<br/> |
|||
Show tag prototype<br/> |
|||
Close a fold<br/> |
|||
Open a fold<br/> |
|||
Open all folds<br/> |
|||
Close all folds<br/> |
|||
Maximimze/Restore window<br/> |
|||
Jump to tag location<br/> |
|||
Jump to tag location (new window, vertical)<br/> |
|||
Jump to tag location (in previous window)<br/> |
|||
tag preview (cursor remains in taglist window)<br/> |
|||
Jump to tag (new tab)<br/> |
|||
Update tags<br/> |
|||
Change the sort order |
|||
|} |
|||
=== vim-bufferline (2017) === |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/bling/vim-bufferline GitHub] |
|||
!width=15%|vim-bufferline |
|||
|Super simple vim plugin to show the list of buffers in the command bar |
|||
|} |
|||
Beware that '''airline''' interferes with '''bufferline''' settings. My settings below. |
|||
<source lang=vim> |
<source lang=vim> |
||
" ----- Vim- |
" ----- Vim-bufferline ------------------------------------------------------- |
||
let g:calendar_week_number=1 |
|||
let g:bufferline_rotate = 1 " scrolling with fixed current buffer position |
|||
let g:calendar_first_day='monday' |
|||
let g:bufferline_show_bufnr = 0 " Do not display buffer numbers |
|||
let g:bufferline_active_buffer_left = '[' " Separator used on the left side of current buffer |
|||
let g:bufferline_active_buffer_right = ']' " Separator used on the right side of current buffer |
|||
let g:airline#extensions#bufferline#overwrite_variables = 0 |
|||
</source> |
</source> |
||
<li> [http://www.vim.org/scripts/script.php?script_id=2158 '''diffchanges.vim''' : Show changes made to current buffer since the last save]</li> |
|||
* Never used. Functionality quite limited (only compared with last save). And if file is stored in Git, plugin '''fugitive''' is a much better alternative. |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=521 '''mru.vim''' : Plugin to manage Most Recently Used (MRU) files]</li> |
|||
* Never used. And same functionality is available in '''Ctrl-P''' plugin anyway. |
|||
{{hiddenSourceFile|~/.vim/plugin/|mru.vim.diff|content=<source lang="diff" class="mru.vim.diff"> |
|||
--- 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 |
|||
'''Loved it''', but unfortunately was hiding Vim messages and YCM semantic completion messages (errors/warnings). Trying to live without it... |
|||
</source>}} |
|||
<li> [http://www.vim.org/scripts/script.php?script_id=2185 '''git:file.vim : open any version of a file in git]</li> |
|||
=== Vim BufStat (2016) === |
|||
For instance, to open file <tt>filename.c</tt> at commit ''HEAD~4'': |
|||
[https://github.com/rson/vim-bufstat '''Vim BufStat'''] |
|||
<source lang=bash> |
|||
*[http://vim.1045645.n5.nabble.com/MiniBufExplorer-questions-closing-a-buffer-making-it-invisible-etc-td1181293.html MiniBufExplorer questions (closing a buffer, making it invisible, etc.)] (use '''d''' in minibufexpl, :set hidden to navigate to other buf even if current modified) |
|||
vim HEAD~4:./filename.c |
|||
*[http://vim.1045645.n5.nabble.com/MiniBufExplorer-question-td1163160.html Can we remap :q to :bd only when 2 or more buffer opened]? |
|||
*An alternative is [http://www.vim.org/scripts/script.php?script_id=1664 '''buftabs''': Minimalistic buffer tabs saving screen space] (more at [http://stackoverflow.com/questions/4865132/an-alternative-to-minibufexplorer-vim StackOverflow - An alternative to minibufexplorer (vim)?]) |
|||
*[http://stackoverflow.com/questions/1250943/minibufexplorer-and-nerd-tree-closing-buffers-unexpected-behavior StackOverflow - MiniBufExplorer and NERD_Tree closing buffers unexpected behavior]: See [http://vim.wikia.com/wiki/VimTip165 tip165 - bclose] + custom mapping below, :bd might just be good enough though... |
|||
<source lang="vim"> |
|||
" GRB: use fancy buffer closing that doesn't close the split |
|||
cnoremap <expr> bd (getcmdtype() == ':' ? 'Bclose' : 'bd') |
|||
</source> |
</source> |
||
* Never used. Similar functionality available in plugin '''fugitive'''. |
|||
Replaced by vim-airline and vim-bufferline. |
|||
</ul> |
|||
=== Vim-is=== |
|||
{| class=wikitable width=100% |
|||
|- |
|||
|width=72pt| |
|||
|width=72pt|[https://github.com/haya14busa/is.vim GitHub] |
|||
!width=15%|is.vim |
|||
|is.vim - incremental search improved |
|||
|- |
|||
|colspan=4| |
|||
{| |
|||
|- |
|||
|{{kb|Tab}} |
|||
|Move cursor to next match |
|||
|- |
|||
| {{kb|S-Tab}} |
|||
|Move cursor to previous match |
|||
|} |
|||
|} |
|||
Disabled because did not like the loss of highlight on move. I'm using this feature a lot to locate quickly some identifiers in files. |
Latest revision as of 14:44, 8 April 2023
This page is about Vim plugins.
Overview
Find a plugin
Most plugins are found on vim.org or GitHub:
- A mirror of all plugins originally found on http://www.vim.org/scripts/ ;
- GitHub.
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
Getting help
Most plugins come with local help files. Do :help local-additions
to get a list of help files for locally installed plugins.
Plugin Managers
Here I list various plugin managers. My current favorite is vim-plug.
apt-vim
Fully-automated, Cross-platform Plugin Manager for Vim.
Pathogen
Plugin manager from Tim Pope.
VAM (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.
- Install
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- Update plugins on offline computer
To update plugins on a computer that has no internet access, the simplest solution is to clone all repositories in a folder accessible by the offline computer, and use the git URL rewriting feature to point to this folder instead.
Use the following script to sync the folder, vim-plug-mirror.sh:
#! /bin/bash
die()
{
CODE=$1
shift
>&2 echo "ERROR -- $@"
exit $CODE
}
usage()
{
echo "Usage: $(basename $0) <mirror_dir>"
die 1 "$*"
}
DIR=${1%%/}
echo $DIR
[ -n "$DIR" -a -d "$(dirname "$DIR")" ] || usage "Missing <mirror_dir>"
if ! [ -d "$DIR" ]; then
echo "Creating $DIR"
mkdir "$DIR" || die 1 "Cannot create '$DIR'"
fi
PLUGINS_DIR=$(find ~/.vim/plugged -name .git|sed -r 's_/\.git__')
for plugin_dir in $PLUGINS_DIR; do
echo "Processing '$plugin_dir'"
URL=$(git -C "$plugin_dir" remote get-url origin)
plugin=$(echo $URL|sed -r 's_https://github.com/__; s_github\.com:__; s_\.git__')
PLUGINDIR=$DIR/${plugin}.git
PARENTDIR=$(dirname $PLUGINDIR)
if [ -d "$PLUGINDIR" ]; then
false && echo git -C "$PLUGINDIR" fetch --all
else
mkdir -p "$PARENTDIR" || die 1 "Cannot create '$PARENTDIR'"
git clone --mirror $URL "$PLUGINDIR"
fi
done
To use the script, simply give a folder path:
vim-plug-mirror.sh /smb/some/path
Then, on the offline machine:
sudo git config --system url./smb/some/path/.insteadOf https://github.com/
- 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.
Installed plugins
Plugins I'm currently using.
A
a.vim : Alternate Files quickly (.c --> .h etc) (forked version, the original version)
vim.org | GitHub | a.vim | Alternate Files quickly (.c --> .h etc) (original) | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Plugin high-level description, or comment on the configuration.
" Plug 'nacitar/a.vim' " Alternate Files quickly (.c --> .h etc) - fork of original
Plug 'xeyownt/a.vim' " Alternate Files quickly (.c --> .h etc) - fork of original
ack.vim
GitHub | ack.vim | Vim plugin for the Perl module / CLI script 'ack' | |||
---|---|---|---|---|---|
|
I fell back to this plugin because ag.vim is stalled. But we can still use ag as search engine.
My settings [1]:
if executable('ag')
" Use ag over grep - See ag man page for option '--vimgrep'
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
let g:ackprg = 'ag --vimgrep'
" Allow lowercase command 'ag' - see http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev
cnoreabbrev ag <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'Ack' : 'ag')<CR>
endif
Auto-Pairs
vim.org | GitHub | auto-pairs | Vim plugin, insert or delete brackets, parens, quotes in pair | ||||
---|---|---|---|---|---|---|---|
|
Tested on NeoVim: undoable and dot-repeatable (.
) (and should be the same on vim 7.4.849+).
Works better than ClosePairs and similar.
More auto-close plugins or similar:
- Tested on NeoVim: undo broken but dot-repeatable (
.
).
- delimitMate by Israel Chauca Fuentes, https://github.com/Raimondi/delimitMate [2]
- AutoClose by Karl Guertin, https://github.com/vim-scripts/AutoClose [3]
- AutoClose by Thiago Alves, https://github.com/vim-scripts/AutoClose--Alves [4]
- 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 [5]
- 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 [6]
- Requires Python.
- vim-autoclose by Townk, https://github.com/Townk/vim-autoclose
- Tested on NeoVim: undo broken but dot-repeatable (
.
).
More on auto-close plugins:
More on the issue of dot-repeat (with list of plugins):
AutoSave
vim.org | GitHub | auto-pairs | Automatically save changes to disk | ||||
---|---|---|---|---|---|---|---|
|
Useful in particular when editing TeX file with continuous compilation to view changes live in PDF viewer.
- Configuration
let g:auto_save = 1 " enable AutoSave on Vim startup
" Optional:
let g:auto_save_no_updatetime = 1 " do not change the 'updatetime' option
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode
let g:auto_save_silent = 1 " do not display the auto-save notification
let g:auto_save_postsave_hook = 'TagsGenerate' " this will run :TagsGenerate after each save
AutoTag
AutoTag : Updates entries in a tags file automatically when saving
Cpp.vim
cpp.vim: General C++ Settings (no indentation for namespace...)
- (disabled highlight of leading tabs, line length overruns, unit test header test + nice
AlterColour
function that computes new colour...)
cpsm
GitHub | cpsm | A CtrlP matcher, specialized for paths. | |||||
---|---|---|---|---|---|---|---|
|
To install:
sudo apt install libboost-all-dev cmake python-dev libicu-dev
cd ~/.vim/plugged/cpsm
./install.sh
Cscope_maps
SF | [xeyownt/cscope_maps.vim GitHub] | cscope_maps | Some boilerplate settings and keyboard mappings for cscope | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Cscope page is available on SourceForge.
- See the tutorial here
- Cscope on Vim Wiki
- One can also use cscope and ctags together
" Plug 'simplyzhao/cscope_maps.vim' " Some boilerplate settings and keyboard mappings for cscope
Plug 'xeyownt/cscope_maps.vim' " Some boilerplate settings and keyboard mappings for cscope
ctrlp.vim
vim.org | GitHub | ctrlp.vim | Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder. home | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Currently works best using ag (this and [7]) as file scanner and cpsm as match engine.
My settings:
" Set root directory
let g:ctrlp_working_path_mode = 'rwa'
" Enable filename search (instead of full path) - Ctrl-D to switch
let g:ctrlp_by_filename = 1
"
" Use AG for look-up. See https://robots.thoughtbot.com/faster-grepping-in-vim
if executable('ag')
" Use ag in CtrlP for listing files. Lightning fast and DOESN'T respect .gitignore
let g:ctrlp_user_command = 'ag %s -U -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache - BUT we are on a slow filesystem
" let g:ctrlp_use_caching = 0
endif
DoxygenToolkit.vim
GitHub | DoxygenToolkit.vim | Simplify Doxygen documentation in C, C++, Python | |||
---|---|---|---|---|---|
|
My configuration
" --- DoxygenToolkit --------------------------------------------------------------------------{{{
let g:DoxygenToolkit_briefTag_pre="@Synopsis "
let g:DoxygenToolkit_paramTag_pre="@Param "
let g:DoxygenToolkit_returnTag="@Returns "
let g:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------"
let g:DoxygenToolkit_blockFooter="----------------------------------------------------------------------------"
let g:DoxygenToolkit_authorName="Michael Peeters"
" let g:DoxygenToolkit_licenseTag=""
FastFold
GitHub | FastFold | Speed up Vim by updating folds only when called-for | |||
---|---|---|---|---|---|
|
Plug 'Konfekt/FastFold' " Speed up Vim by updating folds only when called-for
Fugitive
vim.org | GitHub | fugitive.vim | A Git wrapper so awesome, it should be illegal |
---|
Add to .vimrc:
set diffopt+=vertical " Favor vertical split for vimdiff
- Some commands
" Gdiff
:Gdiff " View differences with index
:Gdiff HEAD " View differences with HEAD
:Gdiff - " View differences with HEAD
:Gdiff ^ " View differences with previous commit
:Gdiff ~3 " View differences with 3 commits ago
" Glog
:Glog " Load previous file revision in quickfix. :cn / :cp for next/previous
:Glog -- % " Load commits (i.e. diff) impacting current file.
:Glog -Sfindme -- " Pickaxe string 'findme'
" Gedit
:Gedit " Edit back current file
- Typical workflow
- View history of changes on a file
:Glog " Load previous file revision in quickfix
:cn " next revision (or open quickfix window and <CR> to select)
:cp " previous revision (or open quickfix window and <CR> to select)
:Gdiff " View diff with version in work tree
:q " Quit diff, and return to selected revision
:Gdiff ^ " View diff with previous version
:q
:Gedit " Edit back original file
fzf.vim
GitHub | fzf.vim | fzf :heart: vim | |||||
---|---|---|---|---|---|---|---|
|
- Neovim
fzf.vim uses neovim terminal emulator. Use this mapping to have esc key leave fzf, but go to normal mode in other terminals [8]:
tnoremap <expr> <esc> &filetype == 'fzf' ? "\<esc>" : "\<c-\>\<c-n>"
IndentTab
vim.org | GitHub | IndentTab | Use tabs for indent at the beginning, spaces for alignment in the rest of a line |
---|
This plugin works better than Smart-Tabs (ctab.vim).
See also Indent with tabs & align with spaces.
- Configuration
We must make sure that it is loaded before plugin SuperTab (so that the latter can record IndentTab maps for Tab).
Plug 'xeyownt/IndentTab' | " Use tabs for indent at the beginning, spaces for alignment in the rest of a line
Plug 'ervandew/supertab' " Perform all your vim insert mode completions with Tab
" --- IndentTab -------------------------------------------------------------------------------{{{
let g:IndentTab = 1 " Enable the plugin
let g:IndentTab_IsSuperTab = 1 " Enable integration with supertab
let g:IndentTab_scopes = 'indent' " Disable 'commentprefix' and 'string', which require ingo-library
" }}}
MatchIt
matchit.zip : extended % matching for HTML, LaTeX, and many other languages
Mcf-make-target
mcf-make-target: Persistent make target in Vim This plugin lets Vim to store the last arguments passed to make, and use that argument when make is invoked without arguments. For ease, define the following macro:
: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
Repeat
Install repeat.vim : Use the repeat command (.) with supported plugins
SparkUp
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:
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}
Supertab
vim.org | GitHub | Supertab | Perform all your vim insert mode completions with Tab | ||
---|---|---|---|---|---|
|
Plug 'ervandew/supertab' " Perform all your vim insert mode completions with Tab
" --- SuperTab---------------------------------------------------------------------------------{{{
let g:SuperTabDefaultCompletionType = '<C-n>'
let g:SuperTabCrMapping = 0
" }}}
- Issues
- Tab does not work in vimwiki files
- This is because Tab is mapped by vimwiki plugin to jump to next table cell. The best work-around is to use C-n / C-p to trigger YCM completion. Alternative we can disable table mapping [9]
let g:vimwiki_table_mappings = 0
Surround
vim.org | GitHub | Surround | quoting/parenthesizing made simple. | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Plug 'tpope/vim-surround' " quoting/parenthesizing made simple.
" --- Vim-Surround ----------------------------------------------------------------------------{{{
" Use lowercase 's' instead of 'S' to surround in visual mode
xmap s <Plug>VSurround
" }}}
tComment
vim.org | GitHub | tComment | An extensible & universal comment plugin that also handles embedded filetypes | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Plug 'tomtom/tcomment_vim' " An extensible & universal comment vim-plugin that also handles embedded filetypes
Ultisnips
GitHub | ultisnips | UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips! | |||||
---|---|---|---|---|---|---|---|
GitHub | vim-snippets | vim-snipmate default snippets (Previously snipmate-snippets) | |||||
|
Ultisnips is a snippet engine written in Python. Other snippet plugins:
- snipMate, inspired from TextMate.
- https://github.com/garbas/vim-snipmate (garbas' fork), http://github.com/msanders/snipmate.vim (original, stalled)
- Another engine, also very powerful but different syntax (not compatible with vim-snippets): https://github.com/drmingdrmer/xptemplate
- Configuration
- We configure ultisnips to use ^J / ^K for expansion and next/previous, and leave Tab key for completion with plugin SuperTab (which will trigger YouCompleteMe as well).
- Another option is to use Tab for expansion (see these posts for instance).
" --- Ultisnips / vim-snippets-----------------------------------------------------------------{{{
" Use C-j/C-k for snippet expansion and next/previous.
" To use 'tab', see https://github.com/christoomey/dotfiles/blob/master/vim/rcplugins/youcompleteme-ultisnips-supertab
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsExpandTrigger = '<C-j>'
let g:UltiSnipsJumpForwardTrigger = '<C-j>'
let g:UltiSnipsJumpBackwardTrigger = '<C-k>'
- Writing snippets
- Use command
:UltiSnipsEdit
to start editing snippets for current filetype.
- This will automatically opens a private snippet definition file for the current filetype. Use
:UltiSnipsEdit!
to add snippet in public definition files.
- For advanced snippets (Python, auto-expand, use of context), see LaTeX snippets from Gilles Castel.
- Snippets
Snippets must be installed separately. Some snippets from vim-snippets:
#### C ####
main main() inc #include <...> Inc #include "..." Def #ifndef ... #define ... #endif def #define ifdef #ifdef ... #endif #if #if ... #endif once #ifndef HEADER_H .... # define HEADER_H ... #endif (Header Include-Guard) if If (...) { ... } el else { ... } t ... ? ... : ... (tertiary conditional) do do ... while ( ... ) wh while (...) { ... } for for (... = 0; ...; ...) { ... } forr for (... = ...; ...; ...) { ... } fun ... function(...) { ... } fund ... function(...;) td typedef st struct tds typedef struct tde typedef enum pr printf fpr fprintf . [ ... ] un unsigned
#### C++ ####
readfile snippet for reading file map std::map<... , ...> map... vector std::vector<...> v... ns namespace ... { ... } cl class { public: ... private: };
vim-airline
GitHub | vim-airline | lean & mean status/tabline for vim that's light as air | |
---|---|---|---|
GitHub | vim-airline-themes | A collection of themes for vim-airline | |
vim-airline-themes is optional, and here not needed since I use gruvbox for the theme.
" ----- Vim-airline ----------------------------------------------------------
let g:airline_theme= 'gruvbox'
let g:airline_section_c = '%F'
let g:airline_section_y = ''
let g:airline_section_error = ''
let g:airline_section_warning = ''
let g:airline_section_x = ''
Vim-auto-save
GitHub | vim-auto-save | Automatically save changes to disk | |
---|---|---|---|
- Configuration
let g:auto_save = 1 " enable AutoSave on Vim startup
let g:auto_save_no_updatetime = 1 " do not change the 'updatetime' option
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode
let g:auto_save_silent = 1 " do not display the auto-save notification
Vim-easy-align
GitHub | vim-easy-align | A Vim alignment plugin | |||||
---|---|---|---|---|---|---|---|
|
Vim-easymotion
vim.org | GitHub | vim-easymotion | Vim motions on speed! | ||||
---|---|---|---|---|---|---|---|
|
- Example configuration
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
Vim-gitgutter
GitHub | vim-gitgutter | A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks |
---|
Vim-incsearch
❗ | vim-incsearch is dead and create conflicts. Core is now part of vim/neovim. Use vim-is instead for extra features. |
vim.org | GitHub | incsearch.vim | Improved incremental searching for Vim | ||||
---|---|---|---|---|---|---|---|
GitHub | incsearch-easymotion.vim | Integration between incsearch and easymotion | |||||
|
See website for more features (including fuzzy search, etc.).
- Integration with easy-motion
" You can use other keymappings like <C-l> instead of <CR> if you want to
" use these mappings as default search and somtimes want to move cursor with
" EasyMotion.
function! s:incsearch_config(...) abort
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<CR>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
noremap <silent><expr> / incsearch#go(<SID>incsearch_config())
noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'}))
noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
Vim-LaTeX
vim-latex (documentation) See page vim-latex.
vim-mundo
GitHub | vim-mundo | Vim undo tree visualizer https://simnalamburt.github.io/vim-mundo | |||
---|---|---|---|---|---|
|
vim-mundo is a fork of plugin gundo (originally written by Steve Losh) that is up-to-date and works on neovim.
" --- Vim-mundo -------------------------------------------------------------------------------{{{
let g:mundo_verbose_graph = 0 " Create shorter graph
let g:mundo_inline_undo = 1 " Show a small one line diff at each node
set undofile " Enable persistent undo so that undo history persists across vim sessions
set undodir=~/.vim/undo
nnoremap <F12> :MundoToggle<CR>
" }}}
vim-ps1
GitHub | vim-ps1 | A Vim plugin for Windows PowerShell support | |||
---|---|---|---|---|---|
|
Plug 'PProvost/vim-ps1' " A Vim plugin for Windows PowerShell support
" --- PS1.vim ---------------------------------------------------------------------------------{{{
" Source: https://robindouglas.uk/powershell/vim/2018/04/05/PowerShell-with-Vim.html
if has('win32')
set shell=powershell.exe
set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command
set shellpipe=|
set shellredir=>
endif
" }}}
- Troubleshooting
- Bad indentation of closing braces: check that
equalprg
is not set in .vimrc.
Vimtex
See also Vim-tex for usage.
GitHub | vim-mundo | A modern vim plugin for editing LaTeX files. (wiki) | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||
|
- Install (using Plug)
- Add to .vimrc
Plug 'lervag/vimtex' " A modern vim plugin for editing LaTeX files.
- On Neovim, install neovim-remote.
pip3 install neovim-remote
- Configuration
" --- VimTex ----------------------------------------------------------------------------------{{{
" Inspired from https://castel.dev/post/lecture-notes-1/
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_mode=0
set conceallevel=1
let g:tex_conceal='abdmg'
if has('nvim')
let g:vimtex_compiler_progname='nvr'
endif
" }}}
In addition, the following helps for insert-mode mappings:
imap ² `
Install vim-auto-save plugin to save the file and trigger compilation regularly.
VimWiki
vim.org | GitHub | vimwiki | Personal Wiki for Vim | ||||
---|---|---|---|---|---|---|---|
|
To quote a text block with {{{ ... }}}
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
- Troubleshooting
- Tab not working anymore on
dev
branch. This is because tab is already mapped by plugin SuperTab, and Vimwiki refuses to remap.
--- a/ftplugin/vimwiki.vim
+++ b/ftplugin/vimwiki.vim
@@ -532,13 +532,9 @@ endfunction
" insert mode table mappings
if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings)
- if maparg('<Tab>', 'i') ==# ''
inoremap <expr><buffer> <Tab> vimwiki#tbl#kbd_tab()
- endif
- if maparg('<S-Tab>', 'i') ==# ''
inoremap <expr><buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
-endif
Exception not caught: VimwikiTags5: Metadata file corrupted"
[10]
- The fix is simply to delete the file vimwiki/.vimwiki_tags, and optionally run the command
:VimwikiRebuildTags
.
YouCompleteMe
GitHub | YouCompleteMe | A code-completion engine for Vim http://valloric.github.io/YouCompleteMe/
| |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
- Installation
cd .vim/plugged/YouCompleteMe
./install.py
- Configuration (without semantic completion)
- We don't configure YCM to use Tab for completion but the usual vim's map ^n and ^p.
- Instead, we install SuperTab plugin, which will also trigger YCM completion with Tab and S-Tab (thanks Christoomey).
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } " A code-completion engine for Vim
" ...
" --- YouCompleteMe----------------------------------------------------------------------------{{{
let g:ycm_autoclose_preview_window_after_completion = 1 " Auto-close preview window on completion
let g:ycm_dont_warn_on_startup = 0
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_filetype_blacklist = {}
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" Bug workaround - avoid spurious scrolling on completion when typing '.'
let g:ycm_filetype_specific_completion_to_disable = {
\ 'cpp': 1,
\ 'gitcommit': 1
\}
" }}}
- Configuration (semantic completion)
Add the default compilation flags files (see manual for more details [11]):
# file .ycm_extra_conf_cpp.py
def FlagsForFile( filename, **kwargs ):
return {
'flags': [ '-x', 'c++', '-std=gnu++14', '-Wall', '-Wextra', '-Werror', '-I.', '-Iinclude', '-I../include' ],
}
# file .ycm_extra_conf_c.py
def FlagsForFile( filename, **kwargs ):
return {
'flags': [ '-x', 'c', '-gnu11', '-Wall', '-Wextra', '-Werror', '-I.', '-Iinclude', '-I../include' ],
}
Then in .vimrc:
-Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } " A code-completion engine for Vim
+Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clang-completer' } " A code-completion engine for Vim
-let g:ycm_filetype_specific_completion_to_disable = {
- \ 'cpp': 1,
- \ 'gitcommit': 1
- \}
+let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"
❗ | Care must be taken with space in the option list. When using clang options like -I , -iquote the directory argument can be collated to the flag, like in '-Iinclude', or '-iquoteinclude', . Alternatively the flag and argmument must be split on two array element ('-iquote', 'include' ). But '-iquote include', doesn't work.
|
- Project-specific configuration
YCM can use project-specific compilation flags to report warnings / errors that are relevant to your project. YCM can either use a compilation database (such as BEAR, cmake, ninja...), or use manually defined flags. For the latter, just define a file .ycm_extra_conf.py in the root of your project:
import os
def IsCPPFile(filename):
extension = os.path.splitext(filename)[1]
return extension in ['.cpp','.cxx','.hpp','.hxx']
FLAGS_CPP = [ \
'-x', 'c++', '-Wall', '-Werror', '-std=gnu++14', '-funsigned-char', '-fshort-enums', '-fno-common', \
'-I.', '-Iinclude', '-I../include' \
]
FLAGS_C = [ \
'-x', 'c', '-Wall', '-Werror', '-std=gnu11', '-funsigned-char', '-fshort-enums', '-fno-common', \
'-I.', '-Iinclude', '-I../include' \
]
def FlagsForFile( filename, **kwargs ):
return { 'flags': FLAGS_CPP } if IsCPPFile(filename) else { 'flags': FLAGS_C }
- Configuration - offline install
- When installing on a computer without internet access, transfer the file clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz from ~/.vim/plugged/YouCompleteMe/third_party/ycmd/clang_archives/ manually.
VisIncr
vim.org | GitHub | VisIncr | Produce increasing/decreasing columns of numbers, dates, or daynames | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
More tips about visual increment here.
Visual-increment
GitHub | visual-increment.vim | use CTRL+A/X to create increasing sequence of numbers or letters via visual mode | |||||
---|---|---|---|---|---|---|---|
|
Plugins to try
Language Server
- coc.nvim — Intellisense engine for vim8 & neovim, full language server protocol support as VSCode
- Related posts [12]
- LanguageClient — Language Server Protocol (LSP) support for vim and neovim.
- To be combined with deoplete, and UltiSnips [13].
- List of LSP-compatible implementations: https://langserver.org/
- Typescript server: https://github.com/neoclide/coc-tsserver
Misc
Plugins I need to try or install some day.
- Other completion plugins, but probably not as good as YouCompleteMe (which also integrates nicely with Ultisnips and SuperTab)
vim.org | OmniCppComplete | C/C++ omni-completion with ctags database | |
---|---|---|---|
vim.org | neocomplcache | Ultimate auto completion system for Vim | |
---|---|---|---|
- 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
- project.tar.gz : Organize/Navigate projects of files (like IDE/buffer explorer)
- 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)
- 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).
- syntastic — Syntax checking hacks for vim
- diffchar.vim — Highlight the exact differences, based on characters and words
Tim Pope
Plugins from Tim Pope:
- Tim Pope's commentary: comment stuff out (referenced from Practical Vim)
- However tComment seems more complete, and works fine for me.
vim.org | GitHub | vim-rsi TRY_ME | rsi.vim: Readline style insertion |
---|---|---|---|
vim.org | GitHub | vim-abolish | abolish.vim: easily search for, substitute, and abbreviate multiple variants of a word |
---|---|---|---|
vim.org | GitHub | vim-obsession | obsession.vim: continuously updated session files |
---|---|---|---|
GitHub | vim-ragtag | ragtag.vim: ghetto HTML/XML mappings (formerly allml.vim) | |
---|---|---|---|
A set of mappings for HTML, XML, PHP, ASP, eRuby, JSP, and more (formerly allml) |
Videos
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)
vim.org | GitHub | unimpaired.vim | Pairs of handy bracket mappings |
---|---|---|---|
For interaction with plugin fugitive, and quickfix mappings [q, ]q, [Q, and ]Q. |
vim.org | GitHub | ifdef-highlighting | #ifdef highlighting in c/c++/idl |
---|
GitHub | VimFold4C | Vim folding ftplugin for C & C++ (and similar langages) |
---|
Interesting plugin, but does not handle well nested #ifdef
it seems.
GitHub | GoldenView.Vim | Always have a nice view for vim split windows! http://zhaocai.github.io/GoldenView.Vim/ |
---|
- Doxygen support
- https://github.com/vim-scripts/doxygen-support.vim (currently using DoxygenToolkit.vim).
Uninstalled plugins
Plugins I'm no longer using (with uninstalled date/year when available).
Align
vim.org | GitHub | Align | Help folks to align text, eqns, declarations, tables, etc |
---|---|---|---|
see examples. |
Let's give vim-easy-align a try instead.
AutoClose
vim.org | GitHub | AutoClose | Inserts matching bracket, paren, brace or quote |
---|
{{ |
Insert & push closing brace down a new line |
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 Surround plugin to surround some selected text with braces).
Calendar
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'
ClosePairs
vim.org | GitHub | ClosePairs | Auto closes pairs of characters |
---|
simpler than AutoClose, and can also delete pair of braces at once with <BS>. However breaks undo and not dot-repeatable.
Below is a patch to push down the closing brace when typing { twice (inspired from AutoClose plugin).
--- 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)
Conque Shell
vim.org | GitHub | Conque Shell | Run interactive commands inside a Vim buffer. |
---|
I'm using mostly NeoVim now, and neovim native command :term
offers a much better alternative.
DiffChanges
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.
Leaderdcd |
DiffChangesDiffToggle |
EasyTags
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.
FuzzyFinder (2016)
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 [14], more details at [15]) - To find a file in a sub-directory, use the fuzzy query **/filename
Removed because superseeded by fzf.vim.
- Troubleshooting
- FuzzyFinder plugin complains about:
Error detected while processing function 148..229..fuf#openTag:
line 1:
E432: Tags file not sorted: tags
- Tags were generated with
ctags --sort=foldcase -R .
- Solution is to set option
:set ignorecase
Git-file
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.
Hexman
vim.org | GitHub | Hexman | Simpler Hex viewing and editing |
---|
Uninstalled because it contains the sign of the devil... Well, no, in fact because I don't use it much and standard mappings interfere with vim-gitgutter.
LaTeX Text Formatter
Latex Text Formatter : This scripts makes it easier to format latex text
- Does not work well (line too short, line merge too aggressive)
LustyExplorer (2016)
vim.org | GitHub | LustyExplorer | Dynamic filesystem and buffer explore |
---|---|---|---|
More recent GitHub (merged with LustyJuggler) |
Removed because frequent segfaults in Neovim. Superseeded by fzf.vim.
LustyJuggler
vim.org | GitHub | LustyJuggler | Switch very quickly among your active buffers |
---|---|---|---|
More recent GitHub (merged with LustyExplorer |
Removed because I don't use it. LustyExplorer, NERDTree and FuzzyFinder are much better alternatives.
MiniBufExpl
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)
- Someone is working on improving minibufexpl (v6.4)
MRU
mru.vim : Plugin to manage Most Recently Used (MRU) files
- Never used. And same functionality is available in Ctrl-P plugin anyway.
--- 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
:MRU |
Open MRU file list |
Trinity.vim (2011)
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
--- 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
[[ or BS |
Previous file |
vim-bufferline (2017)
GitHub | vim-bufferline | Super simple vim plugin to show the list of buffers in the command bar |
---|
Beware that airline interferes with bufferline settings. My settings below.
" ----- Vim-bufferline -------------------------------------------------------
let g:bufferline_rotate = 1 " scrolling with fixed current buffer position
let g:bufferline_show_bufnr = 0 " Do not display buffer numbers
let g:bufferline_active_buffer_left = '[' " Separator used on the left side of current buffer
let g:bufferline_active_buffer_right = ']' " Separator used on the right side of current buffer
let g:airline#extensions#bufferline#overwrite_variables = 0
Loved it, but unfortunately was hiding Vim messages and YCM semantic completion messages (errors/warnings). Trying to live without it...
Vim BufStat (2016)
- 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...
" GRB: use fancy buffer closing that doesn't close the split
cnoremap <expr> bd (getcmdtype() == ':' ? 'Bclose' : 'bd')
Replaced by vim-airline and vim-bufferline.
Vim-is
GitHub | is.vim | is.vim - incremental search improved | |||||
---|---|---|---|---|---|---|---|
|
Disabled because did not like the loss of highlight on move. I'm using this feature a lot to locate quickly some identifiers in files.