Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9699

C# FixFormatなき世界で生きる(c#のフォーマッターをカスタマイズする)

$
0
0
C# FixFormatがない 久々に作りかけのUnity Projectを開き、拡張機能を覗くとあれまビックリ、C# FixFormatが消えていた。 調べてみるとdotnet-formatというCLIツールが良いらしいのだが、仕事でガッツリ書くわけでもないため楽をした。 omnisharp.json プロジェクトルートにomnisharp.jsonというファイルを作り、FormattingOptionsで設定をカスタマイズできる。 設定項目一覧。 例:if文などの末尾にある中括弧を同じラインに置きたい。 omnisharp.json { "FormattingOptions": { "NewLinesForBracesInLambdaExpressionBody": false, "NewLinesForBracesInAnonymousMethods": false, "NewLinesForBracesInAnonymousTypes": false, "NewLinesForBracesInControlBlocks": false, "NewLinesForBracesInTypes": false, "NewLinesForBracesInMethods": false, "NewLinesForBracesInProperties": false, "NewLinesForBracesInObjectCollectionArrayInitializers": false, "NewLinesForBracesInAccessors": false, "NewLineForElse": false, "NewLineForCatch": false, "NewLineForFinally": false } } prettierを使っている JSなどを書いてるとdefaultFormatterをprettierに設定していることもあるだろう。 その場合はこうする。 settings.json { "editor.defaultFormatter": "esbenp.prettier-vscode", "[csharp]": { "editor.defaultFormatter": "ms-dotnettools.csharp" } }

Viewing all articles
Browse latest Browse all 9699

Trending Articles