I am new to Visual Studio Code. I want to know how to duplicate a line using a keyboard shortcut.
Please help.
Thanks
File > Preferences > Keyboard Shortcuts If you want to easily duplicate a line of code in Visual Studio Code, you can do it with a simple keyboard shortcut. Just use the Copy Line Down ( Ctrl+Alt+UpArrow ) or Copy Line Up commands ( Ctrl+Alt+DownArrow ) — depending on where you want the new line inserted with respect to your cursor.
Install plugin Duplicate selection or linefrom VS Code Marketplace This extension provides bindings for ctrl+d(Windows/Linux) and cmd+d(MacOS). To customize keyboard shortcuts Preferences -> Keyboard Shortcuts: { "mac": "cmd+d", "key": "ctrl+d", "command": "geeebe.duplicateText", "when": "editorTextFocus" }
The Command you need to change in the Keyboard shortcuts list is called: Duplicate Selection(editor.action.duplicateSelection) – Edenshaw Dec 28 '21 at 2:30 Add a comment | 8 Duplicate line: alt+ shift+ △/▽ Move line up/down: alt+ △/▽ Share Improve this answer Follow answered Apr 30 '21 at 2:17 nCardotnCardot
38 In VScode, they call this Copy Line Upand Copy Line Down From the menu, go to: File > Preferences > Keyboard Shortcuts Check already assigned keyboard shortcut for this, or adjust yours. Sometimes the default assigned shortcut may not work, mostly because of OS. In my Ubuntu, I adjusted this to: Ctrl+Shift+D Share Improve this answer
In Visual Studio Code you can perform the "Copy line down/up" action. The keyboard shortcut varies depending on your operating system.
The defaults for each os are as follows.
Windows
Shift + Alt + Up/Down
Macos
Shift + Option + Up/Down
Linux
Ctrl + Alt + Shift + Up/Down
Note: This shortcut will also copy multi-line selections up and down as in Sublime but when a subset of a line is selected the entire line is copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With