LoginSignup
2
0

内容

VScodeでコードを選択中にTabを押すとインデントされるのですが、
それをSpaceでもできたら便利だろうということ

方針

VSCodeのショートカットキーは設定で簡単に変えられるようなので、設定だけでどうにかなるであろう

完成品

keybindings.json
[
    {
        "key": "space",
        "command": "editor.action.indentLines",
        "when":"editorHasSelection && editorTextFocus && !editorReadonly"
    },
    {
        "key": "shift+space",
        "command": "editor.action.outdentLines",
        "when":"editorHasSelection && editorTextFocus && !editorReadonly"
    }
]

動作

コードを読めばほぼ自明な気がしますが一応

  1. コードを選択中にspaceを押す → 選択範囲にインデントが1追加
  2. コードを選択中にshift+spaceを押す → 選択範囲のインデントが1削除

設定方法

  1. Ctrl+Shift+Pで開くウインドウから、Open Keyboard Shortcuts (JSON)を開く
    image.png
  2. keybindings.jsonが出てくるので、そこを上記コードで置き換える1
  1. 既存コードがある場合は置き換えではなく、中身の追記をしてください

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0