2025年5月10日土曜日

キーボードショートカット カスタム AutoHotKey vscode

  1. AutoHotKey
    • Toggle: 無変換 f でvimのNormalモードみたいになって、無変換を押さずに右手だけで操作できる
    • script.ahk
              ; AutoHotKey v2
              ; {blind} shift同時押し
      ; sendevent  押しっぱ時貫通防止
      
      ; ! alt
      ; + shift
      ; ^ ctrl
      
      ; vk1d 無変換
      ; vkbb セミコロン
      ; vkba コロン
      
      vk1d & i::sendevent "{blind}{up}"
      vk1d & j::sendevent "{blind}{left}"
      vk1d & k::sendevent "{blind}{down}"
      vk1d & l::sendevent "{blind}{right}"
      
      vk1d & u::sendevent "{blind}{home}"
      vk1d & o::sendevent "{blind}{end}"
      
      vk1d & h::sendevent "{blind}{pgup}"
      vk1d & n::sendevent "{blind}{pgdn}"
      
      vk1d & vkbb::enter
      vk1d & p::bs
      
      ; sendeventのがいいか?
      vk1d & ,::send "!{left}"
      vk1d & .::send "!{right}"
      
      vk1d & q::escape
      
      vk1d & 8::[
      vk1d & 9::]
      
      vk1d & vkba::_
      vk1d & m::&
      
      vk1d & 1::reload
      
      ; vscode エクスプローラー ctrl 0
      vk1d & 0::^0
      
      ; デバッグ時
      vk1d & w::f11
      vk1d & e::f10
      
      ; 無変換 capslockで shift capslock発動 (大文字)
      vk1d & f12::SetCapsLockState !GetKeyState("CapsLock", "T")
      
      ;---↑ insert mode---------------------------------
      ; 無変換fで右手オンリー読み取り専用モード
      ; fでもとに戻す
      ;---↓ normal mode---------------------------------
      
      toggle := false
      
      vk1D & f::{
          global toggle
          toggle := true
      }
      
      #HotIf toggle
      
      f::{
          global toggle
          toggle := false
      }
      
      i::sendevent "{blind}{up}"
      k::sendevent "{blind}{down}"
      ; ctrl i,kを効かせるため
      ^i::sendevent "{blind}{up}"
      ^k::sendevent "{blind}{down}"
      
      j::sendevent "{blind}{left}"
      l::sendevent "{blind}{right}"
      ^j::sendevent "{blind}{left}"
      ^l::sendevent "{blind}{right}"
      
      u::sendevent "{blind}{home}"
      o::sendevent "{blind}{end}"
      ^u::sendevent "{blind}{home}"
      ^o::sendevent "{blind}{end}"
      
      h::sendevent "{pgup}"
      n::sendevent "{pgdn}"
      
      ; sendeventのがいいか?
      ,::send "!{left}"
      .::send "!{right}"
      
      vkbb::enter
      ;p::bs
      p::escape
      
      0::^0
      1::^1 ; vscode ctrl 1でエディターに戻る
      
      m::f12 ; 定義元にジャンプ
      
      b::^t ; シンボル検索
      
      4::f4 ; すべての(参照alt shift f12)検索 次の結果
      
      #HotIf
              
  2. vscode
    • keybindings.json
      [
          {// デバッグ時、現在の行まで進める
              "key": "shift+f10",
              "command": "editor.debug.action.runToCursor"
          },
          {// ブレークポイント
              "key": "f9",
              "command": "editor.debug.action.toggleBreakpoint",
              "when": "debuggersAvailable"
          },
          {// 行複製
              "key": "ctrl+b",
              "command": "editor.action.copyLinesDownAction",
              "when": "editorTextFocus && !editorReadonly"
          },
          {// tasks.jsonのrunタスクを実行 (exe直起動)
              "key": "ctrl+r",
              "command": "workbench.action.tasks.runTask",
              "args": "run"
          },
          {// pageupをカーソル5行上に移動
              "key": "pageup",
              "command": "cursorMove",
              "args": {
                  "to": "up",
                  "by": "wrappedLine",
                  "value": 5,
              },
              "when": "editorFocus"
          },
          {// 選択用
              "key": "shift+pageup",
              "command": "cursorMove",
              "args": {
                  "to": "up",
                  "by": "wrappedLine",
                  "value": 5,
                  "select": true
              },
              "when": "editorFocus"
          },
          {// pagedonwをカーソル5行下に移動
              "key": "pagedown",
              "command": "cursorMove",
              "args": {
                  "to": "down",
                  "by": "wrappedLine",
                  "value": 5,
              },
              "when": "editorFocus"
          },
          {// 選択用
              "key": "shift+pagedown",
              "command": "cursorMove",
              "args": {
                  "to": "down",
                  "by": "wrappedLine",
                  "value": 5,
                  "select": true
              },
              "when": "editorFocus"
          },
          {// ctrl rightを単語移動じゃなくて5文字右に移動
              "key": "ctrl+right",
              "command": "cursorMove",
              "args": {
                  "to": "right",
                  "value": 5,
              },
              "when": "editorFocus"
          },
          {// 選択用
              "key": "ctrl+shift+right",
              "command": "cursorMove",
              "args": {
                  "to": "right",
                  "value": 5,
                  "select": true
              },
              "when": "editorFocus"
          },
          {// ctrl leftを単語移動じゃなくて5文字左に移動
              "key": "ctrl+left",
              "command": "cursorMove",
              "args": {
                  "to": "left",
                  "value": 5,
              },
              "when": "editorFocus"
          },
          {// 選択用
              "key": "ctrl+shift+left",
              "command": "cursorMove",
              "args": {
                  "to": "left",
                  "value": 5,
                  "select": true
              },
              "when": "editorFocus"
          },
          {// エクスプローラーで新規ファイル作成
              "key": "ctrl+n",
              "command": "explorer.newFile"
          },
          {// 行削除
              "key": "ctrl+l",
              "command": "editor.action.deleteLines"
          },
          {// ターミナル切り替え
              "key": "ctrl+j",
              "command": "workbench.action.terminal.toggleTerminal",
              "when": "terminal.active"
          }
      ]
                  
  3. Change Key
    • CapsLock: F12
    • 変換: Ctrl
    • かな: Shift

0 件のコメント:

コメントを投稿