80
65

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Mac・VSCode】よく使うショートカット (カーソル移動, 矩形選択, 置換)

Last updated at Posted at 2020-08-31

はじめに

VSCodeには色々と便利なショートカットがあります。
もっと早く知っておきたかったなぁと思うショートカットをいくつか書いていきたいと思います。

今回の記事の内容をおおまかに分けると、

  • カーソル移動・範囲選択系
  • 矩形選択
  • 置換

という感じです順に解説します。

カーソル移動・範囲選択系

単語単位でのカーソル移動

option + ← or →
単語の移動.gif

行頭、行末のカーソル移動

command + ← or →
行頭、行末の移動.gif

1文字ずつ範囲選択

shift + ← or →

範囲選択.gif

単語単位での範囲選択

option + shift + ← or →
単語単位で範囲選択.gif

現在のカーソル位置か行頭 or 行末までの範囲選択

command + shift + ← or →
行単位で範囲選択.gif

上下の行の入れ替え

option + ↑ or ↓
上下の行の入れ替え.gif

ファイルの先頭と最後の移動

command + ↑ or ↓
ファイルの先頭と最後の移動.gif

矩形選択, マルチカーソル

次は矩形選択, マルチカーソルです。
複数のカーソルを同時に扱うことができ、カーソル移動で紹介したコマンドと組み合わせることで絶大な威力を発揮します!

任意の箇所をマルチカーソルに

option + クリック
好きな場所を選びたい.gif

ファイル内検索を利用したマルチカーソル

ファイル内検索( command + F ) → option + Enter
検索結果全体にマルチカーソルが適用されます。
ファイル内検索をした単語全体を選択.gif

矩形

command + option + ↑ or ↓
長方形型で選択したい時などに便利です。
矩形.gif

正規表現による置換

残しておきたい部分を変数に入れて置換

(※こちらは少し正規表現の勉強も必要ですが使えるとすごく便利です!)
変数にしたい部分を( )で囲むと、囲んだ順に\$1, \$2, \$3...に代入される
置換.gif

80
65
3

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
80
65

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?