Add / Remove Block Delimiters (C#, C++)

  • 2 minutes to read

Adds or removes optional block delimiters.


There are many cases when block delimiters are optional; for example, there can be a single-line loop body or if block. There can also be a nested loop or if statement within another loop or if statement. Sometimes block delimiters increase code readability even if they are optional. For example, they let you easily locate the end of a lengthy nested block. You may also need to add block delimiters if you are going to add code to a single-line block. On the other hand, you may wish to remove unnecessary block delimiters if you’ve reduced the block to a single line. In both cases, you don’t have to manually locate the start and end of the required code block - the Add / Remove Block Delimiters (C#, C++) refactoring automatically inserts or removes delimiters at the correct locations .


Available from the context menus or via shortcuts:

  • when the edit cursor or caret is on the first statement within an if, else or loop statement. The corresponding block delimiters should be optional.
  • when the edit cursor or caret is right before, or right after an optional block delimiter.


if (productExists)GetOrders();


if (productExists) {