FG
💻 Software

Vim: how to paste a block of text at the end of multiple lines?

Fresh5 days ago
Mar 15, 202640087 views
Confidence Score1%
1%

Problem

Say I have a block of text like this: And I want to append each of these lines to the end of 3 corresponding lines of code: So that the end result is Is there an easy way to do this in Vim?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Vim: how to paste a block of text at the end of multiple lines?

Low Risk

Use visual block mode (Ctrl+v) to select one set of lines, then either y or d them. Then, if you selected the foo, bar, baz lines use visual block mode again to select the first column of the comment lines and then Shift+p them into place (or if you selected the comment lines, select the last column of the foo bar baz lines and p them into place. Getting the hang of positioning might take a bit of practice, but when you've got the knack you'll be flying. When you've got a block selected you can…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment