快速突出显示vim中的列范围 [英] Quickly highlight a column range in vim

查看:87
本文介绍了快速突出显示vim中的列范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理位置数据文件时,突出显示特定列通常非常有用.在此类文件中,通常会出现由空格(或NULL值)和非常稀疏的数据点填充的巨大区域".在这种情况下,读取文件变得困难.

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.

这是一个示例摘录:

                                                   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起可用)可以设置为一个范围,并且速度更快,因为它不需要匹配字符.

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.

实施建议的解决方案,我看到了它的作用.但这很麻烦,而且-知道vim-应该有一种更简单的方法来指定它.

Implementing the proposed solution I saw it working. But it's cumbersome, and - knowing vim - there should be an easier way to specify this.

是否可以将cursorcolumn范围设置为当前所选(可视)块的列?

Is it possible to set the cursorcolumn range to the columns of the currently selected (visual) block?

推荐答案

事实证明这很简单.函数getpos可以检索任何标记的位置.我们将使用它来将解决方案扩展到先前的问题:

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:

:let &l:cc = join(range(getpos("'<")[2], getpos("'>")[2]),',')

现在,我们可以轻松地对此进行映射:

Now, we can map this easily:

:vnoremap <F5> <ESC>:let &l:cc = join(range(getpos("'<")[2], getpos("'>")[2]),',')<CR>

因此,现在在编辑位置数据文件时,我们只需要进入可视模式,选择需要突出显示的文件部分,然后按F5

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

这篇关于快速突出显示vim中的列范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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