加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 如何浏览当前在vim中打开的文件中的所有文件#included?

发布时间:2020-12-16 07:11:05 所属栏目:百科 来源:网络整理
导读:假设我在 vim中打开了以下.hpp文件: #pragma once#include "a.hpp"#include "b.hpp"#include "c.hpp"#include boost/something.hpp// some code 现在,假设我想在任何包含的文件中搜索任何出现的Token一词(也可能在它们包含的文件中).我怎么能这么容易做到?
假设我在 vim中打开了以下.hpp文件:

#pragma once
#include "a.hpp"
#include "b.hpp"
#include "c.hpp"

#include <boost/something.hpp>
// some code

现在,假设我想在任何包含的文件中搜索任何出现的Token一词(也可能在它们包含的文件中).我怎么能这么容易做到?

我想跳过任何不能从我当前的vimpath中找到的文件,例如在这种情况下,我的路径可能没有提升,所以我希望它不要在boost / something.hpp中搜索.

解决方法

您可以使用vim中提供的 include-search功能.特别是,当您将光标放在该单词上时,这是搜索所有Token所需的命令:

[I          Display all lines that contain the keyword under the
            cursor.  Filenames and line numbers are displayed
            for the found lines.  The search starts at the
            beginning of the file.  {not in Vi}

要跳转到第一个匹配项,您可以使用:

[<Tab>

取自Bram的演讲Seven habits of effective editing时间26’08“.

最后一个命令也在Vim的帮助中描述如下:

[ CTRL-I    Jump to the first line that contains the keyword
            under the cursor.  The search starts at the beginning
            of the file.  Lines that look like a comment are
            ignored (see 'comments' option).  If a count is given,the count'th matching line is jumped to,and comment
            lines are not ignored.  {not in Vi}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读