Format

This section describes items on the Format menu and associated dialogs and views.

Format Menu

The Format menu contains items pertaining to editor windows and the current document. The table below lists a summary of these items.

Document Menu Item

Description

Command

Beautify

gui_beautify

Format Paragraph

Reflows the text in the current paragraph according to the margins.

reflow_paragraph

Format Selection

Reflows the selected text according to the margins.

reflow_selection

Format Columns

Format columns according to words.

format_columns

Add Selected Expr

Adds the result of evaluating each line in a selected area of text.

add

Quick Refactoring

Displays Quick Refactoring menu. See Quick Refactoring Menu.

N/A

Imports

Displays Imports refactoring menu. See Imports Menu.

N/A

Sort

Sorts current buffer or selected text. See Sorting Text.

gui_sort

Spell Check

Displays menu of spell checking commands. See Spell Check Menu.

N/A

Edit Javadoc Comment

Edits Javadoc comments for the current source file.

javadoc_editor

Comment Block

Converts selected text into block comment using box comment setup characters. See Commenting.

box

Comment Lines

Converts selected lines into line comments using the line comment setup. See Commenting.

comment

Uncomment Lines

Uncomments any commented lines and ignores any that isn't commented. See Commenting.

comment_erase

Reflow Comment

Reflows and reformats the current block comment. See Reflow Comment Dialog.

gui_reflow_comment

Comment Setup

Displays the language-specific Comment options screen, which contains settings for box and line comments. See Language-Specific Comment Options.

comment_setup

Comment Wrap

Toggles comment wrap on/off.

comment_wrap_toggle

XML/HTML Formatting

Displays the XML/HTML Formatting menu. See Document Menu.

N/A

Select Mode

List all modes and lets you select one. See Language Editing Mode.

select_mode

Language Options

Displays the Options dialog open to the language-specific General options screen for the language in the current buffer. See Language Options.

setupext

Tabs

Sets tab stops.

gui_tabs

Margins

Sets margins.

gui_margins

Indent with Tabs

Toggles indenting with tabs on/off. See Syntax Indent.

indent_with_tabs_toggle

Word Wrap

Toggles word wrap on/off.

word_wrap_toggle

Justify

Sets/displays paragraph justification style.

gui_justify

Read Only Mode

Toggles read-only mode on/off.

read_only_mode_toggle.

Adaptive Formatting

Toggles Adaptive Formatting on/off. See Adaptive Formatting.

adaptive_format_toggle

Quick Refactoring Menu

The Format → Quick Refactoring menu contains the Quick Refactorings that can be used for C++, C#, Java, and Slick-C®. These are summarized in the table below. For more information about working with these refactorings, see Quick Refactoring.

Quick Refactoring Menu Item

Description

Command

Rename

Rename symbol.

refactor_quick_rename

Extract Method

Extract the selected code block into a new function.

refactor_quick_extract_method

Modify Parameter List

Modify the parameter list of a method.

refactor_quick_modify_params

Encapsulate Field

Encapsulate field using Context Tagging®.

refactor_quick_encapsulate_field

Replace Literal with Constant

Replace literal value with a declared constant.

refactor_quick_replace_literal

Imports Menu

The Format → Imports menu contains options for organizing Java imports. For more information, see Organize Imports.

Imports Menu Item

Description

Command

Organize Imports

Organize import statements in a Java file.

jrefactor_organize_imports

Add Import

Add import statement for symbol under cursor.

jrefactor_add_import

Options

Displays the Options dialog open to Organize Java Imports node. See Organize Imports.

jrefactor_organize_imports_options

Spell Check Menu

The Format → Spell Check menu contains spell checking operations and access to options. For more information about working with Spell Check, see Spell Checking. The table below contains a summary of the Spell Check menu items.

Spell Check Menu Item

Description

Command

Check from Cursor

Spell check starting from cursor.

spell_check

Check Comments and Strings

Spell check comments and strings starting from cursor.

spell_check_source

Check Selection

Spell check words in selection.

spell_check_selection

Check Word at Cursor

Spell check word at cursor.

spell_check_word

Check Files

Spell check multiple source files.

spell_check_files

Spell Options

Display/modify spell checker options.

spell_options

XML/HTML Formatting Menu

The Format → XML/HTML Formatting menu is used to activate these features in SlickEdit Core. You can enable and/or disable Tag Layout and/or Content Wrap for either file type on a global basis or on a per document basis. See XML/HTML Formatting for more information.

XML/HTML Formatting Menu Item

Description

Command

Current Document Options

Displays the Current Document Options Dialog.

xml_html_document_options

Enable XML Formatting

Toggles XML Formatting on/off.

xml_formatting_toggle

(XML) Content Wrap

Toggles XML Content Wrap on/off.

xml_contentwrap_toggle

(XML) Tag Layout

Toggles XML Tag Layout on/off.

xml_taglayout_toggle

Enable HTML Formatting

Toggles HTML Formatting on/off.

html_formatting_toggle

(HTML) Content Wrap

Toggles HTML Content Wrap on/off.

html_contentwrap_toggle

(HTML) Tag Layout

Toggles HTML Tag Layout on/off.

html_taglayout_toggle

Format Dialogs and Tool Windows

This section describes the dialogs and views that are associated with the Format menu items.

Reflow Comment Dialog

The Reflow Comment dialog (Format → Reflow Comment), shown below, is used to reflow block comments, paragraphs, or a selection of the current file.

The following options are available:

  • Entire block comment - If selected, reflows an entire block comment based on the current width and border settings for the block comment.

  • Match block comment border settings - If selected, forces the borders to conform to the comment settings (Format → Comment Setup- see Language-Specific Comment Options).

  • Current paragraph - If selected, reflows the current paragraph within the block comment.

  • Selection - If selected, reflows a selection within a block comment paragraph based on current settings.

  • Comment width - Select one of the width options to reflow a block comment to the margins or the width that you specify in these fields. See Language-Specific Comment Wrap Options for information.

For more information about comments, see Commenting.

Current Document Options Dialog

The Current Document Options dialog allows you to enable/disable aspects of XML or HTML Formatting for just the current document. It can be displayed by clicking Format → XML/HTML Formatting → Current Document Options, or by using the xml_html_document_options command.

The dialog contains the following:

  • Formatting scheme - This drop-down specifies the formatting scheme applied to this document. Choose from the list of available schemes.

  • Auto formatting options - These are the aspects of XML/HTML Formatting that can be enabled/disabled for the current document.

  • Configure Schemes button - Displays the XML/HTML Formatting Scheme Configuration Dialog, which allows you to modify or create a new scheme to apply to the current document.

For more detailed information, see Enabling/Disabling for the Current Document.

XML/HTML Formatting Scheme Configuration Dialog

This dialog is used to configure the way XML and HTML code is automatically formatted as you edit. Note that XML/HTML Formatting must be enabled in order for these settings to work. See XML/HTML Formatting for more information.

To access this dialog, from the main menu, click Format → XML/HTML Formatting → Current Document Options, then click the Configure Schemes button on the Current Document Options dialog. Or, use the xml_html_options command to display the dialog.

The Scheme column shows a list of available schemes. The Tags column shows a list of tags associated with the selected scheme. Right-click in this column for a menu of operations such as add, save, and more. See Working with Schemes and Working with Tags for more details.

A Preview at the bottom of the dialog shows how the selected tag will be formatted in your code. Click the XML Options or HTML Options button to jump to the language-specific Formatting Options page for each language (this is the same as Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Formatting).

The following sections describe the tabs and how each setting works. Before configuring settings, be sure the scheme and tag(s) that you want to affect are selected.

Caution

XML/HTML Formatting does not currently affect XML or HTML Beautifier settings. If you run the beautifier on documents that have been automatically formatted through XML/HTML Formatting, you may find unexpected results.

General Settings

The General tab of the XML/HTML Formatting dialog is shown below.

It contains the following general settings:

  • End tags settings - These options control how the end tags for the selected tag are formatted:

    • Has end tag - This option tells SlickEdit Core whether or not the specified tag is intended to be closed with an end tag. This information is used for SlickEdit Core to know when to start or stop calculating information based on the tag. For example, the <div> tag in HTML has a start and end tag, while the <br> tag does not have an end tag.

    • Insert end tags on '>' - When selected, SlickEdit Core automatically inserts the end tag after you type the closing brace (>) of the start tag. For example, when you type <div>, </div> is automatically inserted. The placement of the inserted tag depends on other settings you have specified, such as whether or not the end tag should be on a separate line (specified on the Tag Layout tab).

  • Match tag style of - Select this option if you want the selected tag's settings to match the style of another tag, then pick the tag to use from the drop-down list. This can be a time-saver when adding a batch of new tags that should all have the same settings.

  • Scheme uses case-sensitive tag search - When this option is selected, tags in the Tags column are displayed in the list exactly as you have typed them, with the case preserved. When you type the tags in the editor, the case must match exactly or the tag will not be recognized (and the (default) tag settings will be applied). This option is appropriate for XML. HTML is not case-sensitive.

Content Wrap Settings

The Content Wrap tab of the XML/HTML Formatting dialog contains options for specifying how wrapping should occur for the selected tag's content.

There are three main (mutually-exclusive) options:

  • Wrap tag content - When selected, content between tags is wrapped according to the settings specified in the Tag content width group box. See Tag Content Width Settings below for details.

  • Treat as content - When selected, the tag as well as its content is wrapped according to the parent tag content. The tag is treated as "inline" with the surrounding text. This could be useful for style tags such as <b> or <i> that you want to appear "inline" with the content. For example:

    <div>
        This is a sample paragraph with the <b>bold tags</b> being treated as 
        content, "inline" with the rest of the text.
    </div>
  • Preserve content - When selected, content between start and end tags is not wrapped, but the tags are laid out properly with the parent tag. This could be useful for tags such as <pre>, where the content needs to be rendered exactly as it appears in the code.

Note

  • When Treat as content is selected, the wrapping options in the Tag content width group box, as well as options on the Tag Layout tab, are unavailable.

  • When Preserve content is selected, the wrapping options in the Tag content width group box are unavailable.

Tag Content Width Settings

When Wrap tag content is selected, content between tags is wrapped according to the settings specified in this group box. The options Fixed width, Automatic width, and Fixed right margin are mutually exclusive.

  • Fixed width - When selected, tag content is formatted to the specified width. The original left margin of the content is maintained, and the right margin is adjusted to meet the target width.

    If Maximum right column is used, lines will be wrapped when they reach the specified column, even if they have not reached the specified fixed width. This is useful if coding standards mandate that text should not exceed a specified column.

  • Automatic width - When selected, the width of the longest multi-line paragraph in the tag's content is used as the width. This is useful for preserving the formatting of existing content.

    If Maximum right column is used, lines will be wrapped when they reach the specified column, even if they have not reached the specified automatic width. This is useful if coding standards mandate that text should not exceed a specified column.

  • Fixed right margin - When selected, lines will break before the specified number of columns in the Right column field has been reached.

Tip

If coding standards mandate that text should not exceed a specified column, you can still use Fixed or Automatic width settings. Select and set the Maximum right column, and lines will be wrapped when they reach the specified column, even if they have not reached the specified fixed or automatic width.

  • Parent tag right margin - When selected, tag content is wrapped at the right margin to the width of the parent tag.

  • Include tags in width calculation - When selected, the start and end tag characters are counted in addition to the content. The number of characters and spaces (including attributes) within tags are calculated, and the specified width is adjusted accordingly. This is useful for producing uniform blocks of text.

  • Preserve width of existing content - When selected, SlickEdit Core preserves the width of the existing content while editing. The width is determined by the length of the longest multi-line paragraph. If the width of the existing content cannot be determined, the formatting option specified (Fixed, Automatic, or Fixed right) will be used instead.

Tag Layout Settings

The Tag Layout tab of the XML/HTML Formatting dialog contains options to control the location of the start tag, end tag, and the content between them.

  • Start tag on separate line - When selected, the start tag occurs on a separate line, and the cursor will be placed on the line below for you to type the content. Note the cursor location (|) in the examples below.

  • End tag on separate line e - When selected, the end tag placed on a separate line below the content.

    Example of both settings checked:

    <div>
         |
    </div>

    Example of both settings unchecked:

    <div>|</div>

    Example of start checked and end unchecked:

    <div>
        |</div> 

Note

Dynamic Surround is triggered when you type a tag that has both options StartandEnd tag on separate line checked. Note that Dynamic Surround cannot wrap content and only indents to match your indent style setting (Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Indent). See Syntax Indent for more information about indent styles.

  • Content indent - These mutually exclusive options control how content between tags is indented:

    • Match extension indent style - When selected, tag content is indented according to your indent style setting (Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Indent). See Syntax Indent for more information about indent styles.

    • Indent - When selected, indenting for the tag occurs at the column number specified in the spin box. When Indent after start tag '>' is selected, indenting is relative to the close bracket. Otherwise indenting is relative to the open bracket.

  • Nested tag indent - Indenting is activated after the end tag is typed (or automatically inserted if Insert end tags on '>' is checked on the General tab). These mutually exclusive settings apply to all tags in the selected scheme:

    • Match extension indent style - When selected, SlickEdit Core indents the selected tag according to your indent style setting (Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → Indent). See Syntax Indent for more information about indent styles.

    • Match content indent - When selected, SlickEdit Core indents the selected tag to the same level as its parent content.

  • Insert line breaks - The values for Before start tag and After end tag specify the number of line breaks that are inserted before and after start and end tags. Note that in order to insert one or more blank lines, the values should be set to 2 or higher.