diff --git a/README.md b/README.md index f17622e..fe52607 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Commands | `History` | `v:oldfiles` and open buffers | | `Snippets` | Snippets ([UltiSnips][us]) | | `Commands` | User-defined commands | +| `Helptags` | Help tags | - Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key bindings to open in a new tab, a new split, or in a new vertical split. diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index 9613649..c11b431 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -70,6 +70,7 @@ COMMANDS *fzf-vim-commands* `History` | `v:oldfiles` and open buffers `Snippets` | Snippets ({UltiSnips}{6}) `Commands` | User-defined commands + `Helptags` | Help tags -----------------+--------------------------------------------------------------------- - Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 0813110..516ceac 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -472,6 +472,24 @@ endfunction command! -bang Marks call s:marks(0) +" ------------------------------------------------------------------ +" Help tags +" ------------------------------------------------------------------ +function! s:helptag_sink(line) + execute 'help' split(a:line)[0] +endfunction + +function! s:helptags(bang) + let tags = split(globpath(&runtimepath, '**/doc/tags'), '\n') + + call s:fzf({ + \ 'source': 'cat '.join(map(tags, 'shellescape(v:val)'))."| sort | awk '{printf \"%-40s%s\\n\", $1, $2}'", + \ 'sink': function('s:helptag_sink'), + \ 'options': '+m --tiebreak=begin'}, a:bang) +endfunction + +command! -bang Helptags call s:helptags(0) + " ---------------------------------------------------------------------------- " Completion helper " ----------------------------------------------------------------------------