0

Lets say you have the following dataset with two lines

a
b

And you want to paste another column,

c
d

How do you either paste that dataset to produce the following

a c
b d

Or, paste them consecutively (like below), and merge them to produce the above

a
b
c
d

This question comes from copy of a PDF file that displays as two columns, but copies as one column (the right column merely appended to the left column).

2 Answers 2

2

Vim has column editing mode. This was answered on Stack Overflow: https://stackoverflow.com/questions/6971903/how-to-do-column-editing-in-vim

From a blog post, the steps are generally:

  1. Ctrl + V to go into column mode
  2. Select the columns and rows where you want to enter your text
  3. Shift + i to go into insert mode in column mode
  4. Type in the text you want to enter. Dont be discouraged by the fact that only the first row is changed.
  5. Esc to apply your change (or alternately Ctrl+c)

As stated in the documentation, if you're on Windows or have ctrl-v mapped to something else, you may be able to use ctrl-q instead

0

This first step is not always necessary, but since you're wanting to put spaces between the columns and there are not corresponding spaces in the text, set 'virtualedit' to "all":

:set ve=all

Next, move the cursor to the upper-left column of the text you wish to move and type

Ctrl-V$

where Ctrl-V means CtrlV, then move the cursor down to the last row of the text to be copied and type y to yank or d to delete it.

Now move the cursor to, in your case, the right of the a and type p.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .