How does this vim command work `:g/#/+1t.`

vim

I was playing vimgolf (very addictive by the way) and I can't understand one of the solutions to this challenge http://vimgolf.com/challenges/4d1a34ccfa85f32065000004

The challenge is to convert this text:

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

to this:

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 "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

My question is, how the second line of this solution works:

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

and by second line I mean :g/#/+1t.

Best Answer

As you might already know :g/#/ runs a command for all the lines containig a #, which are the topics of the different challenges.

Now, as your 1st line has deleted the "wrong" line, the 2nd just copyies the remainding one

You are on the #-Line, you move one line ahead (+1) and copy (t) it to the current line (.)

Which leaves 2 identical lines.

Related Question