dwww Home | Show directory contents | Find package

<FILENAME filename="index.html"><html><head><title>KDevelop Handbook</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="description" content="KDevelop is an Integrated Development Environment to be used for a wide variety of programming tasks."><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="next" href="what-is-kdevelop.html" title="Chapter 1. What is KDevelop?"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> <span class="application">KDevelop</span> Handbook</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="what-is-kdevelop.html">Next</a></td></tr></table></div><div id="contentBody"><div lang="en" class="book"><div class="titlepage"><div><div><h1 class="title"><a name="kdevelop"></a><span class="application">KDevelop</span> Handbook</h1></div><div><div class="authorgroup"><p class="author"><span class="firstname">This documentation was converted from the KDE UserBase <a class="ulink" href="https://userbase.kde.org/KDevelop4/Manual" target="_top">KDevelop4/Manual</a> page.</span> <span class="surname"></span> </p></div></div><div>Revision <span class="releaseinfo"><span class="application">KDevelop</span> 4.4 (<span class="orgname">KDE<br></span> 4.9) (<span class="date">2012-08-19</span>)</span></div><div><p><a href="help:/kdoctools5-common/fdl-notice.html">Legal Notice</a></p></div><div><div><div class="abstract"><p><span class="application">KDevelop</span> is an Integrated Development Environment to be used for a wide variety of programming tasks.</p></div></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="chapter"><a href="what-is-kdevelop.html">1. What is <span class="application">KDevelop</span>?</a></span></dt><dt><span class="chapter"><a href="sessions-and-projects--the-basics-of-kdevelop.html">2. Sessions and projects: The basics of <span class="application">KDevelop</span></a></span></dt><dd><dl><dt><span class="sect1"><a href="sessions-and-projects--the-basics-of-kdevelop.html#terminology">Terminology</a></span></dt><dt><span class="sect1"><a href="setting-up-a-session-and-importing-an-existing-project.html">Setting up a session and importing an existing project</a></span></dt><dd><dl><dt><span class="sect2"><a href="setting-up-a-session-and-importing-an-existing-project.html#option-1--importing-a-project-from-a-version-control-system-server">Option 1: Importing a project from a version control system server</a></span></dt><dt><span class="sect2"><a href="setting-up-a-session-and-importing-an-existing-project.html#option-2--importing-a-project-that-is-already-on-your-hard-drive">Option 2: Importing a project that is already on your hard drive</a></span></dt></dl></dd><dt><span class="sect1"><a href="setting-up-an-application-as-a-second-project.html">Setting up an application as a second project</a></span></dt><dt><span class="sect1"><a href="creating-projects-from-scratch.html">Creating projects from scratch</a></span></dt></dl></dd><dt><span class="chapter"><a href="working-with-source-code.html">3. Working with source code</a></span></dt><dd><dl><dt><span class="sect1"><a href="working-with-source-code.html#tools-and-views">Tools and views</a></span></dt><dt><span class="sect1"><a href="exploring-source-code.html">Exploring source code</a></span></dt><dd><dl><dt><span class="sect2"><a href="exploring-source-code.html#local-information">Local information</a></span></dt><dt><span class="sect2"><a href="exploring-source-code.html#file-scope-information">File scope information</a></span></dt><dt><span class="sect2"><a href="exploring-source-code.html#project-and-session-scope-information">Project and session scope information</a></span></dt><dt><span class="sect2"><a href="exploring-source-code.html#rainbow-color-highlighting-explained">Rainbow color highlighting explained</a></span></dt></dl></dd><dt><span class="sect1"><a href="navigating-in-source-code.html">Navigating in source code</a></span></dt><dd><dl><dt><span class="sect2"><a href="navigating-in-source-code.html#local-navigation">Local navigation</a></span></dt><dt><span class="sect2"><a href="navigating-in-source-code.html#file-scope-navigation-and-outline-mode">File scope navigation and outline mode</a></span></dt><dt><span class="sect2"><a href="navigating-in-source-code.html#project-and-session-scope-navigation--semantic-navigation">Project and session scope navigation: Semantic navigation</a></span></dt></dl></dd><dt><span class="sect1"><a href="writing-source-code.html">Writing source code</a></span></dt><dd><dl><dt><span class="sect2"><a href="writing-source-code.html#auto-completion">Auto-completion</a></span></dt><dt><span class="sect2"><a href="writing-source-code.html#adding-new-classes-and-implementing-member-functions">Adding new classes and implementing member functions</a></span></dt><dt><span class="sect2"><a href="writing-source-code.html#documenting-declarations">Documenting declarations</a></span></dt><dt><span class="sect2"><a href="writing-source-code.html#renaming-variables-functions-and-classes">Renaming variables, functions and classes</a></span></dt><dt><span class="sect2"><a href="writing-source-code.html#code-snippets">Code snippets</a></span></dt></dl></dd><dt><span class="sect1"><a href="modes-and-working-sets.html">Modes and working sets</a></span></dt><dt><span class="sect1"><a href="some-useful-keyboard-shortcuts.html">Some useful keyboard shortcuts</a></span></dt></dl></dd><dt><span class="chapter"><a href="code-generation-with-templates.html">4. Code generation with templates</a></span></dt><dd><dl><dt><span class="sect1"><a href="code-generation-with-templates.html#creating-a-new-class">Creating a new class</a></span></dt><dt><span class="sect1"><a href="creating-a-new-unit-test.html">Creating a new unit test</a></span></dt><dt><span class="sect1"><a href="other-files.html">Other files</a></span></dt><dt><span class="sect1"><a href="managing-templates.html">Managing templates</a></span></dt></dl></dd><dt><span class="chapter"><a href="building-compiling-projects-with-custom-makefiles.html">5. Building (compiling) projects with custom Makefiles</a></span></dt><dd><dl><dt><span class="sect1"><a href="building-compiling-projects-with-custom-makefiles.html#building-individual-makefile-targets">Building individual Makefile targets</a></span></dt><dt><span class="sect1"><a href="selecting-a-collection-of-makefile-targets-for-repeated-building.html">Selecting a collection of Makefile targets for repeated building</a></span></dt><dt><span class="sect1"><a href="what-to-do-with-error-messages.html">What to do with error messages</a></span></dt></dl></dd><dt><span class="chapter"><a href="running-programs-in-kdevelop.html">6. Running programs in <span class="application">KDevelop</span></a></span></dt><dd><dl><dt><span class="sect1"><a href="running-programs-in-kdevelop.html#setting-up-launches-in-kdevelop">Setting up launches in <span class="application">KDevelop</span></a></span></dt><dt><span class="sect1"><a href="some-useful-keyboard-shortcuts0.html">Some useful keyboard shortcuts</a></span></dt></dl></dd><dt><span class="chapter"><a href="debugging-programs-in-kdevelop.html">7. Debugging programs in <span class="application">KDevelop</span></a></span></dt><dd><dl><dt><span class="sect1"><a href="debugging-programs-in-kdevelop.html#running-a-program-in-the-debugger">Running a program in the debugger</a></span></dt><dt><span class="sect1"><a href="attaching-the-debugger-to-a-running-process.html">Attaching the debugger to a running process</a></span></dt><dt><span class="sect1"><a href="some-useful-keyboard-shortcuts1.html">Some useful keyboard shortcuts</a></span></dt></dl></dd><dt><span class="chapter"><a href="working-with-version-control-systems.html">8. Working with version control systems</a></span></dt><dt><span class="chapter"><a href="customizing-kdevelop.html">9. Customizing <span class="application">KDevelop</span></a></span></dt><dd><dl><dt><span class="sect1"><a href="customizing-kdevelop.html#customizing-the-editor">Customizing the editor</a></span></dt><dt><span class="sect1"><a href="customizing-code-indentation.html">Customizing code indentation</a></span></dt><dt><span class="sect1"><a href="customizing-keyboard-shortcuts.html">Customizing keyboard shortcuts</a></span></dt><dt><span class="sect1"><a href="customizing-code-auto-completion.html">Customizing code auto-completion</a></span></dt></dl></dd><dt><span class="chapter"><a href="credits.html">10. Credits and License</a></span></dt></dl></div><FILENAME filename="what-is-kdevelop.html"><html><head><title>Chapter 1. What is KDevelop?</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="index.html" title="KDevelop Handbook"><link rel="next" href="sessions-and-projects--the-basics-of-kdevelop.html" title="Chapter 2. Sessions and projects: The basics of KDevelop"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> What is <span class="application">KDevelop</span>?</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="index.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="sessions-and-projects--the-basics-of-kdevelop.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="what-is-kdevelop"></a>Chapter 1. What is <span class="application">KDevelop</span>?</h1></div></div></div><p><a class="ulink" href="https://www.kdevelop.org/" target="_top"><span class="application">KDevelop</span></a> is a modern integrated development environment (IDE) for C++ (and other languages) that is one of many <a class="ulink" href="https://kde.org/applications/" target="_top">KDE applications</a>. As such it runs on <span class="trademark">Linux</span>® (even if you run one of the other desktops, such as GNOME) but it is also available for most other variants of <span class="trademark">UNIX</span>® and for Windows as well.</p><p><span class="application">KDevelop</span> offers all amenities of modern IDEs. For large projects and applications, the most important feature is that <span class="application">KDevelop</span> <span class="emphasis"><em>understands C++</em></span>: it parses the entire source base and remembers which classes have which member functions, where variables are defined, what their types are, and many other things about your code. For example, let's say one of your project's header files declares a class</p><pre class="programlisting">
class Car {
  // ...
  public:
    std::string get_color () const;
};
</pre><p>
</p><p>and later on in your program you have</p><pre class="programlisting">
Car my_ride;
// ...do something with this variable...
std::string color = my_ride.ge
</pre><p>
</p><p>it will have remembered that <code class="varname">my_ride</code> in the last line is a variable of type <code class="varname">Car</code> and offer you to complete <code class="varname">ge</code> as <code class="varname">get_color()</code> since this is the only member function of the <code class="varname">Car</code> class that starts like this. Instead of continuing to type you just hit <span class="keysym">Enter</span> to get the full word; this saves typing, avoids typos, and doesn't require you to remember the exact names of the hundreds or thousands of functions and classes that make up large projects.</p><p>As a second example, assume you have code like this:</p><pre class="programlisting">double foo ()
{
  double var = my_func();
 return var * var;
}
double bar ()
{
  double var = my_func();
  return var * var * var;
}
</pre><p>If you hover the mouse over the symbol <code class="varname">var</code> in function <code class="varname">bar</code> you get the option to see all uses of this symbol. Clicking on it will only show you the uses of this variable in function <code class="varname">bar</code> because <span class="application">KDevelop</span> understands that the variable <code class="varname">var</code> in function <code class="varname">foo</code> has nothing to do with it. Similarly, right clicking on the variable name allows you to rename the variable; doing so will only touch the variable in <code class="varname">bar</code> but not the one with the same name in <code class="varname">foo</code>.</p><p>But <span class="application">KDevelop</span> is not just an intelligent code editor; there are other things <span class="application">KDevelop</span> does well. Obviously, it highlights the source code in different colors; it has a customizable indenter; it has an integrated interface to the GNU debugger <span class="application">gdb</span>; it can show you the documentation for a function if you hover the mouse over a use of this function; it can deal with different kinds of build environments and compilers (<abbr class="abbrev">e.g.</abbr> with <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">make</span></span> and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">cmake</span></span>-based project), and many other neat things that are discussed in this manual.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="index.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="sessions-and-projects--the-basics-of-kdevelop.html">Next</a></td></tr><tr><td class="prevCell"><span class="application">KDevelop</span> Handbook </td><td class="upCell"> </td><td class="nextCell"> Sessions and projects: The basics of <span class="application">KDevelop</span></td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="sessions-and-projects--the-basics-of-kdevelop.html"><html><head><title>Chapter 2. Sessions and projects: The basics of KDevelop</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="what-is-kdevelop.html" title="Chapter 1. What is KDevelop?"><link rel="next" href="setting-up-a-session-and-importing-an-existing-project.html" title="Setting up a session and importing an existing project"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Sessions and projects: The basics of <span class="application">KDevelop</span></div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="what-is-kdevelop.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="setting-up-a-session-and-importing-an-existing-project.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="sessions-and-projects--the-basics-of-kdevelop"></a>Chapter 2. Sessions and projects: The basics of <span class="application">KDevelop</span></h1></div></div></div><p>In this section, we will go over some of the terminology of how <span class="application">KDevelop</span> sees the world and how it structures work. In particular, we introduce the concept of <span class="emphasis"><em>sessions</em></span> and <span class="emphasis"><em>projects</em></span> and explain how you can set up the projects you want to work on in <span class="application">KDevelop</span>.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="terminology"></a>Terminology</h2></div></div></div><p><span class="application">KDevelop</span> has the concept of <span class="emphasis"><em>sessions</em></span> and <span class="emphasis"><em>projects</em></span>. A session contains all projects that have something to do with each other. For the examples that follow, assume you are the developer of both a library and an application that uses it. You can think of the core KDE libraries as the former and <span class="application">KDevelop</span> as the latter. Another example: Let's say you are a <span class="trademark">Linux</span>® kernel hacker but you are also working on a device driver for <span class="trademark">Linux</span>® that hasn't been merged into the kernel tree yet.</p><p>So taking the latter as an example, you would have a session in <span class="application">KDevelop</span> that has two projects: the <span class="trademark">Linux</span>® kernel and the device driver. You will want to group them into a single session (rather than having two sessions with a single project each) because it will be useful to be able to see the kernel functions and data structures in <span class="application">KDevelop</span> whenever you write source code for the driver — for example so that you can get kernel function and variable names auto-expanded, or so that you can see kernel function documentation while hacking on the device driver.</p><p>Now imagine you also happen to be a KDE developer. Then you would have a second session that contains KDE as a project. You could in principle have just one session for all of this, but there is no real reason for this: in your KDE work, you don't need to access kernel or device driver functions; and you don't want KDE class names autoexpanded while working on the <span class="trademark">Linux</span>® kernel. Finally, building some of the KDE libraries is independent of re-compiling the <span class="trademark">Linux</span>® kernel (whereas whenever you compile the device driver it would also be good to re-compile the <span class="trademark">Linux</span>® kernel if some of the kernel header files have changed).</p><p>Finally, another use for sessions is if you work both on the current development version of a project, as well as on a branch: in that case, you don't want <span class="application">KDevelop</span> to confuse classes that belong to mainline and the branch, so you'd have two sessions, with the same set of projects but from different directories (corresponding to different development branches).</p></div><FILENAME filename="setting-up-a-session-and-importing-an-existing-project.html"><html><head><title>Setting up a session and importing an existing project</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="sessions-and-projects--the-basics-of-kdevelop.html" title="Chapter 2. Sessions and projects: The basics of KDevelop"><link rel="prev" href="sessions-and-projects--the-basics-of-kdevelop.html" title="Chapter 2. Sessions and projects: The basics of KDevelop"><link rel="next" href="setting-up-an-application-as-a-second-project.html" title="Setting up an application as a second project"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Setting up a session and importing an existing project</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="sessions-and-projects--the-basics-of-kdevelop.html">Prev</a></td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="setting-up-an-application-as-a-second-project.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="setting-up-a-session-and-importing-an-existing-project"></a>Setting up a session and importing an existing project</h2></div></div></div><p>Let's stick with the <span class="trademark">Linux</span>® kernel and device driver example — you may want to substitute your own set of libraries or projects for these two examples. To create a new session that contains these two projects go to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Session</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Start new session</span></span> menu at the top left (or, if this is the first time you use <span class="application">KDevelop</span>: simply use the default session you get on first use, which is empty).</p><p>We next want to populate this session with projects that for the moment we assume already exist somewhere (the case of starting projects from scratch is discussed elsewhere in this manual). For this, there are essentially two methods, depending on whether the project already is somewhere on your hard drive or whether it needs to be downloaded from a server.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="option-1--importing-a-project-from-a-version-control-system-server"></a>Option 1: Importing a project from a version control system server</h3></div></div></div><p>Let's first assume that the project we want to set up — the <span class="trademark">Linux</span>® kernel — resides in some version control system on a server, but that you haven't checked it out to your local hard drive yet. In this case, go to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Project</span></span> menu to create the <span class="trademark">Linux</span>® kernel as a project inside the current session and then follow these steps:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Go to <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Project</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Fetch Project</span></span> to import a project
</p></li><li class="listitem"><p>You then have multiple options to start a new project in the current session, depending on where the source files should come from: You can just point <span class="application">KDevelop</span> at an existing directory (see option 2 below), or you can ask <span class="application">KDevelop</span> to get the sources from a repository.
</p></li><li class="listitem"><p>Assuming you don't already have a version checked out:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>In the dialog box, under <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Select Source</span></span>, choose to use <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">From File System</span></span>, <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Subversion</span></span>, <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Git</span></span>, <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">GitHub</span></span>, or <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">KDE</span></span>
</p></li><li class="listitem"><p>Choose a working directory as destination into which the sources should be checked out
</p></li><li class="listitem"><p>Choose an URL for the location of the repository where the source files can be obtained
</p></li><li class="listitem"><p>Hit <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Get</span></span>. This can take quite a long while; depending on the speed of your connection and the size of the project. Unfortunately, in <span class="application">KDevelop</span> 4.2.x the progress bar does not actually show anything, but you can track progress by periodically looking at the output of the command line command </p><pre class="screen">du -sk <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="replaceable"><em class="replaceable"><code>/path/to/<span class="application">KDevelop</span>/project</code></em></span></pre><p> to see how much data has already been downloaded.
</p></li></ul></div><p>
</p></li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The problem with the progress bar has been reported as <a class="ulink" href="https://bugs.kde.org/show_bug.cgi?id=256832" target="_top"><span class="application">KDevelop</span> bug 256832</a>.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>In this process, I also get the error message <span class="emphasis"><em>You need to specify a valid location for the project</em></span> which can be safely ignored.</p></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>It asks you to select a <span class="application">KDevelop</span> project file in this directory. Since you probably don't have one yet, simply hit <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span>
</p></li><li class="listitem"><p>Hit <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span> again
</p></li><li class="listitem"><p><span class="application">KDevelop</span> will then ask you to choose a project manager. If this project uses standard <span class="trademark">UNIX</span>® make files, choose the custom makefile project manager
</p></li><li class="listitem"><p><span class="application">KDevelop</span> will then start to parse the entire project. Again, it will take quite a while to go through all files and index classes <abbr class="abbrev">etc.</abbr> At the bottom right of the main window, there is a progress bar that shows how long this process has come along. (If you have several processor cores, you can accelerate this process by going to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Configure <span class="application">KDevelop</span></span></span> menu item, then selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Background parser</span></span> on the left, and increasing the number of threads for background parsing on the right.)
</p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="option-2--importing-a-project-that-is-already-on-your-hard-drive"></a>Option 2: Importing a project that is already on your hard drive</h3></div></div></div><p>Alternatively, if the project you want to work with already exists on your hard drive (for example, because you have downloaded it as a tar file from an FTP server, because you already checked out a version of the project from a version control system, or because it is your own project that exists <span class="emphasis"><em>only</em></span> on your own hard drive), then  use <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Projects</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Open/Import project</span></span> and in the dialog box choose the directory in which your project resides.</p></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="sessions-and-projects--the-basics-of-kdevelop.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="setting-up-an-application-as-a-second-project.html">Next</a></td></tr><tr><td class="prevCell">Sessions and projects: The basics of <span class="application">KDevelop</span> </td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"> Setting up an application as a second project</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="setting-up-an-application-as-a-second-project.html"><html><head><title>Setting up an application as a second project</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="sessions-and-projects--the-basics-of-kdevelop.html" title="Chapter 2. Sessions and projects: The basics of KDevelop"><link rel="prev" href="setting-up-a-session-and-importing-an-existing-project.html" title="Setting up a session and importing an existing project"><link rel="next" href="creating-projects-from-scratch.html" title="Creating projects from scratch"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Setting up an application as a second project</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="setting-up-a-session-and-importing-an-existing-project.html">Prev</a></td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="creating-projects-from-scratch.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="setting-up-an-application-as-a-second-project"></a>Setting up an application as a second project</h2></div></div></div><p>The next thing you want to do is set up other projects in the same session. In the example above, you would want to add the device driver as the second project, which you can do using exactly the same steps.</p><p>If you have multiple applications or libraries, simply repeat the steps to add more and more projects to your session.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="setting-up-a-session-and-importing-an-existing-project.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="creating-projects-from-scratch.html">Next</a></td></tr><tr><td class="prevCell">Setting up a session and importing an existing project </td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"> Creating projects from scratch</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="creating-projects-from-scratch.html"><html><head><title>Creating projects from scratch</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="sessions-and-projects--the-basics-of-kdevelop.html" title="Chapter 2. Sessions and projects: The basics of KDevelop"><link rel="prev" href="setting-up-an-application-as-a-second-project.html" title="Setting up an application as a second project"><link rel="next" href="working-with-source-code.html" title="Chapter 3. Working with source code"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Creating projects from scratch</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="setting-up-an-application-as-a-second-project.html">Prev</a></td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="working-with-source-code.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-projects-from-scratch"></a>Creating projects from scratch</h2></div></div></div><p>There is of course also the possibility that you want to start a new project from scratch. This can be done using the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Projects</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">New from Template...</span></span> menu item, which presents you with a template selection dialog. Some project templates are provided with <span class="application">KDevelop</span>, but even more are available by installing the <span class="application">KAppTemplate</span> application. Choose the project type and programming language from the dialog, enter a name and location for you project, and click <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span>.
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-project-dialog.png"></div></div><p>
</p><p>The second page of the dialog allows you to set up a version control system. Choose the system you wish the use, and fill in the system-specific configuration if needed. If you do not wish to use a version control system, or want to set it up manually later, choose <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">None</span></span>. When you are happy with your choice,  press <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Finish</span></span>.
</p><p>Your project is now created, so you can try building or installing it. Some templates will include comments within the code, or even a separate README file, and it is recommended that you read those first. Then, you can start working on your project, by adding whatever features you want.
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="setting-up-an-application-as-a-second-project.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="working-with-source-code.html">Next</a></td></tr><tr><td class="prevCell">Setting up an application as a second project </td><td class="upCell">Sessions and projects: The basics of <span class="application">KDevelop</span></td><td class="nextCell"> Working with source code</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="what-is-kdevelop.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="setting-up-a-session-and-importing-an-existing-project.html">Next</a></td></tr><tr><td class="prevCell">What is <span class="application">KDevelop</span>? </td><td class="upCell"> </td><td class="nextCell"> Setting up a session and importing an existing project</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="working-with-source-code.html"><html><head><title>Chapter 3. Working with source code</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="creating-projects-from-scratch.html" title="Creating projects from scratch"><link rel="next" href="exploring-source-code.html" title="Exploring source code"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Working with source code</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="creating-projects-from-scratch.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="exploring-source-code.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="working-with-source-code"></a>Chapter 3. Working with source code</h1></div></div></div><p>Besides debugging, reading through and writing source code is what you will spend the most time with when developing software. To this end, <span class="application">KDevelop</span> offers you many many different ways to explore source codes and to make writing it more productive. As discussed in more detail in the following sections, <span class="application">KDevelop</span> is not just a source editor — rather, it is a source management system that gives you different views of extracted information on the files that collectively make up your session's source code.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="tools-and-views"></a>Tools and views</h2></div></div></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-7.png"><div class="caption"><p></p></div></div></div><p>In order to work with projects, <span class="application">KDevelop</span> has the concept of <span class="emphasis"><em>tools</em></span>. A tool provides a particular view of the source, or an action that can be taken with it. Tools are represented by buttons around the perimeter of your window (in vertical text along the left and right margins, or horizontally along the bottom margin). If you click on them, they expand to a subwindow — a <span class="emphasis"><em>view</em></span> — within the main window; if you click on the tool button again, the subwindow disappears again.</p><p>To make a subwindow disappear, you can also click at the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">x</span></span> at the top right of the subwindow</p><p>The picture above shows a particular selection of tools, aligned on the left and right margins; in the picture, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Classes</span></span> tool is open on the left and the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Snippets</span></span> tool on the right, along with an editor for a source file in the middle. In practice, most of the time you will probably only have the editor and maybe the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Classes</span></span> or <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool open at the left. Other tool view will likely only be open temporarily as you use the tool, leaving more space for the editor most of the time.</p><p>When you run <span class="application">KDevelop</span> the first time, you should already have the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool button. Click on it: it will open a subwindow that shows the projects you have added to the session at the bottom, and a file system view of the directories of your projects at the top.</p><p>There are many other tools you can use with <span class="application">KDevelop</span>, not all of which are initially present as buttons on the perimeter. To add some, go to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Windows</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Add tool view</span></span> menu entry. Here are some that you will likely find useful:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Classes</span></span>: A complete list of all classes that are defined in one of the projects or your session with all of their member functions and variables. Clicking on any of the members opens a source editor window at the location of the item you clicked on.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Documents</span></span>: Lists some of the more recently visited files, by kind (<abbr class="abbrev">e.g.</abbr> source files, patch files, plain text documents).
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span>: Depending on your cursor position in a file, this tool shows things that are related. For example, if you are on an <code class="varname">#include</code> line, it shows information about the file you are including such as what classes are declared in that file; if you are on an empty line at file scope, it shows the classes and functions declared and defined in the current file (all as links: clicking on them brings you to the point in the file where the declaration or definition actually is); if you are in a function definition, it shows where the declaration is and offers a list of places where the function is used.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">File system</span></span>: Shows you a tree view of the file system.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Documentation</span></span>: Allows you to search for man pages and other help documents.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Snippets</span></span>: This provides sequences of text that one uses over an over and doesn't want to write every time. For example, in the project from which the picture above was created, there is a frequent need to write code like
</p></li></ul></div><pre class="programlisting">for (typename Triangulation&lt; dim&gt;::active_cell_iterator cell
      = triangulation.begin_active();
   cell != triangulation.end();
   ++cell)</pre><p> This is an awkward expression but it will look almost exactly like this every time you need such a loop — which would make it a good candidate for a snippet.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Konsole</span></span>: Opens a command line window inside <span class="application">KDevelop</span>'s main window, for the occasional command you may want to enter (<abbr class="abbrev">e.g.</abbr> to run <code class="varname">./configure</code>).
</p></li></ul></div><p>A complete list of tools and views is given <a class="ulink" href="https://userbase.kde.org/Special:myLanguage/KDevelop4/Manual/Tool%20list" target="_top">here</a>.</p><p>For many programmers, vertical screen space is the most important. To this end, you can arrange your tool views at the left and right margin of the window: to move a tool, click on its symbol with the right mouse button and select a new position for it.</p></div><FILENAME filename="exploring-source-code.html"><html><head><title>Exploring source code</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="prev" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="next" href="navigating-in-source-code.html" title="Navigating in source code"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Exploring source code</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="working-with-source-code.html">Prev</a></td><td class="upCell">Working with source code</td><td class="nextCell"><a accesskey="n" href="navigating-in-source-code.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="exploring-source-code"></a>Exploring source code</h2></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="local-information"></a>Local information</h3></div></div></div><p><span class="application">KDevelop</span> <span class="emphasis"><em>understands</em></span> source code, and as a consequence it is really good at providing you information about variables or functions that may appear in your program. For example, here is a snapshot of working with a piece of code and hovering the mouse over the symbol <code class="varname">cell</code> in line 1316 (if you are working keyboard oriented, you can achieve the same effect by holding down the <span class="keycap"><strong>Alt</strong></span> key for a while):</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-13.png"><div class="caption"><p></p></div></div></div><p><span class="application">KDevelop</span> shows me a tooltip that includes the type of the variable (here: <code class="varname">DoFHandler&lt;dim&gt;active_cell_iterator</code>), where this variable is declared (the <span class="emphasis"><em>container</em></span>, which here is the surrounding function <code class="varname">get_maximal_velocity</code> since it is a local variable), what it is (a variable, not a function, class or namespace) and where it is declared (in line 1314, just a few lines up in the code).</p><p>In the current context, the symbol over which the mouse was hovering has no associated documentation. In this example, had the mouse hovered over the symbol <code class="varname">get_this_mpi_process</code> in line 1318, the outcome would have been this:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-14.png"><div class="caption"><p></p></div></div></div><p>Here, <span class="application">KDevelop</span> has cross-referenced the declaration from an entirely different file (<code class="filename">utilities.h</code>, which in fact even resides in a different project of the same session) together with the doxygen-style comment that accompanies the declaration there.</p><p>What makes these tooltips even more useful is that they are dynamic: I can click on the container to get information about the context in which the variable is declared (<abbr class="abbrev">i.e.</abbr> about the namespace <code class="varname">System</code>, such as where it is declared, defined, used, or what its documentation is) and I can click on the blue links that will reset the cursor position to the location of the declaration of the Symbol (<abbr class="abbrev">e.g.</abbr> in <code class="varname">utilities.h</code>, line 289) or give me a list of places where this symbol is used in the current file or throughout all the projects of the current session. The latter is often useful if you want to explore how, for example, a particular function is used in a large code basis.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The information in a tooltip is fleeting — it depends on you holding the <span class="keycap"><strong>Alt</strong></span> key down or hovering your mouse. If you want a more permanent place for it, open the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool view in one of the sub-windows. For example, here the cursor is on the same function as in the example above, and the tool view on the left presents the same kind of information as in the tooltip before:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-15.png"><div class="caption"><p></p></div></div></div><p>Moving the cursor around on the right changes the information presented on the left. What's more, clicking on the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Lock current view</span></span> button at the top right allows you to lock this information, making it independent of the cursor movement while you explore the information presented there.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This sort of context information is available in many other places in <span class="application">KDevelop</span>, not just in the source editor. For example, holding down the <span class="keycap"><strong>Alt</strong></span> key in a completion list (<abbr class="abbrev">e.g.</abbr> when doing a quick-open) also yields context information about the current symbol.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="file-scope-information"></a>File scope information</h3></div></div></div><p>The next level up is to obtain information about the entire source file you are currently working on. To this end, position the cursor at file scope in the current file and look at the what the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool view shows:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-16.png"><div class="caption"><p></p></div></div></div><p>Here, it shows a list of namespaces, classes and functions declared or defined in the current file, giving you an overview of what's happening in this file and a means to jump directly to any of these declarations or definitions without scrolling up and down in the file or searching for a particular symbol.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The information shown for file scope is the same as presented in the <span class="quote">“<span class="quote">Outline</span>”</span> mode discussed below for navigating source code; the difference is that outline mode is only a temporary tooltip.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="project-and-session-scope-information"></a>Project and session scope information</h3></div></div></div><p>There are many ways to obtain information about an entire project (or, in fact, about all projects in a session). This sort of information is typically provided through various tool views. For example, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Classes</span></span> tool view provides a tree structure of all classes and surrounding namespaces for all projects in a session, together with the member functions and variables of each of these classes:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-17.png"><div class="caption"><p></p></div></div></div><p>Hovering over an entry provides again information about the symbol, its location of declaration and definition, and its uses. Double-clicking on an entry in this tree view opens an editor window at the location where the symbol is declared or defined.</p><p>But there are other ways of looking at global information. For example, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Documents</span></span> tool provides a view of a project in terms of the kinds of files or other documents this project is comprised of:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-18.png"><div class="caption"><p></p></div></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="rainbow-color-highlighting-explained"></a>Rainbow color highlighting explained</h3></div></div></div><p><span class="application">KDevelop</span> uses a variety of colors to highlight different objects in source code. If you know what the different colors mean, you can very quickly extract a lot of information from source code just by looking at the colors, without reading a single character. The highlighting rules are as follows:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Objects of type Class / Struct, Enum (the values and the type), (global) functions, and class members each have their own color assigned (classes are green, enums are dark red, and members are dark yellow or violet, (global) functions are always violet).</p></li><li class="listitem"><p>All global variables are colored in dark green.</p></li><li class="listitem"><p>Identifiers which are typedefs for another type are colored in teal.</p></li><li class="listitem"><p>All declarations and definitions of objects are in bold.</p></li><li class="listitem"><p>If a member is accessed from within the context where it is defined (base or derived class) it appears in yellow, otherwise it appears in violet.</p></li><li class="listitem"><p>If a member is private or protected, it gets colored in a slightly darker color when used.</p></li><li class="listitem"><p>For variables local to a function body scope, rainbow colors are picked based on a hash of the identifier. This includes the parameters to the function. An identifier always will have the same color within its scope (but the same identifier will get a different color if it represents a different object, <abbr class="abbrev">i.e.</abbr> if it is redefined in a more nested scope), and you will usually get the same color for the same identifier name in different scopes. Thus, if you have multiple functions taking parameters with the same names, the arguments will all look the same color-wise. These rainbow colors can be turned off separately from the global coloring in the settings dialog.</p></li><li class="listitem"><p>Identifiers for which <span class="application">KDevelop</span> could not determine the corresponding declaration are colored in white. This can sometimes be caused by missing <code class="varname">#include</code> directives.</p></li><li class="listitem"><p>In addition to that coloring, the normal editor syntax highlighting will be applied, as known from <span class="application">Kate</span>. <span class="application">KDevelop</span>'s semantic highlighting will always override the editor highlighting if there is a conflict.</p></li></ul></div></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="working-with-source-code.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="navigating-in-source-code.html">Next</a></td></tr><tr><td class="prevCell">Working with source code </td><td class="upCell">Working with source code</td><td class="nextCell"> Navigating in source code</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="navigating-in-source-code.html"><html><head><title>Navigating in source code</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="prev" href="exploring-source-code.html" title="Exploring source code"><link rel="next" href="writing-source-code.html" title="Writing source code"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Navigating in source code</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="exploring-source-code.html">Prev</a></td><td class="upCell">Working with source code</td><td class="nextCell"><a accesskey="n" href="writing-source-code.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="navigating-in-source-code"></a>Navigating in source code</h2></div></div></div><p>In the previous section, we have discussed exploring source code, <abbr class="abbrev">i.e.</abbr> getting information about symbols, files and projects. The next step is then to jump around your source base, <abbr class="abbrev">i.e.</abbr> to navigate in it. There are again various levels at which this is possible: local, within a file, and within a project.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Many of the ways to navigate through code are accessible from the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Navigate</span></span> menu in the <span class="application">KDevelop</span> main window.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="local-navigation"></a>Local navigation</h3></div></div></div><p><span class="application">KDevelop</span> is much more than an editor, but it is <span class="emphasis"><em>also</em></span> a source editor. As such, you can of course move the cursor up, down, left or right in a source file. You can also use the <span class="keycap"><strong>PageUp</strong></span> and <span class="keycap"><strong>PageDown</strong></span> keys, and all the other commands you are used from any useful editor.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="file-scope-navigation-and-outline-mode"></a>File scope navigation and outline mode</h3></div></div></div><p>At the file scope, <span class="application">KDevelop</span> offers many possible ways to navigate through source code. For example:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Outline</span></span>: You can get an outline of what's in the current file in at least three different ways:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>Clicking into the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Outline</span></span> textbox at the top right of the main window, or hitting <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>N</strong></span> opens a drop-down menu that lists all function and class declarations:
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-19.png"><div class="caption"><p></p></div></div></div><p> You can then just select which one to jump to, or — if there are a lot — start typing any text that may appear in the names shown; in that case, as you keep typing, the list becomes smaller and smaller as names are removed that don't match the text already typed until you are ready to select one of the choices.
</p></li><li class="listitem"><p>Positioning the cursor at file scope (<abbr class="abbrev">i.e.</abbr> outside any function or class declarations or definitions) and having the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool open:
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-16.png"><div class="caption"><p></p></div></div></div><p> This also provides you an outline of what is happening in the current file, and allows you to select where you want to jump to.
</p></li><li class="listitem"><p>Hovering the mouse over the tab for one of the open files also yields an outline of the file in that tab.
</p></li></ul></div><p>
</p></li><li class="listitem"><p>Source files are organized as a list of function declarations or definitions. Hitting <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>PgUp</strong></span> and <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>PgDown</strong></span> jumps to the previous or next function definition in this file.
</p></li></ul></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="project-and-session-scope-navigation--semantic-navigation"></a>Project and session scope navigation: Semantic navigation</h3></div></div></div><p>As mentioned in other places, <span class="application">KDevelop</span> does not usually consider individual source files but rather looks at projects as a whole (or, rather, at all projects that are part of the current session). As a consequence, it offers many possibilities for navigating through entire projects. Some of these are derived from what we have already discussed in the section on <a class="link" href="exploring-source-code.html" title="Exploring source code">Exploring source code</a> while others are genuinely different. The common theme is that these navigation features are based on a <span class="emphasis"><em>semantic understanding</em></span> of the code, <abbr class="abbrev">i.e.</abbr> they offer you something that requires parsing entire projects and connecting data. The following list shows some ways how to navigate through source code that is scattered throughout a potentially very large number of files:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>As seen in the section on <a class="link" href="exploring-source-code.html" title="Exploring source code">Exploring source code</a>, you can get a tooltip explaining individual namespace, class, function or variable names by hovering your mouse over it or keeping the <span class="keycap"><strong>Alt</strong></span> key pressed for a while. Here is an example:
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-14.png"></div></div><p> Clicking on the links for the declaration of a symbol or expanding the list of uses allows you to jump to these locations, if necessary opening the respective file and placing the cursor at the corresponding location. A similar effect can be achieved by using the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool view also discussed previously.
</p></li><li class="listitem"><p>A quicker way to jump to the declaration of a symbol without having to click on the links in the tooltip is to temporary enabling <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Source Browse Mode</span></span> by holding down the <span class="keycap"><strong>Alt</strong></span> or <span class="keycap"><strong>Ctrl</strong></span> key. In this mode, it is possible to directly click on any symbol in the editor to jump to its declaration.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Quick open</span></span>: A very powerful way of jumping to other files or locations is to use the various <span class="emphasis"><em>quick open</em></span> methods in <span class="application">KDevelop</span>. There are four versions of these:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Quick open class</span></span> (<span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigate</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Quick open class</span></span> or <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>C</strong></span>): You will get a list of all classes in this session. Start typing (a part of) the name of a class and the list will continue to whittle down to only those that actually match what you've typed so far. If the list is short enough, select an element using the up and down keys and <span class="application">KDevelop</span> will get you to the place where the class is declared.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Quick open function</span></span> (<span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigate</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Quick open function</span></span> or <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>M</strong></span>): You will get a list of all (member) functions that are part of the projects in the current session, and you can select from it in the same way as above. Note that this list may include both function declarations and definitions.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Quick open file</span></span> (<span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigate</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Quick open file</span></span> or <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>O</strong></span>): You will get a list of all files that are part of the projects in the current session, and you can select from it in the same way as above.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Universal quick open</span></span> (<span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigate</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Quick open</span></span> or <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Q</strong></span>): If you forget which key combination is bound to which of the above commands, this is the universal swiss army knife — it simply presents you with a combined list of all files, functions, classes, and other things from which you can select.
</p></li></ul></div><p>
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Jump to declaration/definition</span></span>:  When implementing a (member) function, one often needs to switch back to the point where a function is declared, for example to keep the list of function arguments synchronised between declaration and definition, or to update the documentation. To do so, place the cursor onto the function name and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Jump to declaration</span></span> (or hit <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>.</strong></span>) to get to the place where the function is declared. There are multiple ways to get back to the original place:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>Selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Jump to definition</span></span> (or hitting <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>,</strong></span>).
</p></li><li class="listitem"><p>Selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Previous visited context</span></span> (or hit <span class="keycap"><strong>Meta</strong></span>+<span class="keycap"><strong>Left</strong></span>), as described below.
</p></li></ul></div><p>
</p></li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Jumping to the declaration of a symbol is something that does not only work when placing the cursor on the name of the function you are currently implementing. Rather, it also works for other symbols: Putting the cursor on a (local, global, or member) variable and jumping to its declaration also transports you to its location of declaration. Similarly, you can place the cursor on the name of a class, for example in a variable of function declaration, and jump to the location of its declaration.</p></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Switch between declaration/definition</span></span>: In the example above, to jump to the site of the declaration of the current function, you need to first place the cursor on the function name. To avoid this step, you can select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Switch definition/declaration</span></span> (or hit <span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>C</strong></span>) to jump to the declaration of the function within which the cursor currently is. Selecting the same menu entry a second time transports you back to the place where the function is defined.
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Previous/Next use</span></span>: Placing the cursor on the name of a local variable and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Next use</span></span> (or hitting <span class="keycap"><strong>Meta</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>Right</strong></span>) transports you to the next use of this variable in the code. (Note that this doesn't just search for the next occurrence of the variable name but in fact takes into account that variables with the same name but in different scopes are different.) The same works for the use of function names. Selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Previous use</span></span> (or hitting <span class="keycap"><strong>Meta</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>Left</strong></span>) transports you to the previous use of a symbol.
</p></li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>To see the list of all uses of a name through which these commands cycle, place the cursor onto it and open the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool view or press and hold the <span class="keycap"><strong>Alt</strong></span> button. This is explained in more detail in the section on <a class="link" href="exploring-source-code.html#file-scope-information" title="File scope information">Exploring code</a>.</p></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">context list</span></span>: Web browsers have this feature where you can go backward and forward in the list of most recently visited web pages. <span class="application">KDevelop</span> has the same kind of features, except that instead of web pages you visit <span class="emphasis"><em>contexts</em></span>. A context is the current location of the cursor, and you change it by navigating away from it using anything but cursor commands — for example, by clicking on a location provided by a tooltip, in the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code Browser</span></span> tool view, one of the options given in the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Navigation</span></span> menu, or any other navigation command. Using the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Previous Visited Context</span></span> (<span class="keycap"><strong>Meta</strong></span>+<span class="keycap"><strong>Left</strong></span>) and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Navigation</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Next Visited Context</span></span> (<span class="keycap"><strong>Meta</strong></span>+<span class="keycap"><strong>Right</strong></span>) transports you along this 
list of visited contexts just like the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">back</span></span> and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">forward</span></span> buttons of a browser transports you to the previous or next webpage in the list of visited pages.
</p></li><li class="listitem"><p>Finally, there are tool views that allow you to navigate to different places in your code base. For example, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Classes</span></span> tool provides you with a list of all namespaces and classes in all projects of the current session, and allows you to expand it to see member functions and variables of each of these classes:
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-17.png"><div class="caption"><p></p></div></div></div><p> Double-clicking on an item (or going through the context menu using the right mouse button) allows you to jump to the location of the declaration of the item. Other tools allow similar things; for example, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool view provides a list of files that are part of a session:
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-13.png"><div class="caption"><p></p></div></div></div><p> Again, double-clicking on a file opens it.
</p></li></ul></div></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="exploring-source-code.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="writing-source-code.html">Next</a></td></tr><tr><td class="prevCell">Exploring source code </td><td class="upCell">Working with source code</td><td class="nextCell"> Writing source code</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="writing-source-code.html"><html><head><title>Writing source code</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="prev" href="navigating-in-source-code.html" title="Navigating in source code"><link rel="next" href="modes-and-working-sets.html" title="Modes and working sets"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Writing source code</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="navigating-in-source-code.html">Prev</a></td><td class="upCell">Working with source code</td><td class="nextCell"><a accesskey="n" href="modes-and-working-sets.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="writing-source-code"></a>Writing source code</h2></div></div></div><p>Because <span class="application">KDevelop</span> understands your projects' source code, it can assist in writing more code. The following outlines some of the ways in which it does that.</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="auto-completion"></a>Auto-completion</h3></div></div></div><p>Probably the most useful of all features in writing new code is auto-completion. Consider, for example, the following piece of code:</p><pre class="programlisting">class Car {
  // ...
  public:
    std::string get_color () const;
};
void foo()
{
  Car my_ride;
  // ...do something with this variable...
  std::string color = my_ride.ge
</pre><p>In the last line, <span class="application">KDevelop</span> will remember that the variable <code class="varname">my_ride</code> is of type <code class="varname">Car</code>, and will automatically offer to complete the name of the member function <code class="varname">ge</code> as <code class="varname">get_color</code>. In fact, all you have to do is to keep typing until the auto-completion feature has reduced the number of matches to one, and then hit the <span class="keysym">Enter</span> key:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-42.png"><div class="caption"><p></p></div></div></div><p>Note that you can click on the tool-tip to get more information about the function apart from its return type and whether it is public:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-43.png"><div class="caption"><p></p></div></div></div><p>Auto-completion can save you a lot of typing if your project uses long variable and function names; furthermore, it avoids mis-spelling names (and the resulting compiler errors) and it makes it much simpler to remember the exact names of functions; for example, if all of your getters start with <code class="varname">get_</code>, then the auto-completion feature will be able to only present you a list of possible getters when you have typed the first four letters, likely reminding you in the process which of the functions is the correct one. Note that for auto-completion to work, neither the declaration of the <code class="varname">Car</code> class nor of the <code class="varname">my_ride</code> variable need to be in the same file as where you are currently writing code. <span class="application">KDevelop</span> simply has to know that these classes and variables are connected, <abbr class="abbrev">i.e.</abbr> the files in which these connections are made need to be part of the project you are currently working on.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p><span class="application">KDevelop</span> doesn't always know when to assist you in completing code. If the auto-completion tooltip doesn't automatically open, hit <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Space</strong></span> to open a list of completions manually. In general, in order for auto-completion to work, <span class="application">KDevelop</span> needs to parse your source files. This happens in the background for all files that are part of the projects of the current session after you start <span class="application">KDevelop</span>, as well as while after you stop typing for a fraction of a second (the delay can be configured).</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p><span class="application">KDevelop</span> only parses files that it considers source code, as determined by the MIME-type of the file. This type isn't set before the first time a file is saved; consequently, creating a new file and starting to write code in it will not trigger parsing for auto-completion until after it is saved for the first time.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>As in the previous note, for auto-completion to work, <span class="application">KDevelop</span> must be able to find declarations in header files. For this, it searches in a number of default paths. If it doesn't automatically find a header file, it will underline the name of a header file in red; in that case, right click on it to tell <span class="application">KDevelop</span> explicitly where to find these files and the information they provide.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Configuring auto-completion is discussed in <a class="link" href="customizing-code-auto-completion.html" title="Customizing code auto-completion">this section of this manual</a>.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="adding-new-classes-and-implementing-member-functions"></a>Adding new classes and implementing member functions</h3></div></div></div><p><span class="application">KDevelop</span> has an assistant for adding new classes. The procedure is described in <a class="link" href="code-generation-with-templates.html#creating-a-new-class" title="Creating a new class">Creating a new class</a>.  A simple C++ class can be created by choosing the Basic C++ template from the <code class="filename">Class</code> category. In the assistant, we can choose some predefined member functions, for example an empty constructor, a copy constructor and a destructor.
</p><p>After completing the assistant, the new files are created and opened in the editor. The header file already has include guards and the new class has all the member functions we selected. The next two steps would be to document the class and its member functions and to implement them. We will discuss aids for documenting classes and functions below. To implement the special functions already added, simply go to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">bus.cpp</span></span> tab where the skeleton of functions are already provided:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-30.png"><div class="caption"><p></p></div></div></div><p>To add new member functions, go back to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">bus.h</span></span> tab and add the name of a function. For example, let us add this:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-31.png"><div class="caption"><p></p></div></div></div><p>Note how I have already started with the implementation. However, in many coding styles, the function shouldn't be implemented in the header file but rather in the corresponding .cpp file. To this end, locate the cursor on the name of the function and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Code</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Move to source</span></span> or hit <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>S</strong></span>. This remove the code between curly braces from the header file (and replaces it by a semicolon as necessary to terminate the function declaration) and moves it into the source file:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-32.png"><div class="caption"><p></p></div></div></div><p>Note how I have just started typing and that I meant to imply that the <code class="varname">students</code> variable should probably be a member variable of class <code class="varname">Bus</code> but that I haven't yet added it. Note also how <span class="application">KDevelop</span> underlines it to make clear that it doesn't know anything about the variable. But this problem can be solved: Clicking on the variable name yields the following tooltip:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-33.png"><div class="caption"><p></p></div></div></div><p>(The same can be achieved by right clicking on it and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Solve: Declare As</span></span>.) Let me select <span class="quote">“<span class="quote">3 - private unsigned int</span>”</span> (either by mouse, or by hitting <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>3</strong></span>) and then see how it comes out in the header file:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-34.png"><div class="caption"><p></p></div></div></div><p>It is worth noting that <span class="application">KDevelop</span> extracts the type of the variable to be declared from the expression used to initialize it. For example, if we had written the addition in the following rather dubious way, it would had suggested to declare the variable as type <code class="varname">double</code>:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-35.png"><div class="caption"><p></p></div></div></div><p>As a final point: The method using <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Code</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Move to source</span></span>  does not always insert the new member function where you may want it. For example, you may want it to be marked as <code class="varname">inline</code> and place it at the bottom of the header file. In a case like this, write the declaration and the start writing the definition of the function like this:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-36.png"><div class="caption"><p></p></div></div></div><p><span class="application">KDevelop</span> automatically offers all possible completions of what might come here. Selecting one of the two <code class="varname">add_students</code> entries yields the following code that already fills in the complete argument list:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-37.png"><div class="caption"><p></p></div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>In the example, accepting one of the choices the auto-completion tool offers yields the correct signature but unfortunately deletes the <code class="varname">inline</code> marker already written. This has been reported as <a class="ulink" href="https://bugs.kde.org/show_bug.cgi?id=274245" target="_top"><span class="application">KDevelop</span> Bug 274245</a>.</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="documenting-declarations"></a>Documenting declarations</h3></div></div></div><p>Good code is well documented, both at the level of the implementation of algorithms within in functions as well as at the level of the interface — <abbr class="abbrev">i.e.</abbr>, classes, (member and global) functions, and (member or global) variables need to be documented to explain their intent, possible values of arguments, pre- and postconditions, <abbr class="abbrev">etc.</abbr> As far as documenting the interface is concerned, <a class="ulink" href="http://www.doxygen.org" target="_top">doxygen</a> has become the de facto standard for formatting comments that can then be extracted and displayed on searchable webpages.</p><p><span class="application">KDevelop</span> supports this style of comments by providing a short cut to generate the framework of comments that document a class or member function. For example, assume you have already written this code:</p><pre class="programlisting">
class Car {
  public:
    std::string get_color () const;
};
</pre><p>
</p><p>You now want to add documentation to both the class and the member function. To this end, move the cursor onto the first line and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Code</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Document Declaration</span></span> or hit <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>D</strong></span>. <span class="application">KDevelop</span> will respond with the following:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-23.png"><div class="caption"><p></p></div></div></div><p>The cursor is already in the grayed out area for you to fill in the short description (after the doxygen keyword <code class="varname">@brief</code>) of this class. You can then continue to add documentation to this comment that gives a more detailed overview of what the class does:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-24.png"><div class="caption"><p></p></div></div></div><p>While the editor is inside the comment, the comment text is highlighted in green (the highlighting disappears once you move the cursor out of the comment). When you get to the end of a line, hit <span class="keysym">Enter</span> and <span class="application">KDevelop</span> will automatically start a new line that starts with an asterisk and place the cursor one character indented.</p><p>Now let's document the member function, again by putting the cursor on the line of the declaration and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Code</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Document Declaration</span></span> or hitting <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>D</strong></span>:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-25.png"><div class="caption"><p></p></div></div></div><p>Again, <span class="application">KDevelop</span> automatically generates the skeleton of a comment, including documentation for the function itself, as well as its return type. In the current case, the name of the function is pretty much self-explanatory, but oftentimes function arguments may not be and should be documented individually. To illustrate this, let's consider a slightly more interesting function and the comment <span class="application">KDevelop</span> automatically generates:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-26.png"><div class="caption"><p></p></div></div></div><p>Here, the suggested comment already contains all the Doxygen fields for the individual parameters, for example.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="renaming-variables-functions-and-classes"></a>Renaming variables, functions and classes</h3></div></div></div><p>Sometimes, one wants to rename a function, class or variable. For example, let's say we already have this:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-38.png"><div class="caption"><p></p></div></div></div><p>We then realize that we're unhappy with the name <code class="varname">remove_students</code> and would have rather called it, say, <code class="varname">throw_out_students</code>. We could do a search-replace for the name, but this has two drawbacks:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>The function may be used in more than one file.
</p></li><li class="listitem"><p>We really only want to rename this function and not touch functions that may have the same name but are declared in other classes or namespaces.
</p></li></ul></div><p>Both these problems can be solved by moving the cursor on any of the occurrences of the name of the function and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Code</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Rename declaration</span></span> (or right clicking on the name and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Rename Bus::remove_students</span></span>). This brings up a dialog box where you can enter the new name of the function and where you can also see all the places where the function is actually used:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-39.png"><div class="caption"><p></p></div></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="code-snippets"></a>Code snippets</h3></div></div></div><p>Most projects have pieces of code that one frequently has to write in source code. Examples are: for compiler writers, a loop over all instructions; for user interface writers, checks that user input is valid and if not to open an error box; in the project of the author of these lines, it would be code of the kind</p><pre class="programlisting">
for (typename Triangulation::active_cell_iterator
       cell = triangulation.begin_active();
     cell != triangulation.end(); ++cell)
  ... do something with the cell ...
</pre><p>
</p><p>Rather than typing this kind of text over and over again (with all the concomitant typos one introduces), the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Snippets</span></span> tool of <span class="application">KDevelop</span> can help here. To this end, open the tool view (see <a class="link" href="working-with-source-code.html#tools-and-views" title="Tools and views">Tools and views</a> if the corresponding button isn't already on the perimeter of your window). Then click on the <span class="quote">“<span class="quote">Add repository</span>”</span> button (a slight misnomer — it allows you to create a named collection of snippets for source codes of a particular kind, <abbr class="abbrev">e.g.</abbr> C++ sources) and create an empty repository. Then click <span class="inlinemediaobject"><img src="Icon-list-add.png"></span> to add a snippet, to get a dialog like the following:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-40.png"><div class="caption"><p></p></div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The name of a snippet may not have spaces or other special characters because it must look like a normal function or variable name (for reasons that will become clear in the next paragraph).</p></div><p>To use a snippet so defined, when you are editing code, you can just type the name of the snippet like you would any other function or variable name. This name will become available for auto-completion — which means that there is no harm in using a long and descriptive name for a snippet such as the one above — and when you accept the suggestion of the auto-completion tooltip (for example by just hitting <span class="keysym">Enter</span>), the already entered part of the snippets' name will be replaced by the full expansion of the snippet and will be properly indented:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-41.png"><div class="caption"><p></p></div></div></div><p>Note that for this to work, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Snippets</span></span> tool view need not be open or visible: you only ever need the tool view to define new snippets. An alternative, if less convenient, way to expand a snippet is to simply click on it in the respective tool view.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Snippets are much more powerful than just explained. For a full description of what you can do with them, see the <a class="ulink" href="https://userbase.kde.org/Special:myLanguage/KDevelop4/Manual/Tool_list/Snippets" target="_top">detailed documentation of the Snippets tool</a>.</p></div></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="navigating-in-source-code.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="modes-and-working-sets.html">Next</a></td></tr><tr><td class="prevCell">Navigating in source code </td><td class="upCell">Working with source code</td><td class="nextCell"> Modes and working sets</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="modes-and-working-sets.html"><html><head><title>Modes and working sets</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="prev" href="writing-source-code.html" title="Writing source code"><link rel="next" href="some-useful-keyboard-shortcuts.html" title="Some useful keyboard shortcuts"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Modes and working sets</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="writing-source-code.html">Prev</a></td><td class="upCell">Working with source code</td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="modes-and-working-sets"></a>Modes and working sets</h2></div></div></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop4_noworkingset.png"><div class="caption"><p></p></div></div></div><p>If you've gotten this far, take a look at the upper right of the <span class="application">KDevelop</span> main window: As shown in the picture, you will see that there are three <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">modes</span></span> <span class="application">KDevelop</span> can be in: <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code</span></span> (the mode we discuss in the current chapter on working with source code), <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Debug</span></span> (see <a class="link" href="debugging-programs-in-kdevelop.html" title="Chapter 7. Debugging programs in KDevelop">Debugging programs</a>) and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Review</span></span> (see <a class="link" href="working-with-version-control-systems.html" title="Chapter 8. Working with version control systems">Working with version control systems</a>).</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop4_sessionsprojectsworkingsets.png"><div class="caption"><p></p></div></div></div><p>Each mode has its own set of tools that are stacked around the perimeter, and each mode also has a <span class="emphasis"><em>working set</em></span> of currently open files and documents. Furthermore, each such working set is associated with a current session, <abbr class="abbrev">i.e.</abbr> we have the relationship shown above. Note that the files in the working set come from the same session, but they may come from different projects that are part of the same session.</p><p>If you open <span class="application">KDevelop</span> the first time, the working set is empty — there are no open files. But as you open files for editing (or debugging, or reviewing in the other modes) your working set grows. The fact that your working set is non-empty is indicated by a symbol in the tab, as shown below. You will notice that whenever you close <span class="application">KDevelop</span> and later start it again, the working set is saved and restored, <abbr class="abbrev">i.e.</abbr> you get the same set of open files.</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-10.png"><div class="caption"><p></p></div></div></div><p>If you hover your mouse over the symbol for the working set, you get a tooltip that shows you which files are currently open in this working set (here: the <code class="varname">step-32.cc</code> and <code class="varname">step-1.cc</code> files). Clicking on the red minus sign closes the tab for the corresponding file. Maybe more importantly, clicking on the correspondingly named button allows you to <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">close</span></span> the entire working set at once (<abbr class="abbrev">i.e.</abbr> to close all currently open files). The point about closing a working set, however, is that it doesn't just close all files, it actually saves the working set and opens a new, still empty one. You can see this here:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-11.png"><div class="caption"><p></p></div></div></div><p>Note the two symbols to the left of the three mode tabs (the heart and the unidentifiable symbol to its left). Each of these two symbols represents a saved working set, in addition to the currently open working set. If you hover your mouse over the heart symbol, you'll get something like this:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-12.png"><div class="caption"><p></p></div></div></div><p>It shows you that the corresponding working set contains two files and their corresponding project names: <code class="varname">Makefile</code> and <code class="varname">changes.h</code>. Clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Load</span></span> will close and save the current working set (which as shown here has the files <code class="varname">tria.h</code> and <code class="varname">tria.cc</code> open) and instead open the selected working set. You can also permanently delete a working set, which removes it from the set of saved working sets.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="writing-source-code.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts.html">Next</a></td></tr><tr><td class="prevCell">Writing source code </td><td class="upCell">Working with source code</td><td class="nextCell"> Some useful keyboard shortcuts</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="some-useful-keyboard-shortcuts.html"><html><head><title>Some useful keyboard shortcuts</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="working-with-source-code.html" title="Chapter 3. Working with source code"><link rel="prev" href="modes-and-working-sets.html" title="Modes and working sets"><link rel="next" href="code-generation-with-templates.html" title="Chapter 4. Code generation with templates"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Some useful keyboard shortcuts</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="modes-and-working-sets.html">Prev</a></td><td class="upCell">Working with source code</td><td class="nextCell"><a accesskey="n" href="code-generation-with-templates.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="some-useful-keyboard-shortcuts"></a>Some useful keyboard shortcuts</h2></div></div></div><p><span class="application">KDevelop</span>'s editor follows the standard keyboard shortcuts for all usual editing operations. However, it also supports a number of more advanced operations when editing source code, some of which are bound to particular key combinations. The following are frequently particularly helpful:</p><p>
</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th colspan="2">Jumping around in code</th></tr></thead><tbody><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>O</strong></span></td><td>Quick open file: enter part of a filename and select among all the files in the current session's projects' directory trees that match the string; the file will then be opened</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>C</strong></span></td><td>Quick open class: enter part of a class name and select among all class names that match; the cursor will then jump to the class declaration</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>M</strong></span></td><td>Quick open function: enter part of a (member) function name and select among all names that match; note that the list shows both declarations and definitions and the cursor will then jump to the selected item</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Q</strong></span></td><td>Universal quick open: type anything (file name, class name, function name) and get a list of anything that matches to select from</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>N</strong></span></td><td>Outline: Provide a list of all things that are happening in this file, <abbr class="abbrev">e.g.</abbr> class declarations and function definitions</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>,</strong></span></td><td>Jump to definition of a function if the cursor is currently on a function declaration</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>.</strong></span></td><td>Jump to declaration of a function or variable if the cursor is currently in a function definition</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>PageDown</strong></span></td><td>Jump to next function</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>PageUp</strong></span></td><td>Jump to previous function</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>G</strong></span></td><td>Goto line</td></tr></tbody></table></div><p>
</p><p>
</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th colspan="2">Searching and replacing</th></tr></thead><tbody><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>F</strong></span></td><td>Find</td></tr><tr><td><span class="keycap"><strong>F3</strong></span></td><td>Find next</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>R</strong></span></td><td>Replace</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>F</strong></span></td><td>Find-Replace in multiple files</td></tr></tbody></table></div><p>
</p><p>
</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th colspan="2">Other things</th></tr></thead><tbody><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>_</strong></span></td><td>Collapse one level: remove this block from view, for example if you want to focus on the bigger picture within a function</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>+</strong></span></td><td>Expand one level: undo the collapsing</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>D</strong></span></td><td>Comment out selected text or current line</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>D</strong></span></td><td>Comment in selected text or current line</td></tr><tr><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>D</strong></span></td><td>Document the current function. If the cursor is on a function or class declaration then hitting this key will create a doxygen-style comment pre-populated with a listing of all parameters, return values, <abbr class="abbrev">etc.</abbr></td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>T</strong></span></td><td>Transpose the current and the previous character</td></tr><tr><td><span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>K</strong></span></td><td>Delete the current line (note: this is not just emacs' <span class="quote">“<span class="quote">delete from here to the end of the line</span>”</span>)</td></tr></tbody></table></div><p>
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="modes-and-working-sets.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="code-generation-with-templates.html">Next</a></td></tr><tr><td class="prevCell">Modes and working sets </td><td class="upCell">Working with source code</td><td class="nextCell"> Code generation with templates</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="creating-projects-from-scratch.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="exploring-source-code.html">Next</a></td></tr><tr><td class="prevCell">Creating projects from scratch </td><td class="upCell"> </td><td class="nextCell"> Exploring source code</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="code-generation-with-templates.html"><html><head><title>Chapter 4. Code generation with templates</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="some-useful-keyboard-shortcuts.html" title="Some useful keyboard shortcuts"><link rel="next" href="creating-a-new-unit-test.html" title="Creating a new unit test"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Code generation with templates</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="creating-a-new-unit-test.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="code-generation-with-templates"></a>Chapter 4. Code generation with templates</h1></div></div></div><p><span class="application">KDevelop</span> uses templates for generating source code files and to avoid writing repeatable code.
</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-a-new-class"></a>Creating a new class</h2></div></div></div><p>The most common use for code generation is probably writing new classes. To create a new class in an existing project, right click on a project folder and choose <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Create from Template...</span></span>. The same dialog can be started from the menu by clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">File</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">New from Template...</span></span>, but using a project folder has the benefit of setting a base URL for the output files. Choose <code class="filename">Class</code> in the category selection view, and the desired language and template in the other two views. After you have selected a class template, you will have to specify the details of the new class.
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-template-selection.png"></div></div><p>
</p><p>First you have to specify an identifier for the new class. This can be a simple name (like <code class="varname">Bus</code>) or a complete identifier with namespaces (like <code class="varname">Transportation::Bus</code>). In the latter case, <span class="application">KDevelop</span> will parse the identifier and correctly separate the namespaces from the actual name. On the same page, you can add base classes for the new class. You may notice that some templates choose a base class on their own, you are free to remove it and/or add other bases. You should write the full inheritance statement here, which is language-dependent, such as <code class="varname">public QObject</code> for C++, <code class="varname">extends SomeClass</code> for PHP or simply the name of the class for Python.
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-template-inheritance.png"></div></div><p>
</p><p>In the next page, you are offered a selection of virtual methods from all inherited classes, as well as some default constructors, destructors and operators. Checking the check box next to a method signature will implement this method in the new class.
</p><p>Clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span> brings up a page where you can add members to a class. Depending on the selected template, these may appear in the new class as member variables, or the template may create properties with setters and getters for them. In a language where variable types have to be declared, such as C++, you have to specify both the type and the name of the member, such as <code class="varname">int number</code> or <code class="varname">QString name</code>. In other languages, you may leave out the type, but it is good practice to enter it anyway, because the selected template could still make some use of it.
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-template-members.png"></div></div><p>
</p><p>In the following pages, you can choose a license for you new class, set any custom options required by the selected template, and configure output locations for all the generated files. By clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Finish</span></span>, you complete the assistant and create the new class. The generated files will be opened in the editor, so you can start adding code right away.
</p><p>After creating a new C++ class, you will be given an option of adding the class to a project target. Choose a target from the dialog page, or dismiss the page and add the files to a target manually.
</p><p>If you chose the <code class="filename">Qt Object</code> template, checked some of the default methods, and added two member variables, the output should look like on the following picture.
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-template-result.png"></div></div><p>
</p><p>You can see that data members are converted into Qt properties, with accessor functions and the Q_PROPERTY macros. Arguments to setter functions are even passed by const-reference, where appropriate. Additionally, a private class is declared, and a private pointer created with Q_DECLARE_PRIVATE. All this is done by the template, choosing a different template in the first step could completely change the output.
</p></div><FILENAME filename="creating-a-new-unit-test.html"><html><head><title>Creating a new unit test</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="code-generation-with-templates.html" title="Chapter 4. Code generation with templates"><link rel="prev" href="code-generation-with-templates.html" title="Chapter 4. Code generation with templates"><link rel="next" href="other-files.html" title="Other files"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Creating a new unit test</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="code-generation-with-templates.html">Prev</a></td><td class="upCell">Code generation with templates</td><td class="nextCell"><a accesskey="n" href="other-files.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="creating-a-new-unit-test"></a>Creating a new unit test</h2></div></div></div><p>Even though most testing frameworks require each test to also be a class, <span class="application">KDevelop</span> includes a method to simplify the creation of unit tests. To create a new test, right click on a project folder and choose <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Create from Template...</span></span>. In the template selection page, choose <code class="filename">Test</code> as the category, then choose your programming language and template and click <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span>.
</p><p>You will be prompted for the test name and a list of test cases. For the test cases, you only have to specify a list of names. Some unit testing frameworks, such as PyUnit and PHPUnit, require that test cases start with a special prefix. In <span class="application">KDevelop</span>, the template is responsible for adding the prefix, so you do not have to prefix the test cases here. After clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Next</span></span>, specify the license and output locations for the generated files, and the test will be created.
</p><p>Unit tests created this way will not be added to any target automatically. If you are using CTest or some other testing framework, make sure to add the new files to a target.
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="code-generation-with-templates.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="other-files.html">Next</a></td></tr><tr><td class="prevCell">Code generation with templates </td><td class="upCell">Code generation with templates</td><td class="nextCell"> Other files</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="other-files.html"><html><head><title>Other files</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="code-generation-with-templates.html" title="Chapter 4. Code generation with templates"><link rel="prev" href="creating-a-new-unit-test.html" title="Creating a new unit test"><link rel="next" href="managing-templates.html" title="Managing templates"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Other files</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="creating-a-new-unit-test.html">Prev</a></td><td class="upCell">Code generation with templates</td><td class="nextCell"><a accesskey="n" href="managing-templates.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="other-files"></a>Other files</h2></div></div></div><p>While classes and unit tests receive special attention when generating code from templates, the same method can be used for any kind of source code files. For example, one could use a template for a CMake Find module or a .desktop file. This can be done by choosing <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Create from Template...</span></span>, and selecting the wanted category and template. If the selected category is neither <code class="filename">Class</code> nor <code class="filename">Test</code>, you will only have the option of choosing the license, any custom options specified by the template, and the output file locations. As with classes and tests, finishing the assistant will generate the files and open them in the editor.
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="creating-a-new-unit-test.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="managing-templates.html">Next</a></td></tr><tr><td class="prevCell">Creating a new unit test </td><td class="upCell">Code generation with templates</td><td class="nextCell"> Managing templates</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="managing-templates.html"><html><head><title>Managing templates</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="code-generation-with-templates.html" title="Chapter 4. Code generation with templates"><link rel="prev" href="other-files.html" title="Other files"><link rel="next" href="building-compiling-projects-with-custom-makefiles.html" title="Chapter 5. Building (compiling) projects with custom Makefiles"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Managing templates</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="other-files.html">Prev</a></td><td class="upCell">Code generation with templates</td><td class="nextCell"><a accesskey="n" href="building-compiling-projects-with-custom-makefiles.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="managing-templates"></a>Managing templates</h2></div></div></div><p>From the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">File</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">New from Template...</span></span> assistant, you can also download additional file templates by clicking the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Get more Templates...</span></span> button. This opens a Get Hot New Stuff dialog, where you can install additional templates, as well as update or remove them. There is also a configuration module for templates, which can be reached by clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guisubmenu">Configure <span class="application">KDevelop</span></span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Templates</span></span>. From there, you can manage both file templates (explained above) and project templates (used for creating new projects).
</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-template-manager.png"></div></div><p>
</p><p>Of course, if none of the available template suit your project, you can always create new ones. The easiest way is probably to copy and modify an existing template, while a short <a class="ulink" href="https://techbase.kde.org/Development/Tutorials/KDevelop/Creating_a_class_template" target="_top">tutorial</a> and a longer <a class="ulink" href="https://techbase.kde.org/Projects/KDevelop4/File_template_specification" target="_top">specification document</a> are there to help you. To copy an installed template, open the template manager by clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guisubmenu">Configure KDevelop...</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Templates</span></span>, select the template you wish to copy, then click the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Extract Template</span></span> button. Select a destination folder, then click <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">OK</span></span>, and the contents of the template will be extracted into the selected folder. Now you can edit the template by opening the extracted files and modifying them. After you are done, you can import your new
template into <span class="application">KDevelop</span> by opening the template manager, activating the appropriate tab (either <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Project Templates</span></span> or <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">File Templates</span></span>) and clicking <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Load Template</span></span>. Open the template description file, which is the one with the suffix either <code class="varname">.kdevtemplate</code> or <code class="varname">.desktop</code>. <span class="application">KDevelop</span> will compress the files into a template archive and import the template.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>When copying an existing template, make sure you rename it before importing it again. Otherwise, you will either overwrite the old template, or will end up with two templates with identical names. To rename a template, rename the description file to something unique (but keep the suffix), and change the <code class="filename">Name</code> entry in the description file. </p></div><p>
</p><p>If you want to write a template from scratch, you can start with a sample C++ class template by <a class="link" href="creating-projects-from-scratch.html" title="Creating projects from scratch">creating a new project</a> and selecting the <code class="filename">C++ Class Template</code> project in category <code class="filename">KDevelop</code>.
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="other-files.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="building-compiling-projects-with-custom-makefiles.html">Next</a></td></tr><tr><td class="prevCell">Other files </td><td class="upCell">Code generation with templates</td><td class="nextCell"> Building (compiling) projects with custom Makefiles</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="creating-a-new-unit-test.html">Next</a></td></tr><tr><td class="prevCell">Some useful keyboard shortcuts </td><td class="upCell"> </td><td class="nextCell"> Creating a new unit test</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="building-compiling-projects-with-custom-makefiles.html"><html><head><title>Chapter 5. Building (compiling) projects with custom Makefiles</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="managing-templates.html" title="Managing templates"><link rel="next" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html" title="Selecting a collection of Makefile targets for repeated building"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Building (compiling) projects with custom Makefiles</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="managing-templates.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="building-compiling-projects-with-custom-makefiles"></a>Chapter 5. Building (compiling) projects with custom Makefiles</h1></div></div></div><p>Many projects describe how source files have to be compiled (and which files have to be recompiled once a source or header file changes) using Makefiles that are interpreted by the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">make</span></span> program (see, for example, <a class="ulink" href="https://www.gnu.org/software/make/" target="_top">GNU make</a>). For simple projects, it is often very easy to set up such a file by hand. Larger projects often integrate their Makefiles with the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">GNU autotools</span></span> (autoconf, autoheader, automake). In this section, let us simply assume that you have a Makefile for your project and you want to teach <span class="application">KDevelop</span> how to interact with it.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p><span class="application">KDevelop</span> 4.x doesn't know about the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">GNU autotools</span></span> at the time this section is written. If your project uses them, you will have to run <code class="varname">./configure</code> or any of the other related commands by hand on a command line. If you want to do this within <span class="application">KDevelop</span>, open the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Konsole</span></span> tool (if necessary add it to the perimeter of the main window using the menu <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Windows</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Add tool view</span></span>) that gives you a shell window view and run <code class="varname">./configure</code> from the command line in this view.</p></div><p>The first step is to teach <span class="application">KDevelop</span> about targets in your Makefiles. There are two ways to do that: selecting individual Makefile targets, and choosing a set of targets you may want to build frequently. For both approaches, open the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool by clicking on the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> button on the perimeter of <span class="application">KDevelop</span>'s main window (if you don't have this button see above how to add a tool's button there). The <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool window has two parts: the top half — titled <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> — lists all of your projects and let's you expand the underlying directory trees. The bottom half — titled <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Project Selection</span></span> — lists a subset of those projects that will be built if you choose the menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Project</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Build selection</span></span> or hit <span class="keycap"><strong>F8</strong></span>; we'll come back to this part below.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="building-individual-makefile-targets"></a>Building individual Makefile targets</h2></div></div></div><p>In the top part of the project view, expand the sub-tree for one project, let's say the one for which you want to run a particular Makefile target. This will give you icons for (i) directories under this project, (ii) files in the top-level directory for this project, (iii) Makefile targets <span class="application">KDevelop</span> can identify. These categories are shown in the picture at right. Note that <span class="application">KDevelop</span> <span class="emphasis"><em>understands</em></span> Makefile syntax to a certain degree and therefore can offer you targets defined in this Makefile (though this understanding has its limits if targets are composed or implicit).</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-1a.png"><div class="caption"><p></p></div></div></div><p>To build any of the targets listed there, click on it with the right mouse button and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build</span></span>. For example, doing this with the <span class="quote">“<span class="quote">clean</span>”</span> target will simply execute <span class="quote">“<span class="quote">make clean</span>”</span>. You can see this happening in the subwindow titled <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build</span></span> that opens up, showing the command and the output. (This window corresponds to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build</span></span> tool, so you can close and later re-open the window using the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build</span></span> tool button on the perimeter of the main window. It is shown at the bottom right of the picture.)</p></div><FILENAME filename="selecting-a-collection-of-makefile-targets-for-repeated-building.html"><html><head><title>Selecting a collection of Makefile targets for repeated building</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="building-compiling-projects-with-custom-makefiles.html" title="Chapter 5. Building (compiling) projects with custom Makefiles"><link rel="prev" href="building-compiling-projects-with-custom-makefiles.html" title="Chapter 5. Building (compiling) projects with custom Makefiles"><link rel="next" href="what-to-do-with-error-messages.html" title="What to do with error messages"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Selecting a collection of Makefile targets for repeated building</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="building-compiling-projects-with-custom-makefiles.html">Prev</a></td><td class="upCell">Building (compiling) projects with custom Makefiles</td><td class="nextCell"><a accesskey="n" href="what-to-do-with-error-messages.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="selecting-a-collection-of-makefile-targets-for-repeated-building"></a>Selecting a collection of Makefile targets for repeated building</h2></div></div></div><p>Right-clicking on individual Makefile targets every time you want to build something will quickly get old. Rather, we'd like to have individual targets for one or more of the projects in the session that we can repeatedly build without much mouse work. This is where the concept of <span class="quote">“<span class="quote">Build target selections</span>”</span> comes in: it is a collection of Makefile targets that are built one-after-the-other whenever you hit the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build selection</span></span> button in the button list at the top, select the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Project</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Build selection</span></span> menu item, or hit the <span class="keycap"><strong>F8</strong></span> function key.</p><p>The list of selected Makefile targets is shown in the bottom half of the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool view.</p><p>By default, the selection contains all projects, but you can change that. For example, if your list of projects contains three projects (a base library L and two applications A and B), but you're currently only working on project A, then you may want to remove project B from the selection by highlighting it in the selection and hitting the <span class="inlinemediaobject"><img src="Icon-list-remove.png"></span> button. Furthermore, you probably want to make sure that the library L is built before  project A by moving entries in the selection up and down using the buttons to the right of the list. You can also get a particular Makefile target into the selection by right-clicking onto it and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Add to buildset</span></span>, or just highlighting it and hitting the <span class="inlinemediaobject"><img src="Icon-list-add.png"></span> button just above the list of selected targets.</p><p><span class="application">KDevelop</span> allows you to configure what to do whenever you build the selection. To this end, use the menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Project</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Open configuration</span></span>. There, you can for example select the number of simultaneous jobs <span class="quote">“<span class="quote">make</span>”</span> should execute — if your computer has, say, 8 processor cores, then entering 8 in this field would be a useful choice. In this dialog, the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Default make target</span></span> is a Makefile target used for <span class="emphasis"><em>all</em></span> targets in the selection.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="building-compiling-projects-with-custom-makefiles.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="what-to-do-with-error-messages.html">Next</a></td></tr><tr><td class="prevCell">Building (compiling) projects with custom Makefiles </td><td class="upCell">Building (compiling) projects with custom Makefiles</td><td class="nextCell"> What to do with error messages</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="what-to-do-with-error-messages.html"><html><head><title>What to do with error messages</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="building-compiling-projects-with-custom-makefiles.html" title="Chapter 5. Building (compiling) projects with custom Makefiles"><link rel="prev" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html" title="Selecting a collection of Makefile targets for repeated building"><link rel="next" href="running-programs-in-kdevelop.html" title="Chapter 6. Running programs in KDevelop"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> What to do with error messages</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html">Prev</a></td><td class="upCell">Building (compiling) projects with custom Makefiles</td><td class="nextCell"><a accesskey="n" href="running-programs-in-kdevelop.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="what-to-do-with-error-messages"></a>What to do with error messages</h2></div></div></div><p>If the compiler encounters an error message, simply click on the line with the error message and the editor will jump to the line (and if available column) where the error was reported. Depending on the error message, <span class="application">KDevelop</span> may also offer you several possible actions to fix the error, for example by declaring a previously undeclared variable if an unknown symbol was found.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="running-programs-in-kdevelop.html">Next</a></td></tr><tr><td class="prevCell">Selecting a collection of Makefile targets for repeated building </td><td class="upCell">Building (compiling) projects with custom Makefiles</td><td class="nextCell"> Running programs in <span class="application">KDevelop</span></td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="managing-templates.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="selecting-a-collection-of-makefile-targets-for-repeated-building.html">Next</a></td></tr><tr><td class="prevCell">Managing templates </td><td class="upCell"> </td><td class="nextCell"> Selecting a collection of Makefile targets for repeated building</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="running-programs-in-kdevelop.html"><html><head><title>Chapter 6. Running programs in KDevelop</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="what-to-do-with-error-messages.html" title="What to do with error messages"><link rel="next" href="some-useful-keyboard-shortcuts0.html" title="Some useful keyboard shortcuts"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Running programs in <span class="application">KDevelop</span></div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="what-to-do-with-error-messages.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts0.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="running-programs-in-kdevelop"></a>Chapter 6. Running programs in <span class="application">KDevelop</span></h1></div></div></div><p>Once you have built a program, you will want to run it. To do this, need to configure <span class="emphasis"><em>Launches</em></span> for your projects. A <span class="emphasis"><em>Launch</em></span> consists of the name of an executable, a set of command line parameters, and an execution environment (such as <span class="quote">“<span class="quote">run this program in a shell</span>”</span>, or <span class="quote">“<span class="quote">run this program in the debugger</span>”</span>).</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="setting-up-launches-in-kdevelop"></a>Setting up launches in <span class="application">KDevelop</span></h2></div></div></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-2.png"><div class="caption"><p></p></div></div></div><p>To set this up go to menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Configure launches</span></span>, highlight the project you want to add a launch for, and click on the <span class="inlinemediaobject"><img src="Icon-list-add.png"></span> button. Then enter the name of the executable, and the path where you want to run the program. If running the executable depends on building the executable and/or other libraries first, then you may want to add them to the list at the bottom: select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Build</span></span> from the dropdown menu, then hit the <span class="inlinemediaobject"><img src="Icon-folder.png"></span> symbol to the right of the textbox and select whatever target you want to have built. In the example above, I have selected the target <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">all</span></span> from project <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="replaceable"><em class="replaceable"><code>1.deal.II</code></em></span> and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="replaceable"><em class="replaceable"><code>step-32</code></em></span> from project 
<span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="replaceable"><em class="replaceable"><code>1.step-32</code></em></span> to make sure both the base library and the application program have been compiled and are up to date before the program is actually executed. While you're there, you may as well also configure a debug launch by clicking on the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Debug</span></span> symbol and adding the name of the debugger program; if this is the system's default debugger (<abbr class="abbrev">e.g.</abbr> <span class="application">gdb</span> on <span class="trademark">Linux</span>®), then you don't need to do this step.</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-3.png"><div class="caption"><p></p></div></div></div><p>You can now try to run the program: Select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Execute Launch</span></span> from <span class="application">KDevelop</span>'s main window menu (or hit <span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>F9</strong></span>) and your program should run in a separate subwindow of <span class="application">KDevelop</span>. The picture above shows the result: The new <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Run</span></span> tool subwindow at the bottom shows the output of the program that is being run, in this case of the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="replaceable"><em class="replaceable"><code>step-32</code></em></span> program.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> If you have configured multiple launches, you can choose which one should run when you hit <span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>F9</strong></span> by going to <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Current Launch Configuration</span></span>. There is a non-obvious way to edit the name of a configuration, however: in the dialog box you get when you select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Current Launch Configuration</span></span>, double-click on the name of the configuration in the tree view on the left, which will allow you to edit the configuration's name.</p></div></div><FILENAME filename="some-useful-keyboard-shortcuts0.html"><html><head><title>Some useful keyboard shortcuts</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="running-programs-in-kdevelop.html" title="Chapter 6. Running programs in KDevelop"><link rel="prev" href="running-programs-in-kdevelop.html" title="Chapter 6. Running programs in KDevelop"><link rel="next" href="debugging-programs-in-kdevelop.html" title="Chapter 7. Debugging programs in KDevelop"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Some useful keyboard shortcuts</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="running-programs-in-kdevelop.html">Prev</a></td><td class="upCell">Running programs in <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="debugging-programs-in-kdevelop.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="some-useful-keyboard-shortcuts0"></a>Some useful keyboard shortcuts</h2></div></div></div><p>
</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th colspan="2">Running a program</th></tr></thead><tbody><tr><td><span class="keycap"><strong>F8</strong></span></td><td>Build (call make)</td></tr><tr><td><span class="keycap"><strong>Shift</strong></span>+<span class="keycap"><strong>F9</strong></span></td><td>Run</td></tr><tr><td><span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>F9</strong></span></td><td>Run program in the debugger; you may want to set breakpoints beforehand, for example by right-clicking with the mouse on a particular line in the source code</td></tr></tbody></table></div><p>
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="running-programs-in-kdevelop.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="debugging-programs-in-kdevelop.html">Next</a></td></tr><tr><td class="prevCell">Running programs in <span class="application">KDevelop</span> </td><td class="upCell">Running programs in <span class="application">KDevelop</span></td><td class="nextCell"> Debugging programs in <span class="application">KDevelop</span></td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="what-to-do-with-error-messages.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts0.html">Next</a></td></tr><tr><td class="prevCell">What to do with error messages </td><td class="upCell"> </td><td class="nextCell"> Some useful keyboard shortcuts</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="debugging-programs-in-kdevelop.html"><html><head><title>Chapter 7. Debugging programs in KDevelop</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="some-useful-keyboard-shortcuts0.html" title="Some useful keyboard shortcuts"><link rel="next" href="attaching-the-debugger-to-a-running-process.html" title="Attaching the debugger to a running process"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Debugging programs in <span class="application">KDevelop</span></div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts0.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="attaching-the-debugger-to-a-running-process.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="debugging-programs-in-kdevelop"></a>Chapter 7. Debugging programs in <span class="application">KDevelop</span></h1></div></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="running-a-program-in-the-debugger"></a>Running a program in the debugger</h2></div></div></div><p>Once you have a launch configured (see <a class="link" href="running-programs-in-kdevelop.html" title="Chapter 6. Running programs in KDevelop">Running programs</a>), you can also run it in a debugger: Select the menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Debug Launch</span></span>, or hit <span class="keycap"><strong>Alt</strong></span>+<span class="keycap"><strong>F9</strong></span>. If you are familiar with <span class="application">gdb</span>, the effect is the same as starting <span class="application">gdb</span> with the executable specified in the launch configuration and then saying <code class="varname">Run</code>. This means that if the program calls <code class="varname">abort()</code> somewhere (<abbr class="abbrev">e.g.</abbr> when you run onto a failing assertion) or if there is a segmentation fault, then the debugger will stop. On the other hand, if the program runs to the end (with or without doing the right thing) then the debugger will not stop by itself before the program is finished. In the latter case, you will want to set a breakpoint on all those lines of your code base where you want the debugger to stop before you run the debug launch. You 
can do that by moving the cursor on such a line and selecting the menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Toggle breakpoint</span></span>, or right-clicking on a line and selecting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Toggle Breakpoint</span></span> from the context menu.</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-4.png"><div class="caption"><p></p></div></div></div><p>Running a program in the debugger will put <span class="application">KDevelop</span> in a different mode: it will replace all the <span class="quote">“<span class="quote">Tool</span>”</span> buttons on the perimeter of the main window by ones that are appropriate for debugging, rather than for editing. You can see which of the mode you are in by looking at the top right of the window: there are tabs named <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Review</span></span>, <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Debug</span></span>, and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code</span></span>; clicking on them allows you to switch back and forth between the three modes; each mode has a set of tool views of its own, which you can configure in the same way as we configured the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code</span></span> tools in the section <a class="link" href="working-with-source-code.html#tools-and-views" title="Tools and views">Tools and views</a>.</p><p>Once the debugger stops (at a breakpoint, or a point where <code class="varname">abort()</code> is called) you can inspect a variety of information about your program. For example, in the image above, we have selected the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Frame Stack</span></span> tool at the bottom (roughly equivalent to <span class="application">gdb</span>'s <span class="quote">“<span class="quote">backtrace</span>”</span> and <span class="quote">“<span class="quote">info threads</span>”</span> commands) that shows the various threads that are currently running in your program at the left (here a total of 8) and how execution got to the current stopping point at the right (here: <code class="varname">main()</code> called <code class="varname">run()</code>; the list would be longer had we stopped in a function called by <code class="varname">run()</code> itself). On the left, we can inspect local variables including the current object (the object pointed to by the <code class="varname">this</code> variable).</p><p>From here, there are various possibilities you can do: You can execute the current line (<span class="keycap"><strong>F10</strong></span>, <span class="application">gdb</span>'s <span class="quote">“<span class="quote">next</span>”</span> command), step into the functions (<span class="keycap"><strong>F11</strong></span>, <span class="application">gdb</span>'s <span class="quote">“<span class="quote">step</span>”</span> command), or run to the end of the function (<span class="keycap"><strong>F12</strong></span>, <span class="application">gdb</span>'s <span class="quote">“<span class="quote">finish</span>”</span> command). At every stage, <span class="application">KDevelop</span> updates the variables shown at the left to their current values. You can also hover the mouse over a symbol in your code, <abbr class="abbrev">e.g.</abbr> a variable; <span class="application">KDevelop</span> will then show the current value of that symbol and offer to stop the program during execution the next time this variable's value changes. If you know <span class="application">gdb</span>, you can also click on the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">GDB</span></span> tool button at the bottom and have the possibility to enter <span class="application">gdb</span> commands, for example in order to change the value of a variable (for which there doesn't currently seem to 
be another way).</p></div><FILENAME filename="attaching-the-debugger-to-a-running-process.html"><html><head><title>Attaching the debugger to a running process</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="debugging-programs-in-kdevelop.html" title="Chapter 7. Debugging programs in KDevelop"><link rel="prev" href="debugging-programs-in-kdevelop.html" title="Chapter 7. Debugging programs in KDevelop"><link rel="next" href="some-useful-keyboard-shortcuts1.html" title="Some useful keyboard shortcuts"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Attaching the debugger to a running process</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="debugging-programs-in-kdevelop.html">Prev</a></td><td class="upCell">Debugging programs in <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts1.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="attaching-the-debugger-to-a-running-process"></a>Attaching the debugger to a running process</h2></div></div></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-9.png"><div class="caption"><p></p></div></div></div><p>Sometimes, one wants to debug a program that's already running. One scenario for this is debugging parallel programs using <a class="ulink" href="https://computing.llnl.gov/tutorials/mpi/" target="_top">MPI</a>, or for debugging a long running background process. To do this, go to the menu entry <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Attach to Process</span></span>, which will open a window like the one above. You will want to select the program that matches your currently open project in <span class="application">KDevelop</span> - in my case that would be the step-32 program.</p><p>This list of programs can be confusing because it is often long as in the case shown here. You can make your life a bit easier by going to the dropdown box at the top right of the window. The default value is <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">User processes</span></span>, <abbr class="abbrev">i.e.</abbr> all programs that are run by any of the users currently logged into this machine (if this is your desktop or laptop, you're probably the only such user, apart from root and various service accounts); the list doesn't include processes run by the root user, however. You can limit the list by either choosing <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Own processes</span></span>, removing all the programs run by other users. Or better still: Select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Programs only</span></span>, which removes a lot of processes that are formally running under your name but that you don't usually interact with, such as the window manager, background tasks and so on that are unlikely candidates for debugging.</p><p>Once you have selected a process, attaching to it will get you into <span class="application">KDevelop</span>'s debug mode, open all the usual debugger tool views and stop the program at the position where it happened to be when you attached to it. You may then want to set breakpoints, viewpoints, or whatever else is necessary and continue program execution by going to the menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Run</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Continue</span></span>.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="debugging-programs-in-kdevelop.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="some-useful-keyboard-shortcuts1.html">Next</a></td></tr><tr><td class="prevCell">Debugging programs in <span class="application">KDevelop</span> </td><td class="upCell">Debugging programs in <span class="application">KDevelop</span></td><td class="nextCell"> Some useful keyboard shortcuts</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="some-useful-keyboard-shortcuts1.html"><html><head><title>Some useful keyboard shortcuts</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="debugging-programs-in-kdevelop.html" title="Chapter 7. Debugging programs in KDevelop"><link rel="prev" href="attaching-the-debugger-to-a-running-process.html" title="Attaching the debugger to a running process"><link rel="next" href="working-with-version-control-systems.html" title="Chapter 8. Working with version control systems"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Some useful keyboard shortcuts</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="attaching-the-debugger-to-a-running-process.html">Prev</a></td><td class="upCell">Debugging programs in <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="working-with-version-control-systems.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="some-useful-keyboard-shortcuts1"></a>Some useful keyboard shortcuts</h2></div></div></div><p>
</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col class="c1"><col class="c2"></colgroup><thead><tr><th colspan="2">Debugging</th></tr></thead><tbody><tr><td><span class="keycap"><strong>F10</strong></span></td><td>Step over (gdb's <span class="quote">“<span class="quote">next</span>”</span>)</td></tr><tr><td><span class="keycap"><strong>F11</strong></span></td><td>Step into (gdb's <span class="quote">“<span class="quote">step</span>”</span>)</td></tr><tr><td><span class="keycap"><strong>F12</strong></span></td><td>Step out of (gdb's <span class="quote">“<span class="quote">finish</span>”</span>)</td></tr></tbody></table></div><p>
</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="attaching-the-debugger-to-a-running-process.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="working-with-version-control-systems.html">Next</a></td></tr><tr><td class="prevCell">Attaching the debugger to a running process </td><td class="upCell">Debugging programs in <span class="application">KDevelop</span></td><td class="nextCell"> Working with version control systems</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts0.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="attaching-the-debugger-to-a-running-process.html">Next</a></td></tr><tr><td class="prevCell">Some useful keyboard shortcuts </td><td class="upCell"> </td><td class="nextCell"> Attaching the debugger to a running process</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="working-with-version-control-systems.html"><html><head><title>Chapter 8. Working with version control systems</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="some-useful-keyboard-shortcuts1.html" title="Some useful keyboard shortcuts"><link rel="next" href="customizing-kdevelop.html" title="Chapter 9. Customizing KDevelop"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Working with version control systems</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts1.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="customizing-kdevelop.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="working-with-version-control-systems"></a>Chapter 8. Working with version control systems</h1></div></div></div><p>If you are working with larger projects, chances are that the source code is managed by a version control system such as <a class="ulink" href="https://subversion.apache.org/" target="_top">subversion</a> or <a class="ulink" href="https://git-scm.com/" target="_top">git</a>. The following description is written with <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">subversion</span></span> in view but will be equally true if you use <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">git</span></span> or any other supported version control system.</p><p>First not that if the directory in which a project is located is under version control, <span class="application">KDevelop</span> will automatically notice. In other words: It is not necessary that you tell <span class="application">KDevelop</span> to check out a copy itself when setting up your project; it is ok to point <span class="application">KDevelop</span> at a directory into which you have previously checked out a copy from the repository. If you have such a directory under version control, open the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Projects</span></span> tool view. There are then a number of things you can do:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>If your directory has become outdated, you can update it from the repository: Click on the project name with the right mouse button, go to the menu <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Subversion</span></span> and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Update</span></span>. This will bring all files that belong to this project up to date with respect to the repository.
</p></li><li class="listitem"><p>If you want to restrict this action to individual subdirectories or files, then expand the tree view of this project to the level you want and right click on a subdirectory or file name, then do the same as above.
</p></li></ul></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-8.png"><div class="caption"><p></p></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>If you've edited one or more files, expand the view of this project to the directory in which these files are located and right click on the directory. This gives you a menu item <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Subversion</span></span> that offers you different choices. Choose <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Compare to base</span></span> to see the differences between the version you have edited and the version in the repository you had previously checked out (the revision <span class="quote">“<span class="quote">base</span>”</span>). The resulting view will show the <span class="quote">“<span class="quote">diffs</span>”</span> for all files in this directory.
</p></li><li class="listitem"><p>If you only edited a single file, you can also get the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Subversion</span></span> menu for this file by simply right clicking on the corresponding file name in the project view. Even simpler, just right clicking into the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Editor</span></span> view in which you have opened this file will also give you this menu option.
</p></li><li class="listitem"><p>If you want to check in one or more edited files, right click either on an individual file, subdirectory, or whole project and select <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Subversion</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Commit</span></span>. This will get you into <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Review</span></span> mode, the third mode besides <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Code</span></span> and <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Debug</span></span> as you can see in the top right corner of the <span class="application">KDevelop</span> main window. The picture on the right shows you how this looks. In <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Review</span></span> mode, the top part shows you diffs for the entire subdirectory/project and each individual changed file with changes highlighted (see the various tabs on this part of the window). By default, all changed files are in the changeset you are about to commit, but you can unselect some of the files if their modifications are unrelated to what you want to commit. For example, in the example on the right I have unselected <code class="varname">step-32.cc</code> and <code class="varname">step-32.prm</code> because the 
changes in these files have nothing to do with the other ones I made to this project and I don't yet want to check them in yet (I may later want to do so in a separate commit). After reviewing the changes you can enter a commit message into the text box and hit <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Commit</span></span> on the right to send things off.
</p></li><li class="listitem"><p>As with seeing differences, if you want to check in a single file you can also just right click into the editor window to get the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Subversion</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Commit</span></span> menu item.
</p></li></ul></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="some-useful-keyboard-shortcuts1.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="customizing-kdevelop.html">Next</a></td></tr><tr><td class="prevCell">Some useful keyboard shortcuts </td><td class="upCell"> </td><td class="nextCell"> Customizing <span class="application">KDevelop</span></td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="customizing-kdevelop.html"><html><head><title>Chapter 9. Customizing KDevelop</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="working-with-version-control-systems.html" title="Chapter 8. Working with version control systems"><link rel="next" href="customizing-code-indentation.html" title="Customizing code indentation"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Customizing <span class="application">KDevelop</span></div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="working-with-version-control-systems.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="customizing-code-indentation.html">Next</a></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="customizing-kdevelop"></a>Chapter 9. Customizing <span class="application">KDevelop</span></h1></div></div></div><p>There are times when you want to change the default appearance or behavior of <span class="application">KDevelop</span>, for example because you are used to different keyboard shortcuts or because your project requires a different indenting style for source code. In the following sections, we briefly discuss the various ways how <span class="application">KDevelop</span> can be customized for these needs.</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="customizing-the-editor"></a>Customizing the editor</h2></div></div></div><p>There are a number of useful things one can configure in and around <span class="application">KDevelop</span>'s built-in editor. Of more universal use is to switch on line numbering using the menu entry <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Editor</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guisubmenu">View</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Show line numbers</span></span>, making it easier to match compiler error messages or debug messages with locations in the code. In the same submenu you may also want to switch on the <span class="emphasis"><em>Icon border</em></span> - a column to the left of your code in which <span class="application">KDevelop</span> will show icons such as whether there is a breakpoint on the current line.</p></div><FILENAME filename="customizing-code-indentation.html"><html><head><title>Customizing code indentation</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="customizing-kdevelop.html" title="Chapter 9. Customizing KDevelop"><link rel="prev" href="customizing-kdevelop.html" title="Chapter 9. Customizing KDevelop"><link rel="next" href="customizing-keyboard-shortcuts.html" title="Customizing keyboard shortcuts"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Customizing code indentation</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-kdevelop.html">Prev</a></td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="customizing-keyboard-shortcuts.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="customizing-code-indentation"></a>Customizing code indentation</h2></div></div></div><p>Many of us like code formatted in a particular way. Many projects also enforce a particular indentation style. Neither may match <span class="application">KDevelop</span>'s default indentation style. However, this can be customized: Go to the <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Customize <span class="application">KDevelop</span></span></span> menu item, then click on <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Source Formatter</span></span> on the left. You can choose one of the predefined indentation styles that are widely in use, or define your own one by adding a new style and then editing it. There may not be a way to exactly re-create the style in which your project's sources have been indented in the past, but you can come close by using the settings for a new style; an example is shown in the two pictures below.</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-5.png"><div class="caption"><p></p></div></div></div><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-6.png"><div class="caption"><p></p></div></div></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> With <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel"><span class="application">KDevelop</span> 4.2.2</span></span>, you can create a new style for a particular mimetype (<abbr class="abbrev">e.g.</abbr> for C++ header files) but this style does not show up among the list of possible styles for other mimetypes (<abbr class="abbrev">e.g.</abbr> for C++ source files) although it would of course be useful to use the same style for both kinds of files. You will therefore have to define the style twice, once for header and once for source files. This has been reported as <a class="ulink" href="https://bugs.kde.org/show_bug.cgi?id=272335" target="_top"><span class="application">KDevelop</span> bug 272335</a>.</p></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-kdevelop.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="customizing-keyboard-shortcuts.html">Next</a></td></tr><tr><td class="prevCell">Customizing <span class="application">KDevelop</span> </td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"> Customizing keyboard shortcuts</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="customizing-keyboard-shortcuts.html"><html><head><title>Customizing keyboard shortcuts</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="customizing-kdevelop.html" title="Chapter 9. Customizing KDevelop"><link rel="prev" href="customizing-code-indentation.html" title="Customizing code indentation"><link rel="next" href="customizing-code-auto-completion.html" title="Customizing code auto-completion"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Customizing keyboard shortcuts</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-code-indentation.html">Prev</a></td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="customizing-code-auto-completion.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="customizing-keyboard-shortcuts"></a>Customizing keyboard shortcuts</h2></div></div></div><p><span class="application">KDevelop</span> has an almost boundless list of keyboard shortcuts (some of them are listed in the <span class="quote">“<span class="quote">Useful keyboard shortcuts sections</span>”</span> of several chapters in this manual) that can be changed to your taste through the menu <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Configure Shortcuts</span></span>. At the top of the dialog you can enter a searchword and it only shows those commands that match; you can then edit which key combination is bound to this command.</p><p>Two that have been found to be very useful to change are to set <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Align</span></span> to the <span class="keycap"><strong>Tab</strong></span> key (many people don't usually enter tabs by hand and rather prefer if the editor chooses the layout of code; with the changed shortcut, hitting <span class="keycap"><strong>Tab</strong></span> makes <span class="application">KDevelop</span> indent/outdent/align the code). The second one is putting <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Toggle Breakpoint</span></span> on <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>B</strong></span> since this is quite a frequent operation.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-code-indentation.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="customizing-code-auto-completion.html">Next</a></td></tr><tr><td class="prevCell">Customizing code indentation </td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"> Customizing code auto-completion</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="customizing-code-auto-completion.html"><html><head><title>Customizing code auto-completion</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="customizing-kdevelop.html" title="Chapter 9. Customizing KDevelop"><link rel="prev" href="customizing-keyboard-shortcuts.html" title="Customizing keyboard shortcuts"><link rel="next" href="credits.html" title="Chapter 10. Credits and License"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Customizing code auto-completion</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-keyboard-shortcuts.html">Prev</a></td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"><a accesskey="n" href="credits.html">Next</a></td></tr></table></div><div id="contentBody"><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="customizing-code-auto-completion"></a>Customizing code auto-completion</h2></div></div></div><p>Code completion is discussed in <a class="link" href="writing-source-code.html#auto-completion" title="Auto-completion">this manual's section on writing source code</a>. In <span class="application">KDevelop</span>, it comes from two sources: the editor, and the parse engine. The editor (<span class="application">Kate</span>) is a component of the larger KDE environment and offers auto-completion based on words it has already seen in other parts of the same document. Such auto-completions can be identified in the tooltip by the icon that precedes it:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-20.png"><div class="caption"><p></p></div></div></div><p>The editor's code completion can be customized via <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guisubmenu">Configure Editor</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Editing</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Auto Completion</span></span>. In particular, you can select how many characters you need to type in a word before auto-completion kicks in.</p><p>On the other hand, <span class="application">KDevelop</span>'s own auto-completion is much more powerful as it takes into account semantic information about the context. For example, it knows which member functions to offer when you type <code class="varname">object.</code>, <abbr class="abbrev">etc.</abbr>, as shown here:</p><p>
</p><div class="screenshot"><div xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="mediaobject"><img src="kdevelop-42.png"><div class="caption"><p></p></div></div></div><p>This context information comes from various language support plugins, which can be used after a given file has been saved (so it can check the filetype and use the correct language support).</p><p><span class="application">KDevelop</span>'s completion is set to appear as you type, right away, pretty much everywhere that it could possibly complete something. This is configurable in <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenu">Settings</span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guisubmenu">Configure <span class="application">KDevelop</span></span></span> → <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guimenuitem">Language Support</span></span>. If it isn't already set (as it should, by default), make sure <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Enable Automatic Invocation</span></span> is set.</p><p><span class="application">KDevelop</span> has two ways to show a completion: <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Minimal Automatic Completion</span></span> shows just the basic information in completion tooltips (<abbr class="abbrev">i.e.</abbr> the namespace, class, function, or variable name). This will look similar to <span class="application">Kate</span> completion (except for the icons).</p><p>On the other hand, <span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Full completion</span></span> will additionally show the type for each entry, and in the case of functions, also the arguments they take. Also, if you are currently filling in the arguments to a function, full completion will have an additional info-box above the cursor that will show you the current argument you are working on.</p><p><span class="application">KDevelop</span>'s code completion should also bring-to-top and highlight in green any completion items that match the currently expected type in both minimal and full completion, known as <span class="quote">“<span class="quote">best-matches</span>”</span>.</p><p>The three possible choices for the completion level in the configuration dialog are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Always minimal completion</span></span>: Never show <span class="quote">“<span class="quote">Full Completion</span>”</span>
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Minimal automatic completion</span></span>: Only show <span class="quote">“<span class="quote">Full Completion</span>”</span> when auto-completion has been triggered manually (<abbr class="abbrev">i.e.</abbr>, whenever you hit <span class="keycap"><strong>Ctrl</strong></span>+<span class="keycap"><strong>Space</strong></span>)
</p></li><li class="listitem"><p><span xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" class="guiitem"><span class="guilabel">Always full completion</span></span>: Always show <span class="quote">“<span class="quote">Full Completion</span>”</span>
</p></li></ul></div></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-keyboard-shortcuts.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="credits.html">Next</a></td></tr><tr><td class="prevCell">Customizing keyboard shortcuts </td><td class="upCell">Customizing <span class="application">KDevelop</span></td><td class="nextCell"> Credits and License</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="working-with-version-control-systems.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"><a accesskey="n" href="customizing-code-indentation.html">Next</a></td></tr><tr><td class="prevCell">Working with version control systems </td><td class="upCell"> </td><td class="nextCell"> Customizing code indentation</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME><FILENAME filename="credits.html"><html><head><title>Chapter 10. Credits and License</title><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-default.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-docs.css"><link rel="stylesheet" type="text/css" href="help:/kdoctools5-common/kde-localised.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><meta name="keywords" content="KDE, KDevelop, IDE, development, programming"><link rel="home" href="index.html" title="KDevelop Handbook"><link rel="up" href="index.html" title="KDevelop Handbook"><link rel="prev" href="customizing-code-auto-completion.html" title="Customizing code auto-completion"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="GENERATOR" content="KDE XSL Stylesheet V1.14 using libxslt"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="content"><div id="header"><div id="header_content"><div id="header_left"><div id="header_right"><img src="help:/kdoctools5-common/top-kde.jpg" width="36" height="34"> Credits and License</div></div></div></div><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-code-auto-completion.html">Prev</a></td><td class="upCell"> </td><td class="nextCell"></td></tr></table></div><div id="contentBody"><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="credits"></a>Chapter 10. Credits and License</h1></div></div></div><p>
Documentation Copyright see the UserBase
    <a class="ulink" href="https://userbase.kde.org/index.php?title=KDevelop4/Manual&amp;action=history" target="_top">KDevelop4/Manual page history</a></p><p><a name="gnu-fdl"></a>This documentation is licensed under the terms of the <a class="ulink" href="help:/kdoctools5-common/fdl-license.html" target="_top">GNU Free Documentation
License</a>.</p></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"><a accesskey="p" href="customizing-code-auto-completion.html">Prev</a></td><td class="upCell"><a accesskey="h" href="index.html">Contents</a></td><td class="nextCell"></td></tr><tr><td class="prevCell">Customizing code auto-completion </td><td class="upCell"> </td><td class="nextCell"> </td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME></div></div><div id="footer"><div class="navCenter"><table class="navigation"><tr><td class="prevCell"></td><td class="upCell"> </td><td class="nextCell"><a accesskey="n" href="what-is-kdevelop.html">Next</a></td></tr><tr><td class="prevCell"> </td><td class="upCell"> </td><td class="nextCell"> What is <span class="application">KDevelop</span>?</td></tr></table></div><div id="footer_text">Would you like to make a comment or contribute an update to this page?<br>Send feedback to the <a href="mailto:kde-doc-english@kde.org" class="footer_email">KDE Docs Team</a></div></div></div></body></html></FILENAME>

Generated by dwww version 1.15 on Fri Jun 21 07:21:25 CEST 2024.