MicrosoftのVisual Studio Codeで、コードの行を複製して上下に移動させる方法を教えてください。(Sublimeのcmd+shift+dの動作に似ています)
これは私が常に使用している機能であり、これがないとVisual Studio Codeを使用するのに苦労します。
お探しのコマンドは、editor.action.copyLinesDownAction
とeditor.action.copyLinesUpAction
です。
関連するキーバインドを確認するには、次の手順を実行します。File > Preferences > Keyboard Shortcuts.
Windows:。
Windowsでは、以下のキーバインドが使用できます。
Mac:
Shift+Option+Down および Shift+OptionUp</kbd>。
Linux:
Ctrl+Shift+Alt+Downと、Ctrl+Shift+Alt+Up
(Linuxでは、テンキーのDownとUpが必要な場合があります)
また、コマンドeditor.action.moveLinesUpAction
とeditor.action.moveLinesDownAction
は、それぞれのコマンドに対応しています。moveLinesDownAction`は線を移動させるもので、Alt+DownとAlt+WindowsおよびMacではUp、LinuxではCtrl+Down、Ctrl+Upとなります。
からキーボードショートカットを見つけることができます。
ファイル、設定、キーボードショートカット
デフォルトのキーボードショートカットは
行を下にコピーする動作 : shift+alt+down
Copy Lines Up Action : shift+alt+up
Move Lines Up Action : alt+up
Move Lines Down Action : alt+down
また、以下のようにキーボードショートカットを上書きすることもできます。 ファイルと環境設定とキーボードショートカット
そして、keybindings.json
を編集します。
例:
[
{
"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"
}
]
試しに、ALT+SHIFT+UP/DOWN
私の場合はうまくいきました。