有“vim 运行时日志”吗?
有时我会在 vimrc 中尝试自定义/命令。一切看起来都是正确的,但就是行不通。
很难知道 vim 启动时发生了什么,也很难知道哪个命令失败了,因此很难调试导致我的 vimrc 中出现问题的原因。这是一种试错方法,非常耗时,而且确实是一种 PITA。例如,我遇到问题 某些文件中带有 snipmate 插件,只是不知道如何发现问题。
vim 启动时是否有“运行时日志”,告诉它执行了哪些命令,哪些命令失败了等等?这对我有很大帮助。
Sometimes I try a customization/command in my vimrc. Everything seens to be correct, but it just doesn't work.
It's difficult to know what's happening when vim starts, and know which command failed or not, so it's really difficult to debug what can be causing a problem in my vimrc. It's a trial-error approach, which is time consuming and really a PITA. For example, I'm having problems with snipmate plugin in some files and just don't have a clue on how to discover the problem.
Is there a "runtime log" when vim starts, telling which commands it executed, which ones failed and such? This would help me a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用 -V[N] 选项运行 vim 会生成相当大的运行时日志,这里 N 是调试级别。
将在当前目录中创建一个调试级别 9 的日志,文件名为
myVim.log
running vim with the -V[N] option will do a pretty hefty runtime log, here N is the debug level.
would create a log of debug level 9 in the current directory with the filename
myVim.log
:messages
显示 vim 状态行中出现的所有警告、错误和信息性消息(可能是简短的)。:echo errmsg
打印最近的错误消息。g<
是另一个很少有人知道的功能。来自:help g<
:例如,尝试
:!ls
然后取消提示,然后点击g<
。:messages
shows all warnings, errors, and informational messages that appeared (possibly briefly) in the vim statusline.:echo errmsg
prints the most recent error message.g<
is another feature few people know about. From:help g<
:For example try
:!ls
then cancel the prompt, then hitg<
.将此函数放入 .vimrc 中:
然后创建目录
~/.log/vim
并调用ToggleVerbose()
来获取~/.log/vim/ 中的日志详细.log
。请注意,您可能会遇到“变量嵌套太深而无法显示”错误,该错误通常不会仅仅因为您提高了详细级别而出现。Put this function into .vimrc:
Then create directory
~/.log/vim
and callToggleVerbose()
to get your log in~/.log/vim/verbose.log
. Note that you may catch «variable nested too deep for displaying» error which will not normally appear just because you have raised your verbose level.这可能违背了 SO 所代表的一切,但这就是我所做的:当警告出现时我就点击打印屏幕并查看图片。
This probably goes against everything SO stands for, but here's what I do: I just hit print screen soon as the warning comes up and look at the picture.
我认为本身没有运行时日志,但您可以在调试模式下运行它。
http://web.archive.org/web/ 20090323034339/http://www.troubleshootingwiki.org/Debugging_Vim_Scripts
I don't think there is a runtime log, per se, but you can run it in debug mode.
http://web.archive.org/web/20090323034339/http://www.troubleshootingwiki.org/Debugging_Vim_Scripts
由于 &verbose 在 root 中运行时,我必须添加“set nocp”以使用“ToggleVerbose()”函数
I had to add "set nocp" to use "ToggleVerbose()" function when run in root because of &verbose