如何在gvim中增加数字来创建文本行

Viv*_*vek 2 vim block

我有一些文本行,如下所示

text1
text1
text1
text1
Run Code Online (Sandbox Code Playgroud)

我想把它们改成

text1
text2
text3
text4
Run Code Online (Sandbox Code Playgroud)

在gvim中有一个简单的方法吗?我知道使用ctrl + v的可视块可以用其他字母替换一个字母.但我不知道如何生成序列号.

帮助赞赏.谢谢

Mar*_*rth 5

您可以从第二行开始选择文本,然后使用g<ctrl-a>.

来自:h v_g_CTRL-A:

                            *v_g_CTRL-A*
{Visual}g CTRL-A    Add [count] to the number or alphabetic character in
                    the highlighted text. If several lines are
                    highlighted, each one will be incremented by an
                    additional [count] (so effectively creating a
                    [count] incrementing sequence).  {not in Vi}
                    For Example, if you have this list of numbers:
                        1.
                        1.
                        1.
                        1.
                    Move to the second "1." and Visually select three
                    lines, pressing g CTRL-A results in:
                        1.
                        2.
                        3.
                        4.
Run Code Online (Sandbox Code Playgroud)

  • 注意:这是在许多7.4.x补丁中的某处添加的,因此您需要下载每晚版本或Vim without Cream或具有此功能的类似内容. (2认同)