LoginSignup
1
0

More than 3 years have passed since last update.

VSCode 選択テキスト 大文字・小文字変換 キーボードショートカット

Posted at

環境

  • Win10Home
  • VSCode1.53.2

手順

キーボードショートカット設定を開く

Image 2021-03-03 14.38.52.png

ショートカットコマンドを設定

Image 2021-03-03 14.45.33.png

  • コマンド検索窓に「editor.action.transformTo」と入力すると、お目当ての変換コマンドが探せる(現在使える変換コマンドは4つだった
  • 鉛筆アイコンから、直接ショートカットを登録できる

すでにそのコマンドは使用されていると怒られる

  • が、↓大抵もうDefaultで使用されていて、アラートが出る(そのコマンドすでに使われてるよ!

Image 2021-03-03 14.49.45.png

なので、ショートカットコマンドを利用する条件定義をする

Image 2021-03-03 14.45.33.png

  • 先のショートカット一覧右上のファイルアイコンをクリック
  • keybindings.jsonが開くので、自分のための設定を記述

keybindings.json - test - Visual Studio Code 2021-.png

// Place your key bindings in this file to override the defaults
[
  {
    //A->a
    "key": "ctrl+u",
    "command": "editor.action.transformToLowercase",
    "when": "editorHasSelection && editorTextFocus"
  },
  {
    //a->A
    "key": "ctrl+shift+u",
    "command": "editor.action.transformToUppercase",
    "when": "editorHasSelection && editorTextFocus"
  },
  {
    //ApplePie->apple_pie
    "key": "ctrl+shift+s",
    "command": "editor.action.transformToSnakecase",
    "when": "editorHasSelection && editorTextFocus"
  },
  {
    //apple->Apple
    "key": "ctrl+shift+t",
    "command": "editor.action.transformToTitlecase",
    "when": "editorHasSelection && editorTextFocus"
  }
]
  • "when":のところが条件の記述
    • この場合は、「範囲選択が行われていること」(editorHasSelection)と「エディタにフォーカスがあること」(editorTextFocus)
  • 記述したら 保存して終了でショートカット使えるようになる

お世話になった記事 :bow::bow:

1
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
1
0