Project Plugin

Introduction

The basic idea of the Project plugin is to have a structured list of files belonging to the project with the following properties:

  1. Provide a structured view of the files

  2. Make it easy and very fast to open and switch projects

  3. Support search and replace for a project

  4. Provide simple auto completion

  5. Make it simple to quickly open files in the project

  6. Support for building the project

Structured View of the Files

Once the Project plugin is loaded in the Kate configuration page, open a file in a project and a sidebar appears that lists all projects as well as the project files as follows:

As you can see, the currently active project is Kate, and its contents is listed in the tree view. Clicking on files in the tree view opens the file in the editor. Further, a context menu is provided with which you can open files with other applications, such as a .ui file with Qt Designer.

You can filter the items by typing parts of the file name you are looking for into the search bar at the bottom of the list.

Switching Projects

The idea is that you never have to open a project manually, this is even not supported at all. Hence, what happens if you open a file, the Project plugin quickly scans the folder and its parent folders for a .kateproject file. If found, the project is automatically loaded.

Furthermore, if you open another document in Kate, that belongs to another project, the Project plugin automatically switches the current project. So intuitively, always the correct project is active. Of course, you can also switch the currently active project using the combo box.

Search and Replace in Projects

Kate has a Search and Replace plugin that shows up in the bottom sidebar. If a project is loaded, open the Search and Replace sidebar, and switch to the mode to search and replace in the current project:

Simple Auto Completion

With the knowledge of all files belonging to a project, the Project plugin provides simple auto completion facilities based on CTags. If a project is initially opened, CTags parses all project files in a background thread and saves the CTags information to /tmp. This file then is used to populate the auto completion popup in Kate.

In contrast, without this auto completion, Kate is only capable of showing auto completion items based on the words in the current file. So the auto completion provided by the Project plugin is much more powerful.

If CTags is missing, a passive popup warns you about this issue. It is also noteworthy, that the CTags file in /tmp is cleaned up when Kate exits, so the plugin does not pollute any folder with unwanted files.

Quick Opening Files

As clicking on files in the tree view is not the fastest way to open a file, Kate provides a built-in quick open mechanism you can activate with Ctrl+Alt+O. What you the get is a list like this:

You can filter by typing parts of the file name you are looking for, and you can also navigate with the arrow keys and page up/down through the list. Hitting Enter activates the selected file, while Esc hides the quick open view again.

Further, the quick open remembers the previous file. So when you change to the quick open view the previously activated file is automatically selected and you just need to hit Enter, which comes very handy at times.

Support for Building the Project

Another feature is to have support for the Build Plugin, so that it automatically is configured correctly.

Creating Projects

Loading Projects Automatically

The Project plugin has an auto-loading feature. You can read the file list from the version control system. To this end, auto-loading for the respective version control system needs to be enabled in the settings (enabled by default):

Creating Projects Manually

You just have to create a .kateproject file in the root folder of the project. For instance, the Kate .kateproject file looks like this:

{
  "name": "Kate"
, "files": [ { "git": 1 } ]
}

The file content is written in JSON syntax. The project name is Kate, and the files contained in should be read from git.

Also supported instead of git is subversion through svn and mercurial through hg. If you do not want to read from a version control system, you can tell it to recursively load files from directories as follows:

{
  "name": "Kate"
, "files": [ { "directory": "kate", "filters": ["*.cpp", "*.h", "*.ui", "CMakeLists.txt", "Find*.cmake"], "recursive": 1 } ]
}

Here, subfolders and filters define what’s part of the project. You can also mix version control and files based on filters.

If you want to add support for the Build plugin, you could write a .kateproject like this:

{
  "name": "Kate"
, "files": [ { "git": 1 } ]
, "build": {
    "directory": "build"
  , "build": "make all"
  , "clean": "make clean"
  , "install": "make install"
  }
}

Current Project

Using ProjectsGo To (Alt+1) you can open the Current Project view at the bottom of the editor window with four tabs:

Terminal

A Terminal emulator starting in the root folder of the project.

Code Index

Entering characters into the search bar will start the search and display matching names of functions, classes, symbols etc. together with kind, filename and line number.

Select an item in the list to jump to the corresponding line in the source file.

Code Analysis

Click Start Analysis to run a static code analysis for the C and C++ using cppcheck and to generate a report showing filename, line number, severity (style, warning etc.) and the issue found.

Select an item in the list to jump to the corresponding line in the source file.

Notes

Text entered in this tab will be saved in the file projectname.kateproject.notes.

The Projects Menu

The Projects menu allows you to switch between currently open projects. It is displayed by the Project plugin.

ProjectsBack (Ctrl+Alt+Left)

Switch to the previous project.

ProjectsForward (Ctrl+Alt+Right)

Switch to the next project.

ProjectsGo To (Alt+1)

Open the Current Project view at the bottom of the editor window.