Question How to chop long lines in ReSharper
Answer
Method 1: Reformat arbitrary selection
Once can chop an arbitrary line in Rider or ReSharper by using the "Reformat Selection" feature following the steps below:
- Select the Line
- Highlight the line or segment of code you wish to chop.
- Open Reformat and Cleanup
- Use Alt+Enter and choose Code → Reformat and Cleanup → Reformat Selection → Spacious format (chop).
Method 2: Chop lines exceeding maximum line length
Alternatively, one can configure the maximum line length and use "Chop long line":
- Open Settings
- Open File → Settings
- Navigate to Code Style Settings
- In the settings window, navigate to Editor → Code Style → C#
- Configure Hard Wrap
- Look for the "Hard wrap at" option. This setting allows you to specify the maximum length a line can be before Rider automatically chops it. Adjust this value according to your preference (e.g., 120 characters).
- Chop the line
- Place a cursor on the line that should be chopped, use Alt+Enter and invoke Chop long line
With these settings configured, Rider will offer the "Chop Long Line" action for lines that exceed the specified hard wrap length.
Comments
0 comments
Please sign in to leave a comment.