Opening manpages from within Vim

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening manpages from within Vim

Badmagic

Hello,

I'm aware of Vim's ability to open manpages using the Shift-k key
combination and I find it very useful - most of the time.

The problem I have is this. Say for example, I put the cursor on
'printf' and press Shift-k, the manpage that opens is 'printf(1)' but
the manpage I'm after is 'printf(3C)'. Is there a way to fix this? I'm
using Solaris 10.

Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

fuzzymo

I'm not sure I can help with 3C, but using a number before the K will
use that as the section if you have keywordprg set to "man"

Example:

2K while on printf will issue "man 2 printf"

You could also set keywordprg to "man -a" and it would always show you
every matching man page.

Fuzzy

On Sun, May 11, 2008 at 5:48 AM, badmagic <[hidden email]> wrote:

>  Hello,
>
>  I'm aware of Vim's ability to open manpages using the Shift-k key
>  combination and I find it very useful - most of the time.
>
>  The problem I have is this. Say for example, I put the cursor on
>  'printf' and press Shift-k, the manpage that opens is 'printf(1)' but
>  the manpage I'm after is 'printf(3C)'. Is there a way to fix this? I'm
>  using Solaris 10.
>
>  Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Zbigniew Kowalski

Can U tell me pls where this feature is described in VIM help. I cant
find it there.
regards & thanks
Z

BTW on windows S-k opens help for vim scripts. I'd like to know how
one configures this behavor.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Tony Mechelynck

On 13/05/08 11:59, Zbikow wrote:
> Can U tell me pls where this feature is described in VIM help. I cant
> find it there.
> regards&  thanks
> Z
>
> BTW on windows S-k opens help for vim scripts. I'd like to know how
> one configures this behavor.

        :help K
        :help 'keywordprg'

On Unix-like systems, the default 'keywordprg' is "man" which displays
the "manual" for the program whose name is given as argument. On Windows
you got to know which command (if any) will similarly open a "help page"
for any command given as argument ("help" maybe?) and set that command
as 'keywordprg'.

Note that Vim handles 'keywordprg' specially when set to "man" or "man
-s" in order to translate any [count] as a "section number" for the man
command.


Best regards,
Tony.
--
Molecule, n.:
        The ultimate, indivisible unit of matter.  It is distinguished
from the corpuscle, also the ultimate, indivisible unit of matter, by a
closer resemblance to the atom, also the ultimate, indivisible unit of
matter ... The ion differs from the molecule, the corpuscle and the
atom in that it is an ion ...
        -- Ambrose Bierce, "The Devil's Dictionary"

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Badmagic
In reply to this post by fuzzymo

Fuzzy Logic wrote:

> I'm not sure I can help with 3C, but using a number before the K will
> use that as the section if you have keywordprg set to "man"
>
> Example:
>
> 2K while on printf will issue "man 2 printf"
>
> You could also set keywordprg to "man -a" and it would always show you
> every matching man page.
>
> Fuzzy
>
> On Sun, May 11, 2008 at 5:48 AM, badmagic <[hidden email]> wrote:
>
>>  Hello,
>>
>>  I'm aware of Vim's ability to open manpages using the Shift-k key
>>  combination and I find it very useful - most of the time.
>>
>>  The problem I have is this. Say for example, I put the cursor on
>>  'printf' and press Shift-k, the manpage that opens is 'printf(1)' but
>>  the manpage I'm after is 'printf(3C)'. Is there a way to fix this? I'm
>>  using Solaris 10.
>>
>>  Thanks in advance.
>
> Thanks for your suggestion but I've been playing around with it for
quite a while now and can't get it to work. No matter what I try,
Shift-k on printf (for example) ALWAYS wants to open printf(1). I need
printf(3c).

I'm starting to think there is no solution to this one - which surprises
me.

Any Solaris users out there come across this issue?

Regards,
BM

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Gary Johnson

On 2008-05-13, badmagic <[hidden email]> wrote:

> Fuzzy Logic wrote:
> > I'm not sure I can help with 3C, but using a number before the K will
> > use that as the section if you have keywordprg set to "man"
> >
> > Example:
> >
> > 2K while on printf will issue "man 2 printf"
> >
> > You could also set keywordprg to "man -a" and it would always show you
> > every matching man page.
> >
> > Fuzzy
> >
> > On Sun, May 11, 2008 at 5:48 AM, badmagic <[hidden email]> wrote:
> >
> >>  Hello,
> >>
> >>  I'm aware of Vim's ability to open manpages using the Shift-k key
> >>  combination and I find it very useful - most of the time.
> >>
> >>  The problem I have is this. Say for example, I put the cursor on
> >>  'printf' and press Shift-k, the manpage that opens is 'printf(1)' but
> >>  the manpage I'm after is 'printf(3C)'. Is there a way to fix this? I'm
> >>  using Solaris 10.
> >>
> >>  Thanks in advance.
> >
> > Thanks for your suggestion but I've been playing around with it for
> quite a while now and can't get it to work. No matter what I try,
> Shift-k on printf (for example) ALWAYS wants to open printf(1). I need
> printf(3c).
>
> I'm starting to think there is no solution to this one - which surprises
> me.
>
> Any Solaris users out there come across this issue?

I use Solaris but don't use K to access man pages.  The problem is
that the page you're looking for is in section 3c, so the command to
man needs to be

   man -s 3c printf

yet vim won't allow 3c as a prefix (count) before the K.

   man -s 3 printf

doesn't work, as you have discovered, because on Solaris, section 3c
is different from section 3.

I can't think of a solution at the moment.

Regards,
Gary


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

John Little-4

In Solaris man the -s option can have have several sections separated
by a comma.  I would have expected that man.cf files would be set up
to do this by default, though.
  HTH
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Gary Johnson

On 2008-05-13, John Little <[hidden email]> wrote:
> In Solaris man the -s option can have have several sections separated
> by a comma.  I would have expected that man.cf files would be set up
> to do this by default, though.

The section order probably is specified in man.cf files.  The
problem for the OP is that the order is 1,1m,1s,2,3,3c,....

Here's an idea.  How about setting 'keywordprg' in
~/.vim/after/ftplugin/c.vim like so:

   setlocal keywordprg=man\ -s\ 2,3,3c,3malloc,3dl,3nsl,3socket,3ldap,3nisdb,3rac,3resolv,3rpc,3slp,3xfn,3proc,3rt,3thr,3elf,3kvm,3kstat,3m,3mp,3pam,3sched,3aio,3bsm,3cpc,3sec,3secdb,3smartcard,3cfgadm,3crypt,3devid,3devinfo,3door,3lib,3libucb,3head,3nvpair,3rsm,7,7d,7fs,7i,7m,7p,9,9e,9f,9s,4,5,4b,3gen,3exacct,3sysevent,3wsreg,3dmi,3snmp,3tnf,3volmgt,3mail,3layout,3ext,3picl,3picltree,1b,1c,1f,3ucb,3xnet,3curses,3plot,3xcurses,3gss,6,l,n,1,1m,1s

(That's all one line.)  That's the same as the MANSECTS
configuration in /usr/share/man/man.cf except that sections 1, 1m
and 1s have been moved to end of the list.  Then, while working on C
source, where the user is presumably more interested in sections 2
and 3 than in 1, those sections are searched first.

I gave it a try and it seems to work.  That is, I opened a C source
file, put the cursor over "printf" and typed K.  Up came the
printf(3C) man page.

Regards,
Gary


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Badmagic

Gary Johnson wrote:

> On 2008-05-13, John Little <[hidden email]> wrote:
>> In Solaris man the -s option can have have several sections separated
>> by a comma.  I would have expected that man.cf files would be set up
>> to do this by default, though.
>
> The section order probably is specified in man.cf files.  The
> problem for the OP is that the order is 1,1m,1s,2,3,3c,....
>
> Here's an idea.  How about setting 'keywordprg' in
> ~/.vim/after/ftplugin/c.vim like so:
>
>    setlocal keywordprg=man\ -s\ 2,3,3c,3malloc,3dl,3nsl,3socket,3ldap,3nisdb,3rac,3resolv,3rpc,3slp,3xfn,3proc,3rt,3thr,3elf,3kvm,3kstat,3m,3mp,3pam,3sched,3aio,3bsm,3cpc,3sec,3secdb,3smartcard,3cfgadm,3crypt,3devid,3devinfo,3door,3lib,3libucb,3head,3nvpair,3rsm,7,7d,7fs,7i,7m,7p,9,9e,9f,9s,4,5,4b,3gen,3exacct,3sysevent,3wsreg,3dmi,3snmp,3tnf,3volmgt,3mail,3layout,3ext,3picl,3picltree,1b,1c,1f,3ucb,3xnet,3curses,3plot,3xcurses,3gss,6,l,n,1,1m,1s
>
> (That's all one line.)  That's the same as the MANSECTS
> configuration in /usr/share/man/man.cf except that sections 1, 1m
> and 1s have been moved to end of the list.  Then, while working on C
> source, where the user is presumably more interested in sections 2
> and 3 than in 1, those sections are searched first.
>
> I gave it a try and it seems to work.  That is, I opened a C source
> file, put the cursor over "printf" and typed K.  Up came the
> printf(3C) man page.
>
> Regards,
> Gary
>
>
>
Gary, you're a legend!

It worked like a charm. Thank you so much.

I stuck it in my ~/.vimrc file and all's well now.

  Thanks to all those who offered assistance as well.

Happy vimming.

Regards,
BM (Steve)

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

scott-268

On Wednesday 14 May 2008 05:34, badmagic wrote:

>
> Gary Johnson wrote:
> > On 2008-05-13, John Little <[hidden email]> wrote:
> >> In Solaris man the -s option can have have several sections separated
> >> by a comma.  I would have expected that man.cf files would be set up
> >> to do this by default, though.
> >
> > The section order probably is specified in man.cf files.  The
> > problem for the OP is that the order is 1,1m,1s,2,3,3c,....
> >
> > Here's an idea.  How about setting 'keywordprg' in
> > ~/.vim/after/ftplugin/c.vim like so:
> >
> >    setlocal keywordprg=man\ -s\ 2,3,3c,3malloc,3dl,3nsl,3socket,3ldap,3nisdb,3rac,3resolv,3rpc,3slp,3xfn,3proc,3rt,3thr,3elf,3kvm,3kstat,3m,3mp,3pam,3sched,3aio,3bsm,3cpc,3sec,3secdb,3smartcard,3cfgadm,3crypt,3devid,3devinfo,3door,3lib,3libucb,3head,3nvpair,3rsm,7,7d,7fs,7i,7m,7p,9,9e,9f,9s,4,5,4b,3gen,3exacct,3sysevent,3wsreg,3dmi,3snmp,3tnf,3volmgt,3mail,3layout,3ext,3picl,3picltree,1b,1c,1f,3ucb,3xnet,3curses,3plot,3xcurses,3gss,6,l,n,1,1m,1s
> >
> > (That's all one line.)  That's the same as the MANSECTS
> > configuration in /usr/share/man/man.cf except that sections 1, 1m
> > and 1s have been moved to end of the list.  Then, while working on C
> > source, where the user is presumably more interested in sections 2
> > and 3 than in 1, those sections are searched first.
> >
> > I gave it a try and it seems to work.  That is, I opened a C source
> > file, put the cursor over "printf" and typed K.  Up came the
> > printf(3C) man page.
> >
> > Regards,
> > Gary
> >
> >
> >
> Gary, you're a legend!
>
> It worked like a charm. Thank you so much.
>
> I stuck it in my ~/.vimrc file and all's well now.
>
>   Thanks to all those who offered assistance as well.
>
> Happy vimming.
>
> Regards,
> BM (Steve)

while we're on the subject of man pages in vim, i'd like to
ask if this is supposed to work in gvim as well as vim --
it works perfectly in vim, but when i try it in gvim i get

    WARNING: terminal is not fully functional

then when i hit enter the man page displays with weird
gobbledygook mixed in with the man-page information

i only just learned about this function from reading this
thread, but it looks as if it could be useful, so i thought
i'd ask

i looked for help on S-K and got nothing relevant, but help
on man was there, and it didn't say anything about it not
working in gvim

tia,

sc



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Opening manpages from within Vim

Benjamin Fritz

On 5/14/08, sc <[hidden email]> wrote:
>
>  i looked for help on S-K and got nothing relevant
>

Probably because you don't need the shift modifier.

Just do :help K

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---