LoginSignup
9
2

More than 3 years have passed since last update.

VisualStudio2019のオプションからC#用の.editorconfigを生成する

Last updated at Posted at 2019-05-03

[ツール] > [オプション] > [テキストエディター] > [C#] > [コードスタイル] の"設定から .editorconfig ファイルを生成"ボタン1つで生成できるので便利

image.png

自動生成した .editorconfig に文字コードの設定を追加

文字コードの設定は自動生成したファイルには含まれていないようなので

# 文字コード
charset = utf-8

を生成したファイルに追記する

editorconfig によると

charset: set to latin1, utf-8, utf-8-bom, utf-16be or utf-16le to control the character set.

の文字コードを設定できるようなので、開発環境に合わせてどうぞ

コード整形のショートカットを叩くのも面倒な場合

Productivity Power Tools 2017/2019

上記の拡張機能をインストールして

[ツール] > [オプション] > [Productivity Power Tools] > [PowerCommands] の "Format document on save" のチェックボックスを ON すれば

保存時にフォーマットしてくれるようになるので、楽になります

参考: Visual Studio で保存時にフォーマットする

EditorConfig をよく知らない場合

どんなものなのかを知るには、下記の記事を見るのが1番早いと思います

どんなエディタでもEditorConfigを使ってコードの統一性を高める

公式ドキュメント

Visual Studio 2019

コードのスタイル設定

EditorConfig の .NET コーディング規則の設定

EditorConfig で移植可能なカスタム エディター設定を作成する

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