Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: duplicate a line shortcut

I am new to Visual Studio Code. I want to know how to duplicate a line using a keyboard shortcut.

Please help.
Thanks

like image 905
Kuldeep Mishra Avatar asked Apr 17 '18 07:04

Kuldeep Mishra


People also ask

How do I duplicate a line in Visual Studio Code?

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.

How to duplicate selection or line from a selection in VS Code?

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" }

How do I change the keyboard shortcut to duplicate a line?

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

How to copy line up and line down in VSCode?

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


1 Answers

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.

  1. Windows

    Shift + Alt + Up/Down

  2. Macos

    Shift + Option + Up/Down

  3. 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.

like image 114
fanduin Avatar answered Sep 22 '22 03:09

fanduin