在vim中快速突出显示列范围
使用位置数据文件时,突出显示特定列通常非常有用。在此类文件中,很常见的是有巨大的“区域”填充空格(或NULL
值)并且只有非常稀疏的数据点。在这种情况下,读取文件会变得困难。
下面是一个示例摘录:
462
63082
01089
75518 735301
53473 017146
37217
07
940376
762 2842
88331
40680 8928
645718
0131
03522
47210 27431
93837
8825072 49479415
52084 8940
0591705 205635
525429
65339 300
0397
1983
0
2605768
121991 648
3892
1260
我发现简单地突出显示特定列很有帮助。起初,我尝试使用常规的 :match
,但事实证明这方式会减慢大型数据文件的速度。我将此作为另一个问题发布。答案很简单。 cursorcolumn
(自 vim 7.3 起可用)可以设置为一个范围,并且速度要快得多,因为它不需要匹配字符。
实施建议的解决方案后,我发现它有效。但这很麻烦,并且 - 了解 vim - 应该有一种更简单的方法来指定这一点。
问题:
是否可以将 cursorcolumn
范围设置为当前选定(可视)块的列?
When working with positional data files, it is often very useful to highlight a specific column. In such files it is quite common to have huge "areas" filled with spaces (or NULL
values) and only very sparse data points. In such cases it becomes difficult to read the file.
Here's an example excerpt:
462
63082
01089
75518 735301
53473 017146
37217
07
940376
762 2842
88331
40680 8928
645718
0131
03522
47210 27431
93837
8825072 49479415
52084 8940
0591705 205635
525429
65339 300
0397
1983
0
2605768
121991 648
3892
1260
I found it helpful to simply highlight a specific column. At first I tried to use a regular :match
, but this turned out to be way to slow on huge data files. I posted this as another question. The answer is simple. cursorcolumn
(available since vim 7.3) can be set to a range and is a lot faster as it does not need to match the characters.
Implementing the proposed solution I saw it working. But it's cumbersome, and - knowing vim - there should be an easier way to specify this.
Question:
Is it possible to set the cursorcolumn
range to the columns of the currently selected (visual) block?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明这很简单。函数
getpos
可以检索任何标记的位置。我们将使用它来扩展之前问题的解决方案:现在,我们可以轻松映射:
因此,现在在编辑位置数据文件时,我们只需进入可视模式,选择我们需要的文件部分突出显示并按
F5
It turns out it's very simple. The function
getpos
can retrieve the position of any marker. We'll use this to extend the solution to the earlier problem:Now, we can map this easily:
So, now when editing a positional data file, we'll simply have to enter visual mode, select the portion of the file we need highlighted and press
F5