【问题标题】:How to create ctags for mocha tests如何为 mocha 测试创建 ctags
【发布时间】:2013-10-20 04:46:11
【问题描述】:

我正在尝试使用 ctags 索引我的测试,以便我可以使用 CtrlP vim 插件更轻松地跳转。测试在咖啡脚本中。这是我在 ~/.ctags 配置中找到描述块的内容。

--regex-coffee=/^[ \t]*(describe+[ \t]+\"(.+?)\")+[ ,]+*->.*$/\1/t,test/

它发现描述块没问题,这就是ctags文件的样子

User_resource_spec.coffee   tests/e2e/User_resource_spec.coffee 1;" F
assert  tests/e2e/User_resource_spec.coffee /^assert = require("assert")$/;"    v
describe "Create User"  tests/e2e/User_resource_spec.coffee /^describe "Create User", ->$/;"    t
describe "Users"    tests/e2e/User_resource_spec.coffee /^  describe "Users", ->$/;"    t
should  tests/e2e/User_resource_spec.coffee /^should = require("should")$/;"    v

我遇到的问题是当我这样做时

:tag describe "Create User"

它说没有找到标签。所有其他标签都可以正常工作。如果我编辑标签文件并更改

describe "Create User"

只是

describe 

然后它再次工作。我的猜测是,由于空格和引号,它不起作用。

但有些奇怪的是,当我用句号和下划线代替空格并去掉引号时,它仍然不起作用。就像我仍然无法跳到那个标签一样。然而,其他带有下划线和句点的标签也可以正常工作。

我无法将标签更改为仅“描述”,因为我想区分测试。

如何让 ctags 使用空格和引号。或者如果不可能做到这一点,那么在 vim 中跳转到特定 mocha 测试的最佳解决方案是什么。

【问题讨论】:

  • describe "Users" 工作吗?

标签: vim tdd mocha.js ctags ctrlp


【解决方案1】:

你必须转义引号:

:tag describe \"Create Users\"

要输入的内容很多,您为什么不简单地执行以下操作?

:tag des<Tab>

它会列出 describe \"Create Users\"describe \"Users\" 并告诉你为什么 :tag describe "Create Users" 不起作用(非转义引号)。

请注意,Vim 默认使用整个单词搜索 :tag 和朋友;您可以使用正则表达式搜索来使该过程更具确定性:

:tag /Crea<Tab>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-18
    • 2012-05-31
    • 1970-01-01
    相关资源
    最近更新 更多