VIM 折叠标题中的语法高亮显示 [英] syntax highlighting in a VIM fold header

查看:54
本文介绍了VIM 折叠标题中的语法高亮显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以让 VIM 继续对用作折叠标题的行应用格式吗?

Is there any way to have VIM continue to apply formatting to the line used as the header for a fold?

例如,我有以下代码:

int foo(int a, int b) {
    int c;
....
}

折叠后,我看到:

+-- 4 lines: int foo(int a, int b) {----------------------------

但是,根据折叠"类突出显示整行.有什么办法可以禁用它,所以我继续看到语法高亮?

However, the whole line is highlighted as per the "Folded" class. Is there any way to disable this, so I continue to see the syntax highlighting?

[举个简单的例子,这不是那么重要,但我也在查看大数据文件时广泛使用折叠,而且格式对我来说更重要]

[for a simple example this is not so important, but I also use folding extensively in viewing large data files, and there the formatting is much more important to me]

推荐答案

但是,根据折叠"类突出显示整行.有什么办法可以禁用它,所以我继续看到语法突出显示?"

However, the whole line is highlighted as per the "Folded" class. Is there any way to disable this, so I continue to see the syntax highlighting?"

不,折叠的标题文本不是文件的一部分,不能直接编辑,只是计算并叠加在屏幕上.折叠"突出显示应用于整条线,所有折叠都应用相同的突出显示.

No, the folded headline text is not text that is part of a file and is not directly editable, just calculated and overlaid on the screen. The 'Folded' highlight is applied to the entire line, and all folds have same highlighting applied.

为了将 vim 用作大纲(在 VimOutliner 项目中),我修改了 vim 源以允许根据折叠级别进行不同的折叠突出显示,因此应用了多个折叠标题突出显示(例如,FoldLevel1、FoldLevel2、等等.).我认为在折叠标题行使用已经存在的文本突出显示可能会被进一步破解,但考虑到折叠的工作方式,我怀疑这可能比听起来更难.

For my use with vim as an outliner (in the VimOutliner project) I hacked the vim source to allow for different fold highlighting depending on the fold level, so there are multiple fold heading highlights that are applied (e.g. FoldLevel1, FoldLevel2, etc.). I assume it could be further hacked to use already-existing highlighting of the text at the fold head line, but given the way folding works I suspect that might be harder to do than it sounds.

抱歉,让我吃惊的是 foldmethod of indent 的建议可能正是您正在寻找的,这确实保留了未缩进行中的语法,同时仍然让它们作为折叠部分的标题.

Sorry, just struck me that the suggestion for foldmethod of indent may be exactly what you're looking for anyway, which does preserve syntax in the unindented lines while still having them function as a sort of heading for the folded section.

这篇关于VIM 折叠标题中的语法高亮显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆