有“vim 运行时日志”吗?

发布于 2024-09-05 20:58:32 字数 377 浏览 4 评论 0原文

有时我会在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

原谅我要高飞 2024-09-12 20:58:32

使用 -V[N] 选项运行 vim 会生成相当大的运行时日志,这里 N 是调试级别。

vim -V9myVim.log

将在当前目录中创建一个调试级别 9 的日志,文件名为 myVim.log

running vim with the -V[N] option will do a pretty hefty runtime log, here N is the debug level.

vim -V9myVim.log

would create a log of debug level 9 in the current directory with the filename myVim.log

囍笑 2024-09-12 20:58:32

:messages 显示 vim 状态行中出现的所有警告、错误和信息性消息(可能是简短的)。

:echo errmsg 打印最近的错误消息。

g< 是另一个很少有人知道的功能。来自 :help g<:

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<:

The g< command can be used to see the last page of previous command output. This is especially useful if you accidentally typed <Space> at the hit-enter prompt.

For example try :!ls then cancel the prompt, then hit g<.

诠释孤独 2024-09-12 20:58:32

将此函数放入 .vimrc 中:

function! ToggleVerbose()
    if !&verbose
        set verbosefile=~/.log/vim/verbose.log
        set verbose=15
    else
        set verbose=0
        set verbosefile=
    endif
endfunction

然后创建目录 ~/.log/vim 并调用 ToggleVerbose() 来获取 ~/.log/vim/ 中的日志详细.log。请注意,您可能会遇到“变量嵌套太深而无法显示”错误,该错误通常不会仅仅因为您提高了详细级别而出现。

Put this function into .vimrc:

function! ToggleVerbose()
    if !&verbose
        set verbosefile=~/.log/vim/verbose.log
        set verbose=15
    else
        set verbose=0
        set verbosefile=
    endif
endfunction

Then create directory ~/.log/vim and call ToggleVerbose() 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.

时光与爱终年不遇 2024-09-12 20:58:32

这可能违背了 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.

情徒 2024-09-12 20:58:32

我认为本身没有运行时日志,但您可以在调试模式下运行它。
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

剧终人散尽 2024-09-12 20:58:32

由于 &verbose 在 root 中运行时,我必须添加“set nocp”以使用“ToggleVerbose()”函数

I had to add "set nocp" to use "ToggleVerbose()" function when run in root because of &verbose

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文