Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a few methods you can use to keep a one-line code expression in C++ from being separated into multiple lines by VS Code:

  1. Use the backslash () character at the end of the line to indicate that the expression continues on the next line:
int sum = 1 + 2 \
          + 3 + 4;
  1. Use parentheses to group the expression:
int sum = (1 + 2
          + 3 + 4);
  1. Use the backslash and parentheses together:
int sum = (1 + 2 \
          + 3 + 4);
  1. Increase the width of the text editor window to allow for longer lines.