查找 c++ vim 内的文档
我使用 vim 编写 c++ 代码。
很多时候,我发现自己浪费时间(和中断流程)查找琐碎的事情,例如:
std::string.substring 是否需要(开始,长度)或(开始,结束)。
这通常会导致浏览器打开;等待;在谷歌上搜索;第一个链接没用,尝试第二个链接;好的,完成。
其他人如何在 vim 中做到这一点?有没有一个很好的 *.tgz 我可以下载标准函数文档并以某种方式在 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您还可以使用 cppman 它提供:
然后您可以使用它代替
man
在 Vim 中输入 ShiftK 时(参见 @alesplin 的回答):这会打开一个类似
man
的漂亮页面您可以使用 Vim 寻呼机浏览 STL 文档。为了更好地与 Vim 集成,它可以与 vim-man 或任何其他类似的工具一起使用插件。
就我个人而言,我通过为 C++ 文件重新映射 ShiftK 绕过了
keywordprg
,然后打开 tmux split:You can also use cppman which provides:
Then you could use it in place of
man
when typing ShiftK in Vim (cf. @alesplin's answer):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:我不使用 C++ 编程,但如果有相关函数的手册页,您可以通过将光标放在函数名称上并点击 ShiftK 来访问它们。这仅适用于安装了手册页的功能,因此您的情况可能会有所不同。
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.
推荐zeal,它是一个离线文档浏览器。使用 zealvim,您只需使用
\z
即可获取定义基于文件类型的当前单词。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.这可能会有所帮助:
OmniCppComplete - 使用 ctags 数据库进行 C/C++ 全方位补全
另请看一下:
C++ 代码完成
您还可以查看 C++ 的 Vim Intellisense:
Vim Intellisense - C++ 插件
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
我知道这是一个老问题,但我一直在寻找同样的东西,但没有一个答案对我有帮助。如果其他人提出这个问题,他们可能会发现这很有用。
你应该使用 CRefVim 插件。这样您就可以完全访问 c 参考手册。它适用于 C,而不是 C++,但仍然非常方便。
用法:
您也可以使用
:help
。要搜索函数的帮助,请像这样使用:h crv-strlen
,您将找到strlen()
函数的帮助。:h crv-operator
将帮助您找到有关 C 运算符的部分。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:
You can use
:help
too. To search help for a function use it like thisWith
:h crv-strlen
, you will find help forstrlen()
function.:h crv-operator
will help you to find the section about C operators.这并不是一个真正的答案,因为它不是“在 vim 内部”...但是你为什么不删除“打开浏览器,搜索 Google”部分呢?只需将您的浏览器指向一个好的 API 文档并保持打开状态即可。 http://www.dinkumware.com/manuals/default.aspx 是我的最爱(也可以下载供离线参考),http://www.cplusplus.com/reference/< /a> 也不错。切换一下窗口,点击两三下,你就会得到答案;我怀疑“内部 vim”解决方案对您的工作流程的干扰会小得多。
话虽如此,对于那些在纯文本界面上工作的人来说,在 vim 中拥有一个解决方案会很好,所以我期待其他答案。 ;-)
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. ;-)