junegunn / fzf.vim

fzf :heart: vim
MIT License
9.59k stars 582 forks source link

Feature Request: Add command for searching available man pages #1389

Open AlxHnr opened 2 years ago

AlxHnr commented 2 years ago

It would be great to provide a default command for searching available man-pages. This would complement commands like :Helptags and fits well into commands with external dependencies like :Locate, :Rg and :Commits.

kattrali commented 11 months ago

I went looking for something similar, and turned up this issue. For future travelers, this worked well for my purposes:

command! -bang -nargs=? Apropos
    \ call fzf#vim#grep('man --apropos '.fzf#shellescape(<q-args>), {
    \   'sink': {line -> execute('Man '. join(split(line, ' ')[:1],''))},
    \   'options': ['--preview', 'echo {1} | awk "{print \$1\$2}" | xargs man']
    \ }, <bang>0)

which is roughly equivalent to the command:

man -k $WORD | fzf --preview='man {1}{2}' | awk '{print $1$2}' | xargs man