Source code formatting

With the source code formatting tool, you can quickly organize and format the code in your documents. In addition, you can define code formatting rules for different languages yourself.

You can run the code formatting tool using the command marked with the icon shown above located in the Tools / Code Formatting and Compression menu, as well as using the button shown above located in the toolbar.

The tool window contains two tabs:

  • Formatting source - allows you to specify where to format the code
  • Formatting options - contains options for formatting the code
You can also use previously created formatting styles by selecting a specific style from the drop-down list when you click the arrow next to the formatting tool icon on the Frequently Used Tools, or by using the Tools / Formatting and Code Compression / Quick Format Current menu. If you select a section of text in a document, only that section will be formatted.

Formatting source


Using the settings of this tab, it is possible to define the scope of the tool - from the currently edited document, to strictly defined types of documents in the selected project, folders, etc. Options are available:

in the active document - operations will be performed on the document currently open in the editor.

in selected text - operations will be performed on the selected text in the document currently open in the editor.

in all open - operations will be performed on all documents currently open in Spider.

in the selected project - operations will be performed on all files of the project selected from the list. You can restrict file types to files with a specific extension:

  • files: - This text box allows you to enter file extensions to narrow down the types of documents to be considered. Extensions should be given in the form e.g. *.php;*.php3;*.php4.

in folders - operations will be performed on all files in folders included in the list. The list of folders can be edited using the buttons on the right.

  • Files with extension - this text field allows you to enter file extensions to narrow down the types of documents to be considered. Extensions should be given in the form e.g. *.php;*.php3;*.php4.
  • including all subfolders - check to extend the operation to files from all subfolders of the selected folder

in files - operations will be performed on all files on the list. The file list can be edited using the buttons on the right.

Create backup copies
Check this if you want selected documents in folders or in the Project to be backed up when they are formatted.

Formatting options

In this tab, you can select the language whose code you want to format, as well as the formatting type of the selected language. You can select more than one language at a time - Spider will automatically recognize and match the formatting to the language!

Spider contains two separate formatting tools - one built directly into the program, and one that uses an external program, Tidy(r)

Use the formatting rules built into the program

The options in this section allow you to select the language you want the code to be formatted in. This is a tool directly built into the program.

To format the code of a language, check the switch next to its name and then select a formatting scheme from the list.

Format HTML
Check this option to format the HTML code. Then select a formatting scheme from the list:

  • Very parsimonious formatting - formats the code in a way that reduces the size of the document as much as possible, but leaves it relatively clear. Code for subordinate elements will be indented with a single space. Unnecessary blank lines will be removed.
  • Parsimonious format ting - formats the code in a clear manner. Subordinate element code will be indented with a single tab. A single line break will be left between some tags, such as between tables. Unnecessary blank lines will be removed.
  • Clean format ting - formats the code in the clearest way possible. Formatting tags. Tags that define the structure of the document, insert images, etc. will be placed on separate lines. Unnecessary empty lines will be removed.
  • Code compression - formats the code as compactly as possible by removing all unnecessary spaces, end-of-line characters, etc. This keeps the HTML code as compact as possible and makes it load faster.
Format CSS
Check this option to format CSS sheets (embedded in documents, or in separate files). Then select a formatting scheme from the list..:
  • Shortest Formatting - formats the CSS code by placing each class on a single line, one directly below the other. Deletes all blank lines.
  • Short Formatting - formats the CSS code by placing each class on a single line, separating each class with one blank line. Deletes all remaining blank lines.
  • Clean formatting - formats CSS code by placing each class element on a single line. The code of the child elements will be indented with one tab. Individual classes will be separated by a single blank line. Any remaining blank lines are removed.

Format JavaScript
Select this option to format the JavaScript code. Use the Formatting Settings command to customize the formatting style for JavaScript.

Format PHP scripts
Check this option to format PHP script code. You can use the Formatting Settings command to customize the formatting style for PHP.

Customizing formatting styles
You can also create your own formatting styles or customize existing ones using the Program Settings - Formatting Source Codewindow options

Only change the case of tags in documents

Select this option if you want the formatter to only change the case of the tags in the documents that will be formatted. Then select the case (lowercase / uppercase).

Use an external W3C Tidy (r) program

Selecting this option allows you to use the Tidy program to format HTML documents that came with Spider. You can use the following formatting styles:

  • Format for code editing - formats the code in a transparent manner, making it easier to edit. The code of the secondary elements will be indented with two spaces, individual tags separated by a blank lines
  • Format for publication - formats the code compactly, removing indentation, unnecessary blank lines, etc.
  • Convert HTML to XHTML - converts HTML code to conform to the XHTML specification
  • Remove Word formatting - removes the usually unnecessary tags, styles, etc. that are inserted into HTML when exporting documents to HTML from MS Word.
  • Remove deprecated formatting - removes tags marked as deprecated in the specification ( deprecated ) from the document, mostly related to text formatting, replacing them with CSS styles.

You can read more about this program on the Tidy(r) website.

Buttons on the right

Format
Use this button to format documents using the selected options.

Settings
Use this button, open the Program Settings / Other Settings / Facilitation(...) / Source Code Formatting window to adjust formatting options. In this window you can also edit and create new code formatting styles

Related topics

To top