Editing Files
Anjuta has a number of features which help you edit and work with source files. The following sections describe how to use some of the interesting features available.
- 3.3.1. Editor Margins
- 3.3.2. Editor Guides
- 3.3.3. Syntax highlighting
- 3.3.4. Code folding
- 3.3.5. Auto-formatting source code
3.3.1. Editor Margins
Editor Margins: Editor margins appear to the left of the editor and are used for some special purposes. There are three editor margins available: the line number margin, the marker margin and the code fold margin. By default (that is, when you run Anjuta for the first time) only the code fold margin will be visible. The rest can be made visible via .
The line number margin is largest of all the three margins (and is slightly darker then rest) and displays a document's line numbers. The line number margin can be shown or hidden by toggling . Left-clicking on this margin will select an entire line (including the trailing newline, if present). You can set font properties for the line number margin in the preferences.
The marker margin can be shown or hidden via . This margin displays graphical icons to mark the given line. The margin may display bookmark markers (blue and rectangular), breakpoint markers (red and circular) and line indicator markers (which look like a yellow pointed arrow). A bookmark marker indicates a bookmarked line, and can be toggled via with the cursor placed on that line. A breakpoint marker is used in the debugger to indicate a debugging breakpoint (see the Debugging section for more details). A line indicator marker is used to indicate the current program position in the debugger.
The code fold margin is where the folding tree is visible. Clicking on folding tree nodes will fold or unfold code blocks. An underline will also be drawn below a folded line to make it more obvious that a block of code has been folded below the line. For more details on code folding, see the section Code Folding below.
If the marker margin is not visible, Anjuta displays markers by changing the background color of a line. For example, if a breakpoint marker is set in a line and the marker margin is not visible, that line will be displayed with a red background. Similarly, for a bookmark marker and a line indicator marker the background color of the line will be sky blue and yellow, respectively. If you do not like this (perhaps due to some contrasting themes), enable the marker margin via .
3.3.2. Editor Guides
The editor can be set to display certain document information which is normally invisible, including indentation guides, white space and line end characters. They can be make visible or invisible by toggling the menu items in . Indentation guides are small dotted lines drawn to connect matching braces in source code. When the cursor is over a matching brace, its dotted indentation guide is highlighted to emphasize the indentation level visually.
3.3.3. Syntax highlighting
Anjuta can highlight the syntax of many different languages. This is usually done automatically by determining the type of a file from its extension. If Anjuta cannot determine the type of a file, there will be no syntax highlighting. You can explicitly force a particular highlight style by selecting the style from the menu .
Anjuta uses a properties file named $prefix/share/anjuta/properties/anjuta.properties, which has the same format as a SciTE properties file but does not use all properties. The style of each element for all languages is defined in a file named $prefix/share/anjuta/properties/styles.properties. It uses some common properties defined by Anjuta in the file $home/.config/anjuta/scintilla/editor-style.properties.
3.3.4. Code folding
Anjuta can display code folds for source files in block-structured languages (such as C, C++, Pascal, and Java). All code blocks in a source file can be folded or unfolded by clicking on the fold points in the code fold margin of the Editor window (usually a +/- symbol or up/down arrow). These fold points automatically appear for source files which use code blocks.
Code folding is especially useful when editing large source files with thousands of lines. Once the folds are closed, a document appears to become smaller, facilitating easy browsing and editing of the file.
Please note that code folding and editor guides are only available in the Scintilla-based editor.
3.3.5. Auto-formatting source code
Anjuta can automatically indent (auto-format) C or C++ source or header files. This gives a clean look to the source code, increases legibility, reduces the likelihood of syntax errors, and above all saves time. To auto-indent the current source file, choose on the menu bar. You can change the style of formatting by customizing the choices in the preferences.



