LoginSignup
2
2

More than 3 years have passed since last update.

VSCodeのターミナルでカーソルの単語移動をする

Posted at

自分用メモ

itermでのカーソルの単語移動は設定からできるし、VSCodeのエディタでの単語移動も簡単に設定できる。記事もそこそこ見つかる。VSCodeのターミナルでも単語移動自体はOption+矢印キーでできるがいちいちそこに指を持っていくのは辛いし、VSCodeなら任意のコマンドを割り当てたい。そのやり方がわからなかったのでメモする。

VSCodeでは"command": "workbench.action.terminal.sendSequence"を使ってエスケープシーケンスを送れる。単語移動に該当するエスケープシーケンスを送ればよいのだがそれが全然わからなかった。
結果は以下を追加すればよかった。keyは任意で。

{
    "key": "cmd+b",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u001bb" },
    "when": "terminalFocus"
},
{
    "key": "cmd+f",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u001bf" },
    "when": "terminalFocus"
}

これでVSCodeでのターミナルで単語移動を任意コマンドに割り当てられるようになりとても捗る。
注意)MacOXでのみ確認。Windowsは不明。

2
2
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
2