通过Ex-Mode为视觉选择添加线条

Ber*_*nnF 5 vim restructuredtext

是否可以通过EX模式命令将某些行添加到视觉选择中?

我有以下形式的文字:

+----------+-----------+
| Some text| other text|
+----------+-----------+
| More text||
| And even more ||
| - ...||
+----------+-----------+
Run Code Online (Sandbox Code Playgroud)

我希望文本显示如下:

+---------------+------------+
| Some text     | other text |
+---------------+------------+
| More text     |            |
| And even more |            |
| - ...         |            |
+---------------+------------+
Run Code Online (Sandbox Code Playgroud)

通过以下工作流程删除带有+的行时使用表格插件:

g!/+/d
// Visually select the remaining lines
Tab /|
// Manually insert the +----+----+ lines
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法保持分界线和视觉选择不包含+通过EX模式的行:g!/+/ add-line-to-visual-selection.

Ben*_*oit 3

你可以使用:

:Tab /|\|+/l1
:<range>g/+/s/ /-/g
Run Code Online (Sandbox Code Playgroud)

\|你可以在全局范围内找到in:help /\|或 more的帮助:help pattern,它是 Vim 正则表达式中表达交替的标准方式。具有与或/|\|+/匹配的分隔符的模式也是如此。(仅供参考,通读全文可带来丰厚的投资回报)​​。|+:help pattern

关于/l1Tabular插件中的,你可以更深入地阅读插件的帮助,它会在分隔符和左对齐文本后添加空格。