# Chapter 7. Trabajando con el editor

An important part of the integrated development environment is the editor . You're using it for:

- creating, opening and saving source and project files

- editing source and project files

- writing your SGML documentation

- printing your project files

Generally, the editor itself doesn't do much difference in comparison to other editors; especially as it is a build-in version of the popular KWrite, also known as the "Extended Editor". If you're familiar with that, you won't have any problems using it for managing your projects. In addition to normal editors, KDevelop contains a new printing system, that is far more extended for use with sourcecodes- and you can choose between the printing program you want to use.

This section gives you more information about how to handle your project files and to make you more familiar with the editor 's functionality. A lot of Unix-hardliners would prefer using Emacs or XEmacs- they're fine with that. But it isn't necessary for easy programming, and especially for beginners, to work themselves into powerful editors which shall, in the result, only allow you to enter your code.

# 7.1. Managing Project Files

The following sections describe how to create, save, open and close your project files you need to edit- mind that this doesn't include translation files or pixmaps . Those are recognized automatically and the according editing program like KTranslator opens those files for you.

To give you an easy access to your files, KDevelop contains two easy-to-handle tree-views, similar to a filemanager, that recognize if you selected a file, and opens it in the according editor window. The main view contains two windows that are used independently, but connected via the Project Editor, so you can do all menubar actions the same way. The intention behind this is that it allows you to handle two windows at the same time, although only one is visible. The C/C++ window thereby takes another task, which allows you to easily compile your sources one by one, so you can check the implementations without having to run a complete build-process over your project.

This can be done when having the C/C++ window on top. Select "Compile File " from the Build-menu or press the according button in the toolbar. Your file gets saved and compiled, and you can control any errors by the Compiler output in the output window.

Within the IDE you can open as many text files as you like. All opened files are listed in the Window-menu, so you can switch between them by selecting the according filename from the menu. Further, the actual opened file is displayed with its name in the window frame of KDevelop.

## 7.1.1. Creating and Saving Files

To create a new file, choose "New" from the File-menu. This opens the "New File " dialog, where you can specify the filename and type. Additionally, you have to set the destination directory as well if the file is added to the project or not. Finally, you can also use your header template for the project in case you want to add a new sourcefile without generating a new class by the Class-Generator.

After the file has been created, you can edit the new file as usual; if you have to switch between different files, you can always turn back to the file either via the file-trees or by the Window-menu.

For saving any changes, KDevelop offers a whole variety of options. The standard way would be to save the file by selecting "Save" or "Save As" from the File-menu or by the Save-button on the toolbar. For saving all changed files at once, you could as well select "Save all" from the File-menu.

Now, when working on a project, it is very annoying if something critical happens while you have done a lot of changes on your files; sometimes you will bite yourself that you have forgotten to save the changes. KDevelop takes care of this by offering "Autosaving", which is by default enabled and set to save all files in intervals of 5 minutes. To select another saving period or to disable this, see Configuración de KDevelop, where the setup options are described.

Additionally, KDevelop takes care for all changes if you open another project or exit KDevelop. You will be asked for saving the changed files, where you also have the option to specify which one to save and which you want to stay unsaved. Further, when invoking any build-processes, your files get saved automatically, so you won't ever wonder why your application doesn't run the way you expected it to do after your changes to the source files. The only exception is the "Compile File " command, which only saves the currently opened source file visible in the source editor window.

## 7.1.2. Opening and Closing Files

To open a source file, you have a lot of options as well. One way could be, as the standard for editors, to select "Open" from the File-menu. You will be presented an "Open File" dialog, which allows you to choose the file you want to edit. Another, probably more frequently used way is to select the file from the LFV , the Logical File Viewer, or the RFV , the Real File Viewer (see \|\|). The advantage of the file trees is that they provide a quick visual access to your files, especially the LFV , which only displays your project files by their type, collected into folders. You can as well configure the LFV towards sorting your files in another manner by a right mouse click on the tree. Select "New Group" from the popup-menu, and you can configure a new group, or select "Edit Group" to install new file filters by specifying the group's file extensions, separated by commas.

The standard file groups for a project generated by asistente de aplicaciones are the Headers, Sources, GNU and Others. Additionally, after adding a translation file, KDevelop adds a folder "Translations", containing your *.po files.

To close files, select the file to close from the Window-menu, which loads the opened file into the front editor . Then select "Close" from the File-menu. If your file has been changed, you will be asked to save it. When closing a project, all currently opened files will be checked for changes and you will be asked for saving as well.