2

I want to select multiple lines in vim, copy them, and paste after that chunk of code (with cursor at the beginning).

yp doesn't work because in visual chunk of code, vim pastes after the 1st line of visually selected lines inside that visual block, not after the whole visually selected chunk of code.

Is there any better way to do this?

I tried to make an alternative solution on my own but didn't succeed.

After some workaround, here's my config

vmap <silent> <c-l> yP

When I press Ctrl+l

    [cursor-position]for(int i=0; i<5; i++){
        cout << n[i] << " ";
    }

I get this

    [cursor-position]for(int i=0; i<5; i++){
        cout << n[i] << " ";
    }
    for(int i=0; i<5; i++){
        cout << n[i] << " ";
    }

but I want

    for(int i=0; i<5; i++){
        cout << n[i] << " ";
    }
    [cursor-position]for(int i=0; i<5; i++){
        cout << n[i] << " ";
    }
0

1 Answer 1

2

copy-paste entire block after (not inside the first selected block) with cursor at the beginning of 2nd paste

Just four three keys

ygP

0

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.