I'm using Vim to develop C on Linux. When I press K in order to open man page for the underlying word, I don't have control on which man section is opened. Is there a way to specify that somewhere ?
Quoting from the documentation
When 'keywordprg' is equal to "man -s", a count before "K" is inserted after the "-s". If there is no count, the "-s" is removed.
man -s seems to be the default for the
'keywordprg' setting, so simplying using a count before typing K seems to do the trick.
(Tested successfully with 2K and 3K and the cursor being on
*K* K Run a program to lookup the keyword under the cursor. [...] Special cases: - When 'keywordprg' is equal to "man" or starts with ":", a [count] before "K" is inserted after keywordprg and before the keyword. For example, using "2K" while the cursor is on "mkdir", results in: !man 2 mkdir - When 'keywordprg' is equal to "man -s", a count before "K" is inserted after the "-s". If there is no count, the "-s" is removed.
So 3K should do the trick
If you're on Linux, you're likely using mandb's
man, and you can control the order in which sections are searched. See
man 1 man:
If $MANSECT is set, its value is a colon-delimited list of sections and it is used to determine which manual sections to search and in what order. The default is "1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6 7", unless overridden by the SECTION directive in /etc/manpath.config.
So another option is to set in your shell initialisation files:
MANSECT=3:3posix:3pm:3perl:3am:1:n:l:8:2:5:4:9:6:7 export MANSECT
Or in your vimrc:
(Also, depending on what you're programming, section 2 might also need a higher priority.)
(Or, as the manpage says, set system-wide in
This also works for FreeBSD's man.