首頁  >  問答  >  主體

vim - 可否在黏貼時保持垂直方向對齊?

系統黏帖板裡有以下內容。

home
help
variables
vi compatibility
modelines
word&line completion
searching
text selection
markets
indenting
reformatting

我想複製到文件成下面的格式。

    home
    help
    variables
    vi compatibility
    modelines
    word&line completion
    searching
    text selection
    markets
    indenting
    reformatting

請問,有無偷懶的辦法?

第一次遊標在行首,使用 "+p 貼文的結果

home
help
variables
vi compatibility
modelines
word&line completion
searching
text selection
markets
indenting
reformatting

第二次遊標在第五列,使用 "+p 黏貼的結果

    home
help
variables
vi compatibility
modelines
word&line completion
searching
text selection
markets
indenting
reformatting

可否一次貼上以這樣?
第一次黏貼的結果,運行%s/^/ /g
第二次黏帖的結果,運行1,$s/^/ /g
都可以得到下面的結果,我想偷懶一次就做到這樣的結果,請問,可以做到嗎?

    home
    help
    variables
    vi compatibility
    modelines
    word&line completion
    searching
    text selection
    markets
    indenting
    reformatting
巴扎黑巴扎黑2712 天前571

全部回覆(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

    設定成自動縮排試試

    :set autoindent

    回覆
    0
  • 漂亮男人

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

    :設定貼上

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

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

    先shift+v選取一行然後按j向下選取多行,最後shift + >, 不知道是不是你要的。

    回覆
    0
  • 取消回覆