In VScode when you copy a line of text and then put your cursor in the middle of quotes and hit Ctrl+V it pastes the new line above where you intended it to go.
In IntelliJ and PyCharm when you copy a line of code with Ctrl+C without selecting any text then they intelligently remove the \n character at the end of the string while it is in memory. So when you paste it in middle of quotes you get the desired behavior.
Since VS team is not likely going to fix this anytime soon I was wondering if anyone has a macro for it.
A combination of keys would help you:
But since you want to do it with just Ctrl + Alt + C, you can install extension called macros to make a macro, recorded multiple key combinations.
Create your own custom macros by adding them to your settings.json
:
"macros": {
"copyWithoutNewLine": [
"cursorHome",
"cursorEndSelect",
"editor.action.clipboardCopyAction",
"cancelSelection",
"cursorUndo",
"cursorUndo",
"cursorUndo"
]
}
Created macro can have a custom name, in this example it's copyWithoutNewLine. And this macro executes all above stated commands to copy line.
After creating macro, you need to add it to keybindings.json
to run it:
{
"key": "ctrl+alt+c",
"command": "macros.copyWithoutNewLine",
"when": "editorTextFocus && !editorHasSelection"
}
When key combination of Ctrl + Alt + C is pressed, it will copy it without a new line, and you can paste it where ever you want.