Search code examples
c#visual-studiocopy-paste

Visual Studio C# How to paste line after caret


When I copy a line using Ctrl+C without a selection, Ctrl+V will result in the line being inserted above my selection, even if the caret is after something.

Example:

Foo();
Bar(); X

Pasting line 1 at X will result in

Foo();
Foo();
Bar();

Is there a possibility to instead achieve something more like this?

Foo();
Bar(); 
Foo();

This only happens if I both copy and paste without a selection. Selecting the entire line and copying will result in Foo being pasted after Bar, same happens when pasting into some selected text.

I am currently using Visual Studio Community 2017.


Solution

  • I don't think you can configure it, but you can workaround it by using 'Move Selected Lines Up' feature

    1. Paste (Ctrl+V)
    2. Move line up (Alt+Up Arrow)

    Keyboard shortcuts might be different depending on your VS settings. You can find this feature "in Edit->Advanced->Move Selected Lines Up"