搜索

首页  >  问答  >  正文

vim - 可否在粘帖时保持垂直方向对齐?

系统粘帖板里有如下内容。

1

2

3

4

5

6

7

8

9

10

11

12

<code>home

help

variables

vi compatibility

modelines

word&line completion

searching

text selection

markets

indenting

reformatting

</code>

我想复制到文件成下面的格式。

1

2

3

4

5

6

7

8

9

10

11

12

<code>    home

    help

    variables

    vi compatibility

    modelines

    word&line completion

    searching

    text selection

    markets

    indenting

    reformatting

</code>

请问,有无偷懒的办法?

第一次光标在行首,使用 "+p 粘帖的结果

1

2

3

4

5

6

7

8

9

10

11

12

<code>home

help

variables

vi compatibility

modelines

word&line completion

searching

text selection

markets

indenting

reformatting

</code>

第二次光标在第五列,使用 "+p 粘帖的结果

1

2

3

4

5

6

7

8

9

10

11

12

<code>    home

help

variables

vi compatibility

modelines

word&line completion

searching

text selection

markets

indenting

reformatting

</code>

可否一次粘帖成这样?
第一次粘帖的结果,运行 %s/^/ /g
第二次粘帖的结果,运行 1,$s/^/ /g
都可以得到下面的结果,我想偷懒一次就做到这样的结果,请问,可以做到吗?

1

2

3

4

5

6

7

8

9

10

11

12

<code>    home

    help

    variables

    vi compatibility

    modelines

    word&line completion

    searching

    text selection

    markets

    indenting

    reformatting

</code>

巴扎黑巴扎黑2846 天前724

全部回复(5)我来回复

  • 高洛峰

    高洛峰2017-05-16 16:35:57

    :set ai

    然后i tab Ctrl-v

    回复
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 16:35:57

    "+pVG>

    回复
    0
  • ringa_lee

    ringa_lee2017-05-16 16:35:57

    设置成自动缩进试试

    1

    <code>:set autoindent</code>

    回复
    0
  • 漂亮男人

    漂亮男人2017-05-16 16:35:57

    :设置粘贴

    回复
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 16:35:57

    首先shift+v选中一行然后按j向下选中多行,最后shift + >, 不知道是不是你要的。

    回复
    0
  • 取消回复