Vim: 在消息历史列表中看不到 :echomsg 消息

Vim: cannot see :echomsg messages in message history list

我正在编写 vim 脚本,并希望查看脚本中生成的变量值以进行调试。

我使用类似的东西:

echomsg 'My variable = ' . b:variable

使用

重新加载源
:source %

然后用

查看消息历史列表
:messages

但是那里什么也没有,我很确定命令会被执行。

我做错了什么?

编辑: 我正在尝试对 vim-cucumber 进行更改,因此我想查看变量的值。在 ftplugin/cucumber.vim 文件中,我有以下内容:

let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)/step_definitions/mobile_website\zs[\/].*??')
echomsg 'cucumber_root = ' . b:cucumber_root

如果您查看文件顶部,您会发现

if (exists("b:did_ftplugin"))
  finish
endif

这会阻止文件在第一次后再次被获取。您需要 unlet b:did_ftplugin 才能再次获取文件。

其他选择是使用另一个 tpope 插件为您使用 :Runtime 命令调用 scripttease 执行此操作。