diff --git a/README.md b/README.md
index 6fc2d18d..8baf2ed4 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,7 @@ Commands
| `:Commands` | Commands |
| `:Maps` | Normal mode mappings |
| `:Helptags` | Help tags [1](#helptags) |
+| `:Manpages` | Man pages |
| `:Filetypes` | File types
- Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key
diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim
index 61f70a0f..2b61076e 100755
--- a/autoload/fzf/vim.vim
+++ b/autoload/fzf/vim.vim
@@ -379,6 +379,16 @@ function! s:action_for(key, ...)
endif
endfunction
+let s:default_cmd_mod = {
+ \ 'ctrl-t': 'tab',
+ \ 'ctrl-x': 'horizontal',
+ \ 'ctrl-v': 'vertical' }
+
+function! s:cmd_mod_for(key)
+ let mod = get(get(g:, 'fzf_cmd_mod', s:default_cmd_mod), a:key, '')
+ return type(mod) == s:TYPE.string ? mod : ''
+endfunction
+
function! s:open(target)
if fnamemodify(a:target, ':p') ==# expand('%:p')
return
@@ -1330,13 +1340,16 @@ endfunction
" ------------------------------------------------------------------
" Help tags
" ------------------------------------------------------------------
-function! s:helptag_sink(line)
- let [tag, file, path] = split(a:line, "\t")[0:2]
+function! s:helptag_sink(lines)
+ if len(a:lines) < 2
+ return
+ endif
+ let [tag, file, path] = split(a:lines[1], "\t")[0:2]
let rtp = fnamemodify(path, ':p:h:h')
if stridx(&rtp, rtp) < 0
execute 'set rtp+='.s:escape(rtp)
endif
- execute 'help' tag
+ execute s:cmd_mod_for(a:lines[0]) 'help' tag
endfunction
function! fzf#vim#helptags(...)
@@ -1354,10 +1367,31 @@ function! fzf#vim#helptags(...)
call writefile(['for my $filename (@ARGV) { open(my $file,q(<),$filename) or die; while (<$file>) { /(.*?)\t(.*?)\t(.*)/; push @lines, sprintf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\t%s\n), $1, $2, $filename, $3); } close($file) or die; } print for sort @lines;'], s:helptags_script)
return s:fzf('helptags', {
\ 'source': 'perl '.fzf#shellescape(s:helptags_script).' '.join(map(tags, 'fzf#shellescape(v:val)')),
- \ 'sink': s:function('s:helptag_sink'),
+ \ 'sink*': s:function('s:helptag_sink'),
\ 'options': ['--ansi', '+m', '--tiebreak=begin', '--with-nth', '..3']}, a:000)
endfunction
+" ------------------------------------------------------------------
+" Man pages
+" ------------------------------------------------------------------
+function! s:manpage_sink(lines)
+ if len(a:lines) < 2
+ return
+ endif
+ let [page, section] = split(a:lines[1])[0:1]
+ if exists(":Man") != 2
+ runtime ftplugin/man.vim
+ endif
+ execute s:cmd_mod_for(a:lines[0]) 'Man' section[1:-2] page
+endfunction
+
+function! fzf#vim#manpages(...)
+ return s:fzf('manpages', {
+ \ 'source': 'man --apropos .',
+ \ 'sink*': s:function('s:manpage_sink'),
+ \ 'options': ['--preview', 'man {1}', '--prompt=Man>']}, a:000)
+endfunction
+
" ------------------------------------------------------------------
" File types
" ------------------------------------------------------------------
diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt
index d2179d27..3c0398fe 100644
--- a/doc/fzf-vim.txt
+++ b/doc/fzf-vim.txt
@@ -136,6 +136,7 @@ COMMANDS *fzf-vim-commands*
`:Commands` | Commands
`:Maps` | Normal mode mappings
`:Helptags` | Help tags [1]
+ `:Manpages` | Man pages
`:Filetypes` | File types
-----------------------+--------------------------------------------------------------------------------------
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 622fb83e..427e3ac3 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -70,6 +70,7 @@ call s:defs([
\'command! -bar -bang Marks call fzf#vim#marks(0)',
\'command! -bar -bang Changes call fzf#vim#changes(0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), 0)',
+\'command! -bar -bang Manpages call fzf#vim#manpages(0)',
\'command! -bar -bang Windows call fzf#vim#windows(fzf#vim#with_preview({ "placeholder": "{2}" }), 0)',
\'command! -bar -bang -nargs=* -range=% -complete=file Commits let b:fzf_winview = winsaveview() | ,call fzf#vim#commits(, fzf#vim#with_preview({ "placeholder": "" }), 0)',
\'command! -bar -bang -nargs=* -range=% BCommits let b:fzf_winview = winsaveview() | ,call fzf#vim#buffer_commits(, fzf#vim#with_preview({ "placeholder": "" }), 0)',