'looking up c++ documentation inside of vim
I code c++, using vim.
Often times, I find myself wasting time (and brekaing flow) looking up trivial things like:
is std::string.substring does it take (start, length) or (start, end).
This often results in open browser; wait; search on google; first link useless, try second link; okay, done.
How do others do this in vim? Is there a nice *.tgz I can download of standard function documentation and somehow reference them inside of vim?
Thanks!
Solution 1:[1]
You can also use cppman which provides:
C++ 98/11/14 manual pages for Linux/MacOS

Then you could use it in place of man when typing ShiftK in Vim (cf. @alesplin's answer):
autocmd FileType cpp set keywordprg=cppman
That would open a nice man-like page with the STL documentation that you can navigate with the Vim pager.
For a better integration with Vim, it could probably be used with vim-man or any other similar plugin.
Personally, I bypassed keywordprg by remapping ShiftK for C++ files, and I open a tmux split:
command! -nargs=+ Cppman silent! call system("tmux split-window cppman " . expand(<q-args>))
autocmd FileType cpp nnoremap <silent><buffer> K <Esc>:Cppman <cword><CR>
Solution 2:[2]
I don't program in C++, but if there are man pages for the functions in question, you can access them by placing the cursor over the function name and hitting ShiftK. This only works for functions that have a man page installed, so your mileage may vary.
Solution 3:[3]
Recommend zeal, it's an offline documentation browser. With zealvim, you can just use \z to get the definition of current word base on filetype.
Solution 4:[4]
This might help:
OmniCppComplete - C/C++ omni-completion with ctags database
Also take a look at this:
You can also take a look at Vim Intellisense for C++:
Solution 5:[5]
Not really an answer as it is not "inside vim"... but why don't you cut the "open browser, search Google" part? Just point your browser at a good API documentation, and keep it open. http://www.dinkumware.com/manuals/default.aspx is my favourite (which can be downloaded for offline reference, too), http://www.cplusplus.com/reference/ is not bad either. A window switch and two or three clicks later you have your answer; I doubt an "inside vim" solution could be much less disruptive to your workflow.
That being said, having a solution inside vim would be nice for those who are working on a text-only interface, so I am looking forward to the other answers. ;-)
Solution 6:[6]
I know it's an old question, but I was searching for the same thing and none of the answer was helpful for me. If anyone else come to this question, they might find this useful.
You should use CRefVim Plugin. With this you will have full access to c reference manual. It's for C, not for C++, but still it's very handy.
The usage:
There are several ways to specify a word CRefVim should search for in order
to view help:
cr normal mode: get help for word under cursor
Memory aid cr: (c)-(r)eference
cr visual mode: get help for visually selected text
Memory aid cr: (c)-(r)eference
cw: prompt for word CRefVim should search for
Memory aid cw: (c)-reference (w)hat
cc: jump to table of contents of the C-reference manual
Memory aid cc: (c)-reference (c)ontents
Note: by default is \, e.g. press \cr to invoke C-reference
Note: The best way to search for an operator (++, --, %, ...) is to visually
select it and press cr.
To get help do :help crefvimdoc
To show the C-reference manual do :help crefvim
You can use :help too. To search help for a function use it like this
:help crv-FUNCTION_NAME
With :h crv-strlen, you will find help for strlen() function. :h crv-operator will help you to find the section about C operators.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | alesplin |
| Solution 3 | Hongbo Liu |
| Solution 4 | |
| Solution 5 | DevSolar |
| Solution 6 | sakibmoon |

