VSC ComBlocks (Visual Studio Code)
A Visual Studio Code extension to facilitate the easy creation and maintenance of
comment structures in software code.
Features
Builds a comment block of selected lines of text in an editor file. The current
line is used if there is no selection. The text from all lines in the selection
is formatted to a block surrounded by comment delimiters with borders top and
bottom. All lines in the selection are replaced with the commented block.
Leading and trailing comment block delimiters are removed from each line of the
selection so an existing comment block can be modified and rebuilt without the
need to manually remove the delimiters.
Leading, single-line comment delimiters are also removed. This allows input of
the text to be block commented using a leading comment so intellisense is not
activated.
If the selection is to be formatted (default option), the width of each line in
the comment block is optimized to keep all lines a similar width. If the number
of lines is given (optional), the line width will still be optimized, possibly
resulting in a block larger than requested.
<---------------------------- Selected Lines ---------------------->
This is non-formatted, contiguous text which will be formated into a
block of text according to the lines and maximum width specified.
<------------------ Commented Block ------------------->
'*-----------------------------------------------------*
'* This is non-formatted, contiguous text which will *
'* will be formated into a block of text according *
'* to the number of lines and maximum width specified. *
'*-----------------------------------------------------*
When not reformatted, the structure of the selected text is maintained
<------ Selected Lines ------> <-------- Commented Block -------->
'*--------------------------------*
This is a per-formatted block: '* This is a pre-formatted block: *
1) 1st bullet. '* 1) 1st bullet. *
2) 2nd bullet. '* 2) 2nd bullet. *
'*--------------------------------*
Delimiters
By default, the current Language Mode determines the left and
right delimiters used to build the comment block. The default top/bottom border
character is a dash (-
).
For languages with multi-line comments, each line starts with the left delimiter
character(s) and ends with the right delimiter character(s). For example, the
default delimiters for C-language source files are the multi-line
delimiters /*
and */
.
Some languages, including most shell scripts, have only single-line comment
delimiters. For these, each line starts with the delimiter character(s) followed
by an asterisk (*
) and ends with a single asterisk (*
). For example, the
default delimiters for a script written in Python are #*
and *
.
The default delimiters can be overridden in the Extension Settings,
below.
Demo

Extension Settings
Overrides default delimiters used to build comment blocks. By default, the
current Language Mode determines the left and right delimiters.
Each item in this list is a JSON object.
Defaults apply for properties not included in the override.
languageId {string}
required
VSCode Language Mode Identifier.
Identifies the language mode to override. The list of currently installed
languages and their identifiers can be found in the Change Language Mode
(Ctrl+K M
) dropdown.
left {string}
Character(s) used to start each line of the comment block.
right {string}
Character(s) used to end each line of a the comment block.
border {string}
Character to be used in creating the top/bottom borders of the comment block.
Default border character is a dash (-)
single {string|string[]}
Single-line comment identifier. These are removed from selected text before
building the comment block.
For example, these overrides are built-in.
{ "languageId": "bat", "left":":*", "right":"*", "single": ["@REM", "REM", ":"] },
{ "languageId": "coffeescript", "left":"#*", "right":"*" },
{ "languageId": "python", "left":"#*", "right":"*" },
{ "languageId": "ruby", "left":"#*", "right":"*" },
{ "languageId": "xml", "border":"=" },
{ "languageId": "xsl", "border":"=" }