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!
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>
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.
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.
This might help:
OmniCppComplete - C/C++ omni-completion with ctags database
Also take a look at this:
C++ code completion
You can also take a look at Vim Intellisense for C++:
Vim Intellisense - C++ Plug-in
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With