0

Question

I think you see the problem... How can I paste directly below? Is there a way?

Setup

I have this table and I want to copy/yank the 3 × | in visual block mode and then paste it:

| sign    | example           |
| ---     | ---               |
| %       | dir/test.txt      |
| %:t     | test.txt
| %:p     | /tmp/dir/test.txt
| %:e     | .txt

p (lowercase):

| sign    | example           |
| ---     | ---               |
| %       | dir/test.txt      ||
| %:t     | test.txt           |
| %:p     | /tmp/dir/test.txt  |
| %:e     | .txt

With P (uppercase):

| sign    | example           |
| ---     | ---               |
| %       | dir/test.txt      ||
| %:t     | test.txt          |
| %:p     | /tmp/dir/test.txt |
| %:e     | .txt

Stuff like :+1put does not work...



Thank you for your help :)

1 Answer 1

3

I suppose you do not have spaces after the text at the last three lines? E.g. if $ denotes the line end, it looks like this?

| %:t     | test.txt$
| %:p     | /tmp/dir/test.txt$
| %:e     | .txt$

In that case, I would copy/yank the 3 | from the first 3 lines using visual-block-mode when the cursor is on the last | of the first line using: ctrlV2jy

Then, you need to enable virtualedit mode, which basically allows the cursor to move beyond the actual text, so you can position the cursor right before the position of where the | should be placed:

:set ve=all

So in the following picture, the ¶ denotes the cursor:

| sign    | example           |
| ---     | ---               |
| %       | dir/test.txt      |
| %:t     | test.txt         ¶
| %:p     | /tmp/dir/test.txt
| %:e     | .txt

And now you can paste using p which should result in:

| sign    | example           |
| ---     | ---               |
| %       | dir/test.txt      |
| %:t     | test.txt          |
| %:p     | /tmp/dir/test.txt |
| %:e     | .txt              |

And optionally disable virtualedit mode using :set ve=

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.