How do I duplicate a line or selection within Visual Studio Code?

前端 未结 17 2297
青春惊慌失措
青春惊慌失措 2020-12-04 04:38

Using Microsoft\'s Visual Studio Code, how do I duplicate a line of code and then move it up and down? (Similar to Sublime\'s cmd+shift+d be

17条回答
  •  無奈伤痛
    2020-12-04 04:47

    You can find keyboard shortcuts from

    File > Preferences > Keyboard Shortcuts

    Default Keyboard Shortcuts are,

    Copy Lines Down Action : shift+alt+down

    Copy Lines Up Action : shift+alt+up

    Move Lines Up Action : alt+up

    Move Lines Down Action : alt+down

    Or you can override the keyboard shortcuts from

    File > Preferences > Keyboard Shortcuts

    And editing the keybindings.json

    Example:

    [
        {
            "key": "ctrl+d",
            "command": "editor.action.copyLinesDownAction",
            "when": "editorTextFocus"
        },
        {
            "key": "ctrl+shift+up",
            "command": "editor.action.moveLinesUpAction",
            "when": "editorTextFocus"
        },
        {
            "key": "ctrl+shift+down",
            "command": "editor.action.moveLinesDownAction",
            "when": "editorTextFocus"
        }
    ]
    

提交回复
热议问题