Editing in CodeMix
The CodeMix Editor has a number of features that improve the coding experience, including formatting and code folding. You can set preferences for these features, along with IntelliSense and Navigation, for a workflow that best meets your needs.
The CodeMix plugin is compatible with Eclipse-based IDEs and tools—like MyEclipse, Spring Tools Suite, and JBoss Tools—so you can continue working in the environment you are accustomed to.
Setting Editor Preferences
You can customize your experience in CodeMix editors by setting preferences. Most of these preferences are accessed from Window>Preferences>CodeMix>Editors.
Note: Some settings use Eclipse preferences. To select Displayed tab width and Insert space for tabs settings, go to General>Editors>Text Editors. To select auto save settings, go to General>Editors>Autosave.
A formatter allows you to quickly format code to keep it consistent and easy to read. Some CodeMix editors allow you to choose from multiple formatters.
Selecting a Default Formatter
If multiple formatters are available for the code you are formatting, you are prompted to configure a default formatter the first time you format your code. Click Configure, and then select the desired formatter.
You can select the default at any time from the command palette (
Ctrl+Shift+P). Select Format Document With, then select Configure Default Formatter, and then select the preferred formatter.
Setting Formatter Preferences
Formatter preferences can be defined for each language. To set preferences, go to Window>Preferences>CodeMix>Formatter and select the language.
In addition, you can choose whether or not to format files when saved. To select this preference, go to Window>Preferences>CodeMix>Editors>Save Actions.
Using the Formatter
Use the context menu or command palette to automatically format code.
Right-click in the editor and select Format (or press
Ctrl+Shift+F). The file is formatted with the default formatter. If no text is selected, the entire file is formatted. If text is selected, only the selection is formatted.
Ctrl+Shift+P and type Format. Select one of the following options:
- Format (Ctrl+Shift+F)— If no text is selected, the entire file is formatted. If text is selected, only the selection is formatted.
- Format Selection With—Formats only selected code with the Formatter you specify.
- Format Document With—Formats the entire file with the Formatter you specify.
- Format Selection—Formats only selected code with the default Formatter.
- Format Document—Formats the entire file with the default Formatter.
Note: Options may vary depending on the type of file.
Code folding allows you to collapse and expand sections of code in the editor, making it easier to work with large files and focus on relevant code.
Setting the Code Folding Preference
Code folding is enabled by default. To change this preference, go to Preferences>CodeMix> Editors>Folding.
Using Code Folding
A minus icon to the left of the code indicates the start of a section that can be collapsed. Click the icon to hide the block of code. The first line in the block of code remains visible with a plus icon. Click the plus icon to expand the block of code.
Tip: Hover the plus icon to preview collapsed code.
You can also use the following shortcuts with the numeric keypad:
- Collapse All—
- Expand All—
- Collapse current—
Ctrl+-(Ctrl key plus the minus key)
- Expand Current—
Ctrl++(Ctrl key plus the plus key)