lambdalisue / vim-manpager

Use Vim as a MANPAGER program
MIT License
62 stars 5 forks source link

built-in manpager #12

Closed Konfekt closed 8 years ago

Konfekt commented 8 years ago

Turns out there is a built in Man command. The following snippet in .vimrc is a good built-in alternative to this manviewer:

if !empty($MAN_PN)
command! -nargs=0 MANPAGER call s:MANPAGER()

fun! s:MANPAGER()
  bwipe!

  let page = expand('$MAN_PN')
  let page_pattern = '\v[a-zA-Z][0-9a-zA-Z-]+'
  let sec_pattern = '\v\(' . '((\d+(\+\d+|\w+)*)|(\w))' . '\)'
  let sec = substitute(matchstr(page, sec_pattern), '\v[()]', '', 'g')
  let page = substitute(page, sec_pattern, '', '')
  setlocal filetype=man
  exe 'Man ' sec . ' ' . page

  delcommand MANPAGER
endf
endif

It uses however <c-] and <c-t> for jumps. So

nnoremap <nowait><buffer> q    :quit<cr>
nmap     <nowait><buffer> <cr> <c-]>
nmap     <nowait><buffer> K    <c-]>
nmap     <nowait><buffer> <s-tab>    <c-t>

in ftplugin/man.vim may turn it more intuitive.

lambdalisue commented 8 years ago

?

Konfekt commented 8 years ago

Just for reference. Often Vim has already everything accumulated in his long history ut got forgotten. See ftplugin/man.vim

lambdalisue commented 8 years ago

it's written in README :-]

Konfekt commented 8 years ago

Ah, ok you got me confused by reimplementing the c-] map.