Next Previous Table of Contents
An important part of the integrated development environment is the editor. You're using it for:
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.
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.
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 KDevelop Setup, 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.
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 one ore more files 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 Overview ). 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 KAppWizard 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.
The following gives you a general guideline how to locate certain positions within your files for a quicker access.
» How to find a certain line in a file
» How to set a bookmark
Another way to set bookmarks would be to select "Add Bookmark" from the "Bookmarks"-menu. This sets a bookmark to the current line and appends it to the bookmarks-list. The documentation browser also offers setting a bookmark to the current page by a context menu entry "Add Bookmark".
» How to delete bookmarks
The bookmarks are set for each editing window separately- mind that your bookmarks aren't connected to a certain file you set the bookmark for. To delete all bookmarks, select "Delete Bookmarks" from the "Bookmarks"-menu. This deletes the bookmarks for the window actually on top, either the Header window, the C++ window or the browser window.
» How to go to a bookmarked line
Selecting a bookmark for the browser window will open the browser and loads the page.
For using the editor, you should make yourself comfortable with some keyboard shortcuts that make it easier to position the cursor and edit the file. The complete shortcut reference is also listed in section Overview.
one letter to the left Left Arrow one letter to the right Right Arrow one word to the left CTRL+Left Arrow one word to the right CTRL+Right Arrow one line upwards Up Arrow one line downwards Down Arrow to the beginning of the line POS 1 to the end of the line END one page up PageUp one page down PageDown to the beginning of the current file CTRL+PageUp to the end of the current file CTRL+PageDown one letter to the left SHIFT+Left Arrow one letter to the right SHIFT+Right Arrow one word to the left CTRL+SHIFT+Left Arrow one word to the right CTRL+SHIFT+Right Arrow one line upwards CTRL+Up one line downwards CTRL+Down to the beginning of the current line CTRL+POS 1 to the end of the current line CTRL+END one page up SHIFT+PageUp one page down SHIFT+PageDown to the beginning of the current file CTRL+SHIFT+PageUp to the end of the current file CTRL+SHIFT+PageDown en/disable insertmode INS copy selection to the clipboard CTRL+C, CTRL+INS insert text from the clipboard CTRL+V, SHIFT+INS delete current line CTRL+K insert line after current line END, then Enter insert line before current line POS 1, then Enter undo editing step CTRL+Z redo an undo step CTRL+Y tabulator TAB delete letter left of cursor position Backspace delete letter right of cursor position Delete delete selected text Select text, then Backspace
The editor inside KDevelop can be configured towards special editing needs with a global effect on all editing windows. Thereby you can set the color modes, highlighting colors (also configurable in reference to the programming language of the file) and automatic text settings like tab-with and selection modes. The following describes how to set these options by the configuration dialogs provided in the "Options"-menu.
The editor's general settings can be configured with the "Editor" entry in the "Options"-menu. Select the according values and press OK after you finished with your configuration.
this sets the editor to place the cursor below the first literal when a new line is entered.
this option sets the cursor below the first literal of the line above when backspace is pressed.
words are taken into the next line after the column set in "Wrap Words At:"
tabulators in the current text are replaced with tabulators of the "Tab Width:" value
removes trailing spaces
sets the cursor to the end of the last line when backspace enters the beginning of a line
creates a closing bracket in front of the cursor when a bracket (any kind) is opened.
selections made stay marked after setting the cursor to a different place
allows multiple independent selections within the text
allows vertical selections of text
deletes a selection when writing in the selection.
allows only one selection. A selection made gets deselected when another selection is made.
sets the maximum columns that a line can have. The word that contains a letter that reaches over this value will be automatically broken into the next line.
For changing the editor's general appearance, you can define a set of colors that the editor uses by selecting "Editor Colors" from the "Options"-menu. You can configure colors for:
The syntax-highlighting mode of KDevelop's editor can be configured by two dialogs; first you can set default colors for syntax-highlighting by the "Editor Defaults" entry in the "Options"-menu. There, you can set colors and fonts as well as the fontsize for e.g. keywords. Select the default item and set all needed options.
The second configuration dialog is accessed by the "Syntax-Highlighting" entry in the "Options"-menu. This allows you to set the file filters for the programming language, e.g. *.cpp, *.h for C++. Then select the item that you want to configure. If you wish to use the default values you've set in the "Editor Defaults" dialog, select the "default" checkboxes in the Item-style and Item-Font sections. This reads the default settings for the selected item. After pressing OK, your new values will be enabled and used by the editor.
» How to find one or more characters in the actual editing window
To repeat searching for an expression entered in the search dialog, press F3.
As the search function only is referencing searches over a single file that is currently visible, you're limited to this. But often
you want to search for the same expression overall your project. Therefore, KDevelop contains a grep
-dialog, which
lets you search over all files that you specify either by setting the directory to start the search from and/or by mime-type.
Specifying the exact directory and the mime-type will therefore reduce the time that KDevelop needs to read your files and display
the results. To start a search over several files, select "Search in files..." from the "Edit"-menu. The search dialog opens and
lets you enter:
By default, the grep-dialog is set to start at your project directory and works recursively over implementation and header files.
You can even extend your search pattern by using the following options:
For a repeating search, you can also use the available operators:
Backreferences to bracketed subexpressions are also available by the notation \n.
After specifying your search, press "Search". The results are then displayed in the result-window. To jump to a file and line number, select the resultline and press Enter or double click the result. The editor will automatically open the according file and place the cursor to the line of the result. This allows a complete specification for any search action and give out exact results.
KDevelop offers also some more specialized functionality to use grep within the editors and the browser. Select the expression you want to search for in either of the windows and press SHIFT+F2 or select "grep:<your_expression>" from the right button popup menu. This will ask grep to search for the selection in your project directory's files and will show the results immediately. Switching to the result works as described above. From within the editor window, it lasts to place the cursor over a word and start searching; the word under the cursor will be the search pattern.
While working on a project, you often need to have information about the parameters of member functions you want to use- most often you remember the function's name that matches your needs, but the parameters are a very hard thing to keep in mind. Therefore, and for other purposes that may occur, KDevelop contains a search functionality that combines searching expressions that appear in your files with the documentation browser. To make use of this search functionality, you should have set up the documentation browser correctly and created the search database. For invoking a search through the documentation, do the following:
This allows you to easily find the information you need. For using the results, the documentation browser allows marking a selection and copying it to the clipboard. Then return to the file you're editing and select "Paste" from the "Edit"-menu.
For a full description on how to use the Documentation, see Using the Searchindex.
For replacing an expression, select "Search and Replace" from the "Edit"-menu. The "Search and Replace"-dialog lets you specify the expression to be replaced as well as the replacement expression. Then press OK. The first expression which is found will be marked, so you can see where the expression is and in which context. Then you can specify by a dialog if the expression shall be replaced or not. When the search is finished by reaching the end of the current file, you will be asked if you want to start the search again from the beginning. If you're finished, select "Cancel".
As KDevelop is designed to give developers the best access to files and information to reduce development cycles, it also contains a new printing utility which makes use of enscript, a common printing program available for Unix-Systems. Besides, you can also print by directly using lpr (the lineprinter device). As using enscript offers the most options towards printing, you should install it on your system; it is usually shipped with distributions, so you shouldn't have any problem to get it. But before printing, you should have a look at the available configuration dialog to prepare the output according to your needs. The following section describes how to configure KDevelop for printing files.
The printing program can be configured by selecting "Print" from the "File"-menu; on the printing dialog, select the program by the drop-down-menu in the left upper corner. Then press the "Options" button on the right. This opens the configuration for the program. Another way to configure the program is selecting "Printer Configuration..." from the "Options"-menu; then select "enscript".
The file selection dialog is accessed by the "Files" button on the printing dialog. The file selection allows specifying which files to print out by certain criteria:
Print Preview is available for you to control how the output will look like. Therefore, KDevelop uses the program ghostview or kghostview. When the preview-button was pressed on either printing dialog, you will be presented a template output that shows you the effect of the currently set options.
Next Previous Table of Contents