Configuring code formatting from code selection with ReSharper
While we now have great control over how our source code is formatted, it may be like an airplane cockpit with too many options. In this post, we’ll look at the easiest way to tune the code formatting engine to our liking!
This post is part of a series around changes in the ReSharper and Rider code formatter:
- Code formatting engine updates in ReSharper and Rider
- Different code styles for different blocks of code
- Aligning code in columns
- Configuring code formatting from code selection
Figuring out which code style settings apply to a block of code
With all of the existing (and new) code formatter changes, figuring out which settings apply to a block of code can be overwhelming. Fortunately, ReSharper provides an easy way to do this. Note that the following is currently only available in ReSharper, and is yet to be implemented in Rider.
To see which settings affect a code block, we can select it, press Alt-Enter and choose Format selection | Configure. ReSharper will then provide an overview of all settings that apply to that selection:
We can use this knowledge to configure the code style to our liking, by editing them directly in the ReSharper options or by adding a specific code style in comments.
We can then save our formatting changes for our own use, or if we’re looking to modify a team-wide code style, save them to a solution team-shared settings layer.
This concludes our series about the code formatter improvements made in ReSharper and Rider 2017.3 Early Access Programs. Download ReSharper 2017.3 EAP and give it a try!
Subscribe to Blog updates
Creating Custom AI Prompts
AI has swept through the software development industry like a wildfire. So people want to learn how to best use AI in their day to day tasks. In this post we’ll take a look at how to write custom prompts for use with the JetBrains AI Assistant in ReSharper and Rider so you can make the most of AI.&n…
12 Debugging Techniques In JetBrains Rider You Should Know About
Twelve must know debugging features in JetBrains Rider every developer should know.
Interceptors – Using C# 12 in Rider and ReSharper
Welcome to our series, where we take a closer look at the C# 12 language features and how ReSharper and Rider make it easy for you to adopt them in your codebase. If you haven’t yet, download the latest .NET 8 SDK and update your project files! In this series, we are looking at: Primary …