SlickEditŪ Core provides two features that allow you to surround existing text with new text. Dynamic Surround lets you selectively include more or fewer lines in a block structure, like an if statement. Surround With lets you surround any selected text with text predefined in one of the Surround With Aliases. In addition, Unsurround can be used to remove code block structures.
Dynamic Surround provides a convenient way to surround a group of statements with a block statement, indented to the correct levels according to your preferences. This feature works in conjunction with the syntax expansion and alias expansion features (see Syntax Expansion and Language-Specific Aliases). It is designed to help you keep your hands on the keyboard, thereby improving your speed and efficiency.
Dynamic Surround is supported for any language that uses block statements. By default, Dynamic Surround is turned on for all supported langauges. To turn it off, select Window → SlickEdit Preferences → Languages, expand your language category and language, then click Indent and uncheck Use Dynamic Surround.
SlickEditŪ Core enters Dynamic Surround mode automatically immediately after you expand a block statement (for instance, by typing if then pressing Space). After expanding the statement, a box is drawn around it as a visual guide, and you can pull the subsequent lines of code or whole statements into the block by using the Up, Down, PgUp, or PgDn keys.
Dynamic Surround stays active until you press ESC. During that time auto-completions and symbol preview are unavailable.
You can also invoke Dynamic Surround on an existing block structure using the dynamic-surround command. Put the cursor on the line containing the block structure keyword, like an "if" or a "for", press ESC to open the SlickEdit Core command line, then type dynamic-surround. If SlickEdit Core recognizes the block structure, the box will be drawn and you will be able to expand or contract the structure using the Up, Down, PgUp, or PgDn keys. By default, this command is not associated with a key binding. See Creating Bindings for information on creating your own.
The following screen shot shows the Syntax Expansion menu that appears after typing "if" in a C++ file:

After pressing Space to expand the statement, Dynamic Surround is activated, with a blue rectangle drawn around the expanded statement, as shown below:

Pressing the Down arrow key pulls the code block into the statement, indented to the correct levels, as shown below:

The finished code is shown below:

Statements that are pulled into the block are indented according to your indent settings (see Syntax Indent). The color of the rectangle box guide is controlled by the Block Matching screen element (see Colors).
Syntax Expansion must be on for Dynamic Surround to work. Both options are on by default. To turn off either of these options, from the main menu, select Window → SlickEdit Preferences → Languages, expand your language category and language, then select Indent. Clear the option(s) Use Dynamic Surround and/or Syntax expansion.
Surround With makes it fast and easy to wrap existing lines of code in a new block structure. Surround With is supported for the languages C, C++, C#, HTML, Java, JavaScript, and XML. Highlight the lines to surround, right-click, and select Surround Selection With, or use the surround_with command. The Surround With dialog appears, with a pre-defined list of structures based on the current file extension.

Select the structure you wish to surround with, then click OK.
If there is no selection and you activate Surround With, the current line or code block will be automatically highlighted for surrounding (the same function performed by the select_code_block command).
Surround With aliases are created and modified the same way as other aliases, with the addition of the %\m sur_text% escape sequence. This sequence indicates where the selected text should be placed, and can be used multiple times within a single Surround With alias. See Surround With Commands for more information on sur_text.
To view or modify the Surround With aliases, use the surround_with command to display the Surround With dialog, then click the Customize button. This will display the language-specific Alias options page with the Surround With option selected. As an example, the C Alias options page is shown below.

The list of Surround With structures for the chosen language is shown in the list box on the left. To modify one of the Surround With structures, complete the following steps:
Select the structure that you wish to modify. Notice the alias for the structure appears in the text box on the right.
Modify the alias to suit your needs. For a list of escape sequences and examples, see Alias Escape Sequences. For more information about using the Alias options page, see Creating a Language-Specific Alias.
When you are finished, click OK on the Alias options page.
Click OK on the Surround With dialog.
There are three commands available for working with Surround With:
surround_with - This command is used to display the Surround With dialog, allowing you to pick a structure to surround selected text with. This command can be bound to a key, see Creating Bindings for more information.
sur_text - This is a Slick-CŪ function that can only be used inside of a Surround With alias. It is used to indicate where the selected text should be placed and can be used multiple times within a single Surround With alias. sur_text can take several parameters, which can appear in any order. The available parameters are:
-beautify - This is the default for C, Java, and others. It beautifies the results of the alias expansion.
-begin text - Prefixes each line of the selection with text.
-deselect - This is the default parameter. It specifies to leave the text deselected.
-end text - Suffixes each line of the selection with text.
-ignore chars - The -begin, -indent, and -stripbegin options will ignore any chars when finding the beginning of the selected line.
-indent - Indents each line of the selection.
-nobeautify - This is the default for HTML, XML, and others. It specifies that the editor should not attempt to beautify the results of the alias expansion.
-notext - Specifies that no text should be pasted.
-select - Leaves the text selected.
-stripbegin text - If any line begins with text, text is removed from the line. This option is applied before -begin.
-stripend text - If any line ends with text, text is removed from the line. This option is applied before -end.
surround_with_if - This is a wrapper command that expands the if alias for the selected text. This command can be bound to a key, see Creating Bindings for more information.
The use of Surround With can be streamlined by using wrapper commands and key bindings. You can create your own wrapper commands. The following example is the definition of surround_with_if _command void surround_with_if() name_info(',':
VSARG2_REQUIRES_EDITORCTL | VSARG2_MARK | VSARG2_REQUIRES_AB_SELECTION)
{
surround_with('if');
}You must change the name of the command and the argument passed to surround_with. The argument does not have to be an exact match with the alias name. For instance, calling surround_with('i') will prompt you to select the if, if...else, or include once alias. If there is an exact match, that alias will be used. In the case of surround_with_if, "if" matches the beginning of both the if and if...else aliases, but the if alias is used because it is an exact match.
After you create your wrapper command, you can bind it a key or invoke it from the command line.
For more information on working with commands, see the Slick-CŪ Macro Programming Guide.
Unsurround is a feature that lets you remove the surrounding text from a code block. This is particularly effective when used with Dynamic Surround. Unsurround is supported for the following languages: ActionScript, AWK, C#, C++, CFML, HTML, Java, JavaScript, Perl, PHP, Slick-CŪ, Tcl, and XML.
To use Unsurround, right-click on a selected code block and select Unsurround, or use the unsurround command. By default, the unsurround command is bound to Ctrl +Shift +Del.
For example, to remove the if statement structure from a code block, select the code block or part of the code block, then right-click and select Unsurround (or use the unsurround command). The entire code block under the cursor is automatically highlighted and a dialog prompt appears to confirm the unsurround operation. Click OK, and the if line of the code block as well as the line containing the closing brace are removed. The remaining code is unindented to the correct level.
Unsurround is also associated with the cut_line (Ctrl+Backspace) and delete_line (Ctrl+Del) commands. When one of these commands is invoked while the cursor is on the first line of a block statement, the Delete Code Block dialog appears, from which you can choose to delete the line, delete the entire block, or unsurround the block.

Each of these operations copies the removed text to the clipboard. This is useful if you want to paste the structure into a different location, because as soon as the text is pasted, SlickEditŪ Core enters Dynamic Surround mode, allowing you to pull statements into the pasted block.
The Delete Code Block dialog also contains an option to Always just delete line when cut_line or delete_line operations are invoked. Selecting this option will prevent the dialog from appearing when these operations are used. To see the dialog again, use the cut_code_block command.