Vim 中的多行突出显示
我目前正在 Vim 中编写一个插件,需要突出显示文件中的任意行 同时。
到目前为止,我的方法一直是使用行号实现 match
来突出显示它,但问题是我需要为文件中的每隔一行添加 |
并附加该信息,然后每次重绘窗口时调用它。
在我的例子中,match
还有另一个问题,那就是可能没有任何空格的行看起来不会突出显示(match
仅突出显示现有文本/空格)。
因此,即使我使用 match
重写窗口并突出显示我需要的所有行,从用户的角度来看,如果没有空格/文本,突出显示不显示任何内容,那么这也没有用。 。
我可以获得有关如何同时有效地显示/显示/突出显示(我愿意接受不同的实现来解决我的问题)文件中的任意行(无论文本或空格数量如何)的任何建议吗?
编辑:我的主要要求是能够按行号突出显示行,而不是通过正则表达式 匹配。因此,任何解决方案都应该需要足够灵活,以接受要匹配的行号。
编辑: signs
是我问题的答案,我发现本教程是掌握和实现我需要的内容的最佳方法:http://htmlpreview.github.io/?https://github.com/ runpaint/vim-recipes/blob/master/text/07_navigation/12_bookmarking_lines_with_visible_markers.html
I am currently writing a plugin in Vim that needs to highlight arbitrary lines in a file
at the same time.
My approach so far has been implementing match
with the line number to highlight it, but the problem is that I would need to add |
for every other line in a file and append that information and then call it every time the window gets redrawn.
There is another problem with match
in my case, and that is that a line that may not have any whitespace would not look highlighted (match
only highlights existing text/whitespace).
So even if I had match
rewrite the window and highlighting all the lines I need, from a user's perspective this wouldn't be to useful if the highlighting doesn't show anything if there is no whitespace/text.
Can I get any suggestions in how to effectively show/display/highlight (I'm open to different implementations to solve my problem) arbitrary lines in a file at the same time regardless of amount of text or whitespace?
Edit: My main request is to be able to highlight lines by line number not by regex
matching. So any solution should need to be flexible enough to accept a Line number to match.
Edit: signs
is the answer to my problem, and I found this tutorial the best way to grasp and implement what I needed: http://htmlpreview.github.io/?https://github.com/runpaint/vim-recipes/blob/master/text/07_navigation/12_bookmarking_lines_with_visible_markers.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会使用
region
而不是match
。这是我的手稿语法文件的一部分,突出显示了演讲:它以双引号开头,以另一个双引号或段落结尾结尾。如果需要的话,它将突出显示多行。
I would use
region
rather thanmatch
. Here is part of my manuscript syntax file that highlights speech:It starts with a double quote and ends with another double quote or the end of the paragraph. It will highlight multiple lines if need be.