我想让 vim 突出显示与某些模式匹配的整行。我可以突出显示一行中的所有文本(通过执行 syn match MyMatch "^.*text-to-match.*$"
),但它总是停在文本末尾。我想继续到学期结束,例如突出显示 CursorLine。
我尝试将 $
替换为 \n^
,希望能将其包裹起来。不用找了。 (我实际上并没有想到这会起作用,但尝试也没有什么坏处。)我还尝试调整 syn-pattern-offset (我在这里读到: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern )。长话短说,添加 he=he-5
将突出显示少 5 个字符,但 he=he+5
不会显示任何额外字符,因为没有字符可显示突出显示。
这是我第一次尝试制作 vim 语法,而且我对 vim 还比较陌生。请保持温和并提供解释。
谢谢!
(编辑:忘记包含,这是多行突出显示。这可能会增加一点复杂性。)
最佳答案
它的适应性不是很强,因为需要明确识别文件名(缓冲区)和行到整行突出显示,但显然 sign 可以使用命令:
It is possible to highlight an entire line using the :sign mechanism.
An example can be found at:help sign-commands
In a nutshell:
:sign define wholeline linehl=ErrorMsg
:sign place 1 name=wholeline line=123 file=thisfile.txt
Obviously, you should pick a higlight group that changes the color of the background for the linehl argument.
关于vim - 如何让 vim 语法高亮整行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2150220/