Configuring Komodo Edit

Last updated on
30 September 2016

Komodo Edit is a free, open source editor and cross-platform.

There a few things you can change in Komodo Edit to keep you Drupal coding clean. First you can enable the syntax checking for both PHP and Drupal. Second is configuring Komodo Edit so that it's inline with the code standards.

Code Intelligence / Completions and Syntax checking

If you want to enable syntax checking and auto-completion for standard PHP and Drupal functions in Komodo Edit, here's what to do:

First you need to download and install PHP on your local machine (if you haven't). Make sure to install the same version that you run on your server.
Then, download the version of Drupal that you're using on your site(s) - or if you keep mirror copies of all your Drupal sites on your local machine already, then you could use those instead and pick up all the available functions.

Launch Komodo Edit and go to the preferences of the PHP language (Edit > Preferences > Languages > PHP) or click on "Check Configuration" (Help > Check Configuration). This will open a screen, click on the config icon on the same line as PHP.

Go into Configure PHP, and you'll want to add the Drupal directory or your site directories under "PHP directories". I only added Drupal 7 because that's the version I'm working with the most.

You can also create a Komodo project in your Drupal projects root directory (Project > New Project). Once the project has been created Komodo will scan your Drupal source to populate it's code intelligence database without having to add PHP Directories in your preferences. The Komodo project file allows for other helpful features such as project specific coding standards (see below) where you can configure special indenting and file saving preferences for a specific Drupal project (Drupal 6 settings and Drupal 8 settings perhaps).

After you've set everything right, restart Komodo Edit and click on the "Help > Check Configuration". The PHP line should read "PHP Syntax Checking:Ready".

That's it - Komodo Edit will check your syntax and recommend/auto-complete for all php and Drupal functions as you type.

Coding standards

There are a ton of things you'll have to keep in mind to keep your code to the standards of Drupal. Some of the standards can be met by configuring Komodo Edit.

The default way of coding with Drupal is using 2 spaces, not using comments longer that 80 chars and don't leave unnecessary spaces in the file. Those are the settings that will be explained here.

2 spaces

Open the Preferences window (Edit > Preferences). Search for 'Indentation'. Here you can set the default spacing. Set both values to 2. Be sure that both values are also 2 for the PHP language in the drop down.

80 chars comments

Komodo Edit is not able to limit the comment length but it can set a line on the 80th char. Search in the Preferences window for 'Smart Editing'. Here you'll see the option for 'Draw the edge line column'. Be sure that it's checked and that the value is set to 80.

Remove spaces

Komodo Edit can remove unused white spaces. Again open the Preferences window. Search for 'Save Options'. The option 'Clean trailing white spaces ... ' should be checked.

Drupal for Komodo

Be sure to check out the Drupal for Komodo module. This will make it much easier to create new modules. Half of the code is already in Komodo when you start with module development.