我正在 Vim 中编写一组抽认卡以导入其他应用程序;抽认卡的格式非常简单——它只是一个包含两个字段、一个问题和一个答案的 CSV。例如,如果我正在测试我的德语知识,我可能会使用以下文本文件:
hello hallo
from all over the world aus der ganzen Welt
unfortunately leider
against Denmark gegen Dänemark
Germany lost Deutschland hat verloren
the French team die französiche Mannschaft
the team won the competition die Mannschaft hat den Wettbewerb gewonnen
every game jedes Spiel
every game lasted an hour jedes Spiel hat eine Stund egedauert
almost three thousand people fast dreitausend Menschen
they saw every game sie haben jedes Spiel gesehen
the tickets were cheap die Tickets waren billig
particularly besonders
on the table auf dem Tisch
on the terrace auf der Terrasse
already schon
key Schlüssel
cutlery Besteck
no glasses keine Gläser
went ging
into the kitchen in die Küche
to fetch zu holen
You don't need a glass du brauchst kein Glas
he called Er hat angerufen
he has to work er muss arbeiten
I am cross ich bin böse
he will come er wird kommen
he will eat dessert er wird Nachtisch essen
我试图找到一种方法来隐藏选项卡后的文本,直到我按下一个键。以前,我通过将分隔符设为换行符后跟一个制表符来完成此操作,因此文件可能如下所示:hello
hallo
from all over the world
aus der ganzen Welt
... 然后,我会针对不包含选项卡的行对该文件进行 grep,将输出通过管道传输到文件,阅读并回答问题,并检查我的答案。然而,这种方法特别麻烦,因为我的抽认卡数据库越来越大,我开始实现简单的 spaced repetition并且需要在特定日期安排我的抽认卡组,可能提前几个月。
我很好奇是否有办法在 Vim 中隐藏给定字符后一行上的所有内容(在这种情况下,在\t 转义序列的第一个实例之后),并在击键时显示隐藏的仅该行上的文本。这将使我的间隔审查更容易。
我很清楚 Anki 和 Mnemosyne 等用于自动间隔重复的存在,但是,我宁愿避免使用这些应用程序,因为我已经转向大部分使用纯文本来存储信息,因为:
(a) unix 工具集非常适合在文件夹中递归查找信息,我可以在我的所有项目文件夹中使用 TODO 查找行以生成议程
(b) 纯文本更容易操作
(c) Unix 工具的存在时间将比任何间隔重复软件都要长得多
(d) 纯文本信息非常密集;最多,备份我一生的信息需要一两兆字节
(e) 我想在 Unix 环境中变得更有能力
最佳答案
V
时,文本可见(或 v
,但使用 V
突出显示更好)。 上面概述的行为是通过以下方式获得的:
:match Conceal /\t.*/
:set conceallevel=3
:set concealcursor=nc
:set tabstop=40
分解::match <group> <pattern>
分配高亮组 <group>
到文本匹配 <pattern>
在当前窗口。在这里,我们分配高亮组
Conceal
到“标签后跟任何东西”。见
:help :match
.conceallevel
选项告诉 Vim 如何处理标记为“隐藏”的文本。在这里,我们告诉 Vim 无条件隐藏可隐藏的文本。
见
:help 'conceallevel'
.concealcursor
选项告诉 Vim 如何在移动时处理隐藏的文本。在这里,我们确保文本在正常模式下保持隐藏。
见
:help 'concealcursor'
.tabstop
选项设置为大值以确保隐藏的文本对齐,就像我喜欢的那样。这对于您想要实现的目标来说不是必需的。见
:help 'tabstop'
.关于csv - 在 Vim 中隐藏给定字符之后的部分行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67456526/