Creating a new file and inserting text

3.1.1. Creating a New File

To create a new file, choose File ▸ New from the menu bar, or click on the New File button on the main toolbar. A new page will appear in the editor (or a new window if the parent document is windowed). New documents will be named newfile#1, newfile#2, newfile#3 and so on.

Save file

You should save new documents as soon as possible to avoid any data loss in case of a crash.

3.1.2. File Wizard

A wizard can also be used to create a new file. To create a new file, choose File ▸ New ▸ File from the menu bar. This will open the New File dialog. Select the file type. Enter the filename. The suffix will be automatically added. You can add license information (according to your license choice) and a header. In case of a C/C++ header file, you can also add an header template. Click OK to validate the creation.

Figure 3-1New File Wizard

Anjuta occasionally also creates new file windows during some operations. For example, some Subversion operations such as Diff and View Log create new file windows and add the output there. You can save the contents of these windows to real files if you like.

3.1.3. Inserting Macros

You can use macros to quickly edit repetitive sequences of text.

The Macro plugin must be activated.

3.1.3.1. Inserting

Two types of macros are available: Anjuta macros and user macros (displayed as "My macros"). Anjuta macros are not modifiable, but you can define and modify your own user macros.

To insert a macro, move the cursor to the desired place. Select Edit ▸ Macros ▸ Macros.... A dialog window appears. Select the desired macro in the list. The result of the macro expansion is displayed in the window and a summary is shown in the dialog window. Choose Insert. The expanded macro text is inserted at the cursor position.

Another way to insert a macro is to select Edit ▸ Macros ▸ Insert Macro..., then to press the desired macro shortcut.

Figure 3-2Macro

3.1.3.2. Defining Macros

From the Insert Macro window, choose Add or select Edit ▸ Macros ▸ Add Macro... . The Add/Edit window appears. Enter the macro name, choose or define a category and enter a shortcut. Then edit text relative to your macro. The character ' | ' will indicate the cursor position after the macro insertion. Choose OK. The macro is added to the list.

You can also erase a macro by selecting it in the list and choosing Remove. This only works for user macros (My Macros), of course.

Similarly, you can edit and modify a macro by selecting it in the list and choosing Edit.

Figure 3-3Add/Edit Macro

3.1.3.3. Macro Keywords

Macro keywords are available. They can be included in macro definitions. These macro keywords start and finish with the character ' @ '.

Available macro keywords are @DATE_TIME@, @DATE_YMD@, @DATE_Y@, @USER_NAME@, @FILE_NAME@, @FILE_NAME_UP@, @FILE_NAME_UP_PREFIX@, @EMAIL@, @TABSIZE@, @INDENTSIZE@, and @USETABS@.

Figure 3-4Keyword Macro