跳转到下一个错误/代码以红色突出显示

发布于 2024-11-15 17:46:39 字数 277 浏览 10 评论 0原文

处理合并冲突时,通常 DCVS 插入的 >>>>>>====== 在语法上不正确我所在的文件并显示为红色突出显示。在处理合并冲突时,使用命令跳转到这些错误会很有用。当我输入 :cnext 时,我只收到消息“无错误”。这些是 Mercurial 合并冲突,因此我无法使用 Fugitive,但我通常更喜欢手动编辑合并冲突。

有没有办法跳转到文件中的下一个语法错误?我认为这些错误是由语法突出显示文件决定的。

When dealing with merge conflicts it is common that the >>>>>> and ====== inserted by DCVS are syntactically incorrect for the file I'm in and show up as highlighted in red. When dealing with merge conflicts it would be useful to have commands to jump to these error. When I type :cnext I just get the message "No Errors". These are Mercurial merge conflicts so I can't use Fugitive, but I generally prefer editing merge conflicts by hand anyway.

Is there a way to jump to the next syntax error in the file? I think these errors are dictated by the syntax highlighting file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

瀞厅☆埖开 2024-11-22 17:46:39

您可以使用 :lopen 打开包含错误/警告行的窗口。之后,导航到它们中的每一个。

实际答案是,您可以使用 :lnext 跳转到下一个错误,或者 :lprev,或者 ]l 和 [l (那些是小写的 L)如果你有 vim-unimpaired,你这样做,因为没有它你不应该使用 Vim。

这实际上不会跳转到下一个红色/错误突出显示的文本组,但会跳转到语法插件指示的任何错误(并填充位置列表)。在 Vim 中不可能跳转到特定的突出显示组,因为还没有人费心去弄清楚如何实现。

插件 SRDispHiGrp 很接近,但如果您无法从这个名字对于人类使用来说太复杂和混乱了。

You can use :lopen to open window containing error/warning lines. After that, navigate to each of them.

The actual answer is that you can use :lnext to jump to the next error, or :lprev, or ]l and [l (those are lowercase Ls) if you have vim-unimpaired, which you do, because you shouldn't use Vim without it.

This will not actually jump to the next red/error highlighted text group, but will jump to whatever your syntax plugin dictates is an error (and populates the location list). It is impossible in Vim to jump to a specific highlighting group, because no one has bothered to figure out how yet.

The plugin SRDispHiGrp comes close, but if you couldn't tell from the name, is too convulted and confusing for human use.

寄居人 2024-11-22 17:46:39

我认为您的 :cnext 走在正确的轨道上。

:cnext:cprevious 是 Vim QuickFix 命令;您可以通过使用使用 QuickFix 模式的代码验证插件来利用它们,例如 pyflakes .vim(适用于 Python)和 jslint.vim/jshint.vim 用于 JavaScript。

这将导致语法错误被标记为波浪状的红色下划线,而不是我相信您看到的纯红色语法错误突出显示。然后,您应该能够使用 :cnext:cprevious 跳到下一个和上一个标记的错误。

I think you were on the right track with :cnext.

:cnext and :cprevious are Vim QuickFix commands; you can take advantage of them by using a code validation plugin that uses QuickFix mode, like pyflakes.vim for Python, and jslint.vim/jshint.vim for JavaScript.

This will result in syntax errors being marked with squiggly red underlines, as opposed to the solid red syntax error highlighting I believe you are seeing. You should then be able to use :cnext and :cprevious to skip to the next and previous marked errors.

静谧幽蓝 2024-11-22 17:46:39

您可以使用 ]s(向后)或 [s(向前),具体取决于您要查找下一个错误的方向。你需要处于正常模式才能工作,但这只是在 vim 中构建的,不需要扩展。

You can use ]s (backwards) or [s (forward) depending on which direction you want to go in finding the next error. You need to be in normal mode for this to work but this is just build in vim, no extensions needed.

第七度阳光i 2024-11-22 17:46:39

:cn - 下一条编译器消息

:cp - 上一条

:cl - 列表

:cn - next compiler message

:cp - previous

:cl - list

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