0
0

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.

【VSCode】余計な空白を色付けして表示する方法と自動削除する方法(git diffの赤色表示をエディターに適用する)

Posted at

git diffでコードをチェックした時に、不要なスペースが入っていると赤色で表示される。

image.png

これをコードエディタでも表示できるようにする方法。


## 設定手順

拡張機能でTrailing Spacesを検索し、インストールすればOK。

image.png

image.png

git diffと同じように不要なスペースが赤色でハイライトされた。

追加設定

settings.jsonを開き以下を追記すれば、機能を追加できる。

settings.jsonの変更方法

(1) ctrl + shift + p でコマンド入力窓を表示する。
(2) settings.jsonを入力

image.png

(3) 「基本設定を開く」をクリック
(4) 指定のコードを追記する

{
  "workbench.iconTheme": "vs-minimal",
   
   省略
   
  "emmet.triggerExpansionOnTab": true,
  "editor.rulers": [80]
}

ハイライトの色の変更

{ "trailing-spaces.backgroundColor": "rgba(255,0,0,0.3)" }

rgbaで色を指定できる。4つ目の数値は透明度。1が透過なし。0が完全透過。

image.png

自動削除

保存した時に自動で削除する。

"trailing-spaces.trimOnSave": true
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?