Home > Software engineering >  Copy/move rest of the current line to the end of next line
Copy/move rest of the current line to the end of next line

Time:11-19

I have Googled a lot but cannot find one feature in VScode that I would appreciate greatly:

Copy (or move) rest of the current line (i.e. not the entire line) to the end of next line

Example:

What I have - note the cursor

What I have - note the cursor

What I need - again note the cursor

What I need - again note the cursor

So ideally, with a single keyboard shortcut, I would copy (or move) the remainder of the current line (= "ABC1" in the example) to the end of the next line. Any ideas how to do that? Is it available within VScode, or is there a relevant extension? Thanks!

CodePudding user response:

Since you're asking if there's an extension for it, the vim extensions should at least be mentioned. I have no intention or desire to start an(other) editor war, though.

What you're asking would be trivial in vim (y$, yank to end of line) and there are at least two very popular vim extensions for vscode that will bring the vim keybindings as well as the power of configurable commands and bindings in vim to vscode.

Yes, it would require some effort to learn the "vim way" of doing things, but the upside is that you'll probably never have to re-learn the bindings if you move between editors/IDEs since they are available in pretty much every editor and they make editing very fast and precise.

CodePudding user response:

Drag and drop by mouse

Why are you not using mouse drag and drop text? Select the text and drag it by mouse where you need

Otherwise, if you have multiple times then you can solve it in two steps.

Step1:

Replace all Name by Name(ctrl enter)SecretCode enter image description here

Step2: Replace all "(ctrl enter)SecretCode by " enter image description here

Done enter image description here

  • Related