Table of content

Surround Selection

Simple but valuable commands in Visual Assist make it easy to surround selections with:

  • Line comments //
  • Block-style comments /* */
  • Parentheses
  • Braces
  • #ifdef and #endif in C/C++
  • Regions in C#

Several of the surrounding commands are intelligent, meaning they don't blindly surround like a snippet might. Several are toggles so they "surround on" and "surround off", adjusting interior code as necessary.

These commands differ from the Surround-With VA Snippets also available in Visual Assist but accessed from different places in the IDE.

Visual Assist versus Visual Studio

The Surround Selection commands complement or supplant similar functionality of the IDE.

Access via Character Toggles

Enable or disable Surround Selection commands via character toggles in the options dialog for Visual Assist. 

Access via Shortcuts

In addition to character toggles, you can assign shortcuts to the surround commands related to comments. Keyboard shortcuts are available for:

  • SelectionLineComment
  • SelectionLineUnComment
  • SelectionToggleLineComment
  • SelectionLineBlockComment
  • SelectionLineBlockUncomment
  • SelectionToggleBlockComment

Comment //

To comment lines with // characters, select one or more lines and press a single / character. If you want to comment a single line, you must first select the entire line. (Use the selection margin.)

If you want to comment several lines, you need only partial selections of the first and last lines.

The entire lines will be commented.

The / is a toggle. If line(s) in the selection are already commented, typing / will uncomment them.

If a subset of lines in the selection is already commented, Visual Assist will insert additional comment characters so the block can be uncommented to its original state.

If you attempt to comment a partial-line selection using /, Visual Assist will insert block-style comments.

Comment Space after //

You can tell Visual Assist to include, or not include, a space between a // and a line toggled into a comment. The space will be removed when toggling to uncomment. Specify your preference in the options dialog for Visual Assist.

Comment /* */

Comment a selection in block-style by typing a single * when a selection is present.

Commenting of a selection that already contains block-style comments causes the inner comment characters to be disabled. If you use Visual Assist to uncomment the outer block, the inner block-style comments will be re-enabled.


Press ( to surround a selection with parentheses. Press ( again to add another pair. Press Undo to revert each operation.


Press { to surround a selection with braces and indent the selection. The command works with partial-, single-, and multi-line selections.

The Format Selection command of the IDE is run automatically on the new selection. Press Undo to revert the formatting; press Undo a second time to eliminate the braces.

#ifdef and #endif

In C/C++, select one or more lines and press # to surround the selection with #ifdef and #endif. Visual Assist will prompt for the condition in the directive.

Unlike other commands that surround, the # is not a toggle.

Edit the VA Snippet for #ifdef (VA) to change the directive.


In C#, select one or more lines and press # to surround the selection with #region and #endregion.

After the surround, the text caret is placed where the region name should be typed.

Unlike other commands that surround, the # is not a toggle.

Edit for VA Snippet for #region (VA) to change the directive.

Registry Settings

Value Name Meaning
LineCommentSlashCount Comment code with more than two slashes