Whitespace

  • Tabs and Spaces - Lines are indented using tabs or spaces depending on how the following preferences from File ‣ Preferences ‣ Settings ‣ Text Editor ‣ Editor are configured:
    • The Insert Spaces (editor.insertSpaces) option controls if the indentation will use space characters or tabs.

    • The Tab Size (editor.tabSize) option controls the size of a tab in spaces.

Note

When the editor.detectIndentation preference is enabled, Visual Studio Code will automatically detect the indentation style of any file opened in the editor. The detected values will be displayed in the right corner of the Status Bar and will have a higher priority over the editor.insertSpaces and editor.tabSize settings when the formatter is invoked.

../../_images/vs_file_indent_status_bar.png
  • Trim End of Line Whitespace (DVT.textEditor.systemVerilog.formatting.whitespace.trimEndOfLineWhitespace) - Controls whether to trim end of line whitespaces.

Before

After

../../_images/before-trim-end-of-line-whites.png
../../_images/after-trim-end-of-line-whites.png
  • Trim Whitespace Lines (DVT.textEditor.systemVerilog.formatting.whitespace.trimWhitespaceLines) - Controls whether to trim lines containing only whitespaces.

Before

After

../../_images/before-trim-whitespace-lines.png
../../_images/after-trim-whitespace-lines.png
  • Compact Whitespace Groups (DVT.textEditor.systemVerilog.formatting.whitespace.compactWhitespaceGroups) - Controls whether to compact consecutive whitespace characters. It does not affect indentation, that is the whitespace at the beginning of a line is not affected by this option.

Before

After

../../_images/before-compact-whitespace-group.png
../../_images/after-compact-whitespace-group.png
  • Compact Consecutive Empty Lines (DVT.textEditor.systemVerilog.formatting.whitespace.compactConsecutiveEmptyLines) - When enabled, consecutive empty lines are compacted into groups of lines whose number is less than or equal to a specified value. It does not affect the empty lines inside multi-line comments.
    • Maximum Number Of Consecutive Empty Lines (DVT.textEditor.systemVerilog.formatting.whitespace.maximumNumberOfConsecutiveEmptyLines) - Consecutive empty lines are compacted when their number exceeds this value.

Before

After (Preference is set to “1”)

../../_images/before-compact-consecutive-empty-lines.png
../../_images/after-compact-consecutive-empty-lines.png
  • Add Whitespace Before (DVT.textEditor.systemVerilog.formatting.whitespace.addWhitespaceBefore) - List of tokens before which whitespace will be added.

Before

After (“=” token)

../../_images/before-add-whitespace-before.png
../../_images/after-add-whitespace-before.png
  • Add Whitespace After (DVT.textEditor.systemVerilog.formatting.whitespace.addWhitespaceAfter) - List of tokens after which whitespace will be added.

Before

After (“=” token)

../../_images/before-add-whitespace-after.png
../../_images/after-add-whitespace-after.png
  • Remove New Line Before (DVT.textEditor.systemVerilog.formatting.whitespace.removeNewLineBefore) - List of tokens before which new lines will be removed.

Before

After (“=” token)

../../_images/before-remove-new-line-before.png
../../_images/after-remove-new-line-before.png
  • Remove New Line After (DVT.textEditor.systemVerilog.formatting.whitespace.removeNewLineAfter) - List of tokens after which new lines will be removed.

Before

After (“=” token)

../../_images/before-remove-new-line-after.png
../../_images/after-remove-new-line-after.png