使用 cscope 在头文件和实现文件之间切换的 Vim 脚本

标签 vim cscope

我目前使用 A.vim在头文件和实现文件之间交换的插件。该脚本的局限性在于,它仅在两者位于同一文件夹中时才有效。

如果您的代码有 cscope 数据库,您可以通过执行 :cscope find f ImplementFileName.h 轻松找到特定实现文件的 header 。

如何编写此脚本以获取不带扩展名的当前文件名并搜索添加了 .h 后缀的该名称?

最佳答案

使用 A.vim 应该可以开箱即用。查看:帮助替代配置。特别是有关搜索路径的部分:

b) Search Paths: In many projects the location of the source files and the corresponding header files is not always the same directory. This plugin allows the search path it uses to locate source and header files to be configured. The search path is specified by setting the g:alternateSearchPath variable. The default setting is as follows,

g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'

This indicates that the corresponding file will be searched for in ../source, ../src. ../include and ../inc all relative to the current file being switched from. The value of the g:alternateSearchPath variable is simply a comma separated list of prefixes and directories. The "sfr:" prefix indicates that the path is relative to the file. Other prefixes are "wdr:" which indicates that the directory is relative to the current working directory and "abs:" which indicates the path is absolute. If no prefix is specified "sfr:" is assumed.

关于使用 cscope 在头文件和实现文件之间切换的 Vim 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5108484/

相关文章:

vim - 从 vim 打印到 Postscript

php - 基于 Vim 语法的 php 折叠

vim - 如何在 vim 中退出 vimdiff 模式,特别是对于 Fugitive?

vim - vim 和 emacs 中的代码导航

vim - 如何将命令应用于 Vim 中所选内容中的每一行并替换为结果(如电子表格)?

node.js - 在 VIM 中调试 Nodejs V8

c++、cscope、ctags 和 vim : Finding classes that inherit from this one

linux - 无法通过 vim 编辑器使用 cscope 多击键

cscope: -c 或 -T 命令行和旧符号数据库不匹配

ctags - 使用 ctags 生成调用层次结构图