突出显示与之前的行不同的列
我有一个文本文件,其中的数字数据按行写入;有散布的输入线(未知数)和残差线(应该被最小化)。我正在研究迭代求解器如何处理各种情况的方法,并且想突出显示残差行中的每个(空格分隔的)字段,该字段(在文本上)与前一个残差行中的同一字段不同(上面 2 行,最好给出通过正则表达式)。如果有帮助的话,我可以随意装饰线条的开头。
使用 Vim 和一些正则表达式魔法可以实现这一点吗?
示例文件:
input 1 2 3 4 5 6
errors .2 .2 .3 .1 0 0
input 1 2.1 2.9 4 5 6 ## here, 2.1 and 2.9 should be highlighted
errors .21 .3 .44 .3 0 0
input 1 2 3 3.9 5.2 6 ## here, 2, 3, 3.9 and 5.2 should be highlighted
errors .2 .2 .34 .9 1 0
注意:我可以编写脚本来提取 Python 中的差异,但我想看看实际数据和更改。当它不能与 Vim 一起使用时,我将使用 python 处理它并输出突出显示的 HTML,但我将失去自动折叠功能。
I have text file with numerical data written in lines; there are interspersed input lines (unknowns) and residuals lines (which are supposed to be minimized). I am investigating ways how the iterative solver handles various cases, and would like to highlight every (space-delimited) field in the residuals line which is (textually) different from the same field in the previous residuals line (2 lines above, better given by a regexp). I am free to decorate beginnings of the lines as I like, if that helps.
Is this at all possible with Vim and some regexp magic?
Example file:
input 1 2 3 4 5 6
errors .2 .2 .3 .1 0 0
input 1 2.1 2.9 4 5 6 ## here, 2.1 and 2.9 should be highlighted
errors .21 .3 .44 .3 0 0
input 1 2 3 3.9 5.2 6 ## here, 2, 3, 3.9 and 5.2 should be highlighted
errors .2 .2 .34 .9 1 0
Note: I could code script extracting differences in Python, but I want to have a look at both the actual data and the changes. When it does not work with Vim, I will process it with python and output highlighted HTML, but I will lose automatic folding capabilities.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论