Editing Files

Anjuta has a number of helpful features which aid in editing and working with source files. The following sections describe how to use some of the interesting features available.

Editor Margins

Editor Margins: Editor margins are the small area on the left of the editor for some special purposes. There are three editor margins available and all of them may not be available when you first start anjuta. They are Line numbers margin, Markers margin and Code fold margin. By default (that is, when you run anjuta for the first time) only the code fold margin witll be visible. The rest could be made visible from View->Editor.

Figure 3. Editor Margins

The Line Numbers Margin is lagest of all the three margins (and slightly darker then rest) and displays the document's line numbers. Line Number Margin could be made visible or invisible by toggling View->Editor->Line Numbers Margin. Single left clicking on this margin will select the whole line (including the last newline, if present). You can set the font properties for line number margin in the preferences.

Markers Margin is the next margin which can be made visible or invisible by selecting View->Editor->Markers Margin. This margin displays graphical icons to mark the give line. The markers which will be displayed in this margin are Bookmark marker (rectangular blue colored icon), Breakpoint marker (circular red colored) and Line indicator (pointed arrow yellow colored). Bookmark marker is used to indicate bookmaked lines which could be toggled from Bookmark->Toggle Bookmark with the cursor placed in that line. The breakpoint marker is used in debugger to mark the line with debugging breakpoints (see debugging section for more details). The line indicator marker is used to indicate a line when we do a jump from another part, for example when navigating the bookmarks and during single stepping in debugger.

Code folding margin is where the folding tree is visisble. Clicking on these folding tree nodes will fold or unfold the code blocks. An underline will also be drawn below the 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.

NoteInvisible margin marker
 

If the marker margin is not visible, the markers will be displayed by changing the background color of the line. For example, if there a breakpoint marker is set in a line and the marker margin is not visible, that line will be displayed with red background. Similarly, for bookmark marker and line indicatior 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 Markers Margins from View->Editor->Markers Margin.

Figure 4. Editor markes when markers margin is invisible

Editor Guides

The editor could be made to make certain document information, which otherwise are normally not visible. Indentation guides, white spaces and line end characters are such information which could be made visible for editing comfort. They could be make visible or invisible by toggling the menu items in View->Editor. Indentation guides are the small dotted lines drawn to connect the matching braces in the source code. When the cursor is over one such maching braces, the dotted indentation guide is highlighted to give a visual region of the indentation.

Figure 5. Editor with guides

Syntax highlighting

Anjuta can highlight many different languages. This is usually done automatically by determining the type of the file from the file extension. If Anjuta cannot determine the type of the file, there will be no syntax highlighting. You can explicitly force a particular highlight style by selecting the style from the menu Format->Force Highlight Style.

Code folding

Source files which have block coding properties (such as C, C++, Pascal, Java etc.), have the advantage of working with code folds. All of the code blocks in the source file can be folded or unfolded by clicking on the fold points in the 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 big source files that run to thousands of lines. Once the folds are closed, the document appears to become smaller, facilitating easy browsing and editing of the file.

Auto-formatting source code

If the current file is a C or C++ source or header file, then it is possible to automatically indent (auto-format) the file. This gives a clean look to the source code, increases legibility, reduces the likelihood of syntax errors, and above all it saves time. This can be performed by clicking on the Auto-format button in the main toolbar or choosing Format->Auto-format on the menubar. Change the style of formatting by customizing the choices in the preferences.

Noteindent
 

You will need to have the indent utility installed in order to use this feature. Read the info page for indent for further details.