Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

looking up c++ documentation inside of vim

Tags:

c++

vim

doc

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!

like image 862
anon Avatar asked Feb 16 '10 12:02

anon


4 Answers

You can also use cppman which provides:

C++ 98/11/14 manual pages for Linux/MacOS

enter image description here

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>

tmux

like image 91
BenC Avatar answered Nov 18 '22 20:11

BenC


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.

like image 11
alesplin Avatar answered Nov 18 '22 21:11

alesplin


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.

like image 5
Hongbo Liu Avatar answered Nov 18 '22 19:11

Hongbo Liu


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

like image 4
Robert S. Barnes Avatar answered Nov 18 '22 20:11

Robert S. Barnes