この vim コマンドは `:g/#/+1t.` をどのように機能しますか?

この vim コマンドは `:g/#/+1t.` をどのように機能しますか?

私はvimgolfをプレイしていますが(中毒性が非常に高い)、この問題に対する解決策の1つを理解できません。http://vimgolf.com/challenges/4d1a34ccfa85f32065000004

問題は、次のテキストを変換することです。

Make the pairs of lines match up by making each second line same as first:

# Appending text:
The name "Vim" is an acronym for "Vi IMproved"
The name "Vim" is an acronym for

# Editing text:
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga
Trivia: Vim is a text editor released by Bram Moolenaar in 1991 for the Amiga

# Deleting text:
Vim has a vi compatibility mode
Vim has a vi compatibility mode but when not in this mode Vim has many enhancements over vi

これに関して:

2 番目の行を最初の行と同じにして、2 つの行を一致させます。

# Appending text:
The name "Vim" is an acronym for "Vi IMproved"
The name "Vim" is an acronym for "Vi IMproved"

# Editing text:
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga

# Deleting text:
Vim has a vi compatibility mode
Vim has a vi compatibility mode

私の質問は、このソリューションの2行目がどのように機能するかです。

:g/#/+2d<CR>:<Up><BS><BS>1t.<CR>ZZ

2行目で私の言葉は:g/#/+1t.

ベストアンサー1

あなたはすでに知っているでしょう:g /#/は、さまざまな問題のターゲットである#を含むすべての行でコマンドを実行します。

最初の行が「間違った」行を削除したので、2番目の行は残りの行だけをコピーします。

#行にあります。 1行前に移動(+1)し、現在の行(.)にコピー(t)します。

2つの同じ行が残ります。

おすすめ記事