Chapter 4. Configuration files
Prev |  | Next

## Chapter 4. Configuration files

## Filetype definition files

All colour definitions and other filetype specific settings are stored in the filetype definition files. Those settings are colours for syntax highlighting, general settings like comment characters or word delimiter characters as well as compiler and linker settings.

The system-wide configuration files can be found in `$prefix/share/geany` and are called `filetypes.$ext`, where $prefix is the path where Geany is installed (commonly `/usr/local`) and $ext is the name of the filetype. For every filetype there is a corresponding definition file. There is one exception: `filetypes.common` - this file is for general settings, which are not specific to a certain filetype. It is not recommended to edit the system-wide files, because they will be overridden when Geany is updated.

To change the settings, copy a file from `$prefix/share/geany` to the subdirectory `filedefs` in your configuration directory (usually `~/.geany/`).

For example:

    % cp /usr/local/share/geany/filetypes.c /home/username/.geany/filedefs/

Then you can edit the file and the changes are also available after an update of Geany because they reside in your configuration directory. Alternatively, you can create a file `~/.geany/filedefs/filetypes.X` and add only these settings you want to change. All missing settings will be read from the corresponding global definition file in `$prefix/share/geany`.

### Format

#### [styling] Section

In this section the colours for syntax highlighting are defined. The format is always: `key=forground_colour;background_colour;bold;italic`

Colours have to be specified as RGB hex values prefixed by 0x. For example red is 0xff0000, blue is 0x0000ff. The values are case-insensitive, but it is a good idea to use small letters. Bold and italic are flags and should only be "true" or "false". If their value is something other than "true" or "false", "false" is assumed.

#### [keywords] Section

This section contains keys for different keyword lists specific to the filetype. Some filetypes do not support keywords, so adding a new key will not work. You can only add or remove keywords to/from an existing list.

### Important

The keywords list must be in one line without line ending characters.

#### [settings] Section

Table 4.1. General settings

Key | Description | Example
--- | --- | ---
wordchars | These characters define word boundaries when making selections and searching using word matching options. | (look at system filetypes.* files)
comment_open | A character or string which is used to comment code. If you want to use multiline comments, also set comment_close, otherwise leave it empty. | comment_open=/*
comment_close | If multiline comments are used, this is the character or string to close the comment. | comment_close=*/

comment_use_indent

Set this to false if a comment character or string should start at column 0 of a line. If set to true it uses any indentation of the line.

Example 4.1. Comment indentation

comment_use_indent=true would generate this if a line is commented (e.g. with Ctrl-D)

    	#command_example();

comment_use_indent=false would generate this if a line is commented (e.g. with Ctrl-D)

    #	command_example();

### Note

This setting only works for single line comments (like '//', '#' or ';').

comment_use_indent=true

context_action_cmd

A command which can be executed on a certain word or the current selection. Example usage: Open the API documentation for the current function call at the cursor position. The command can be set for every filetype or if not set, a global command will be used. The command itself can be specified without the full path, then it is searched in $PATH. But for security reasons, it is recommended to specify the full path to the command. The wildcard %s will be replaced by the current word at the cursor position or by the current selection.

Hint: for PHP files the following could be quite useful: context_action_cmd=firefox "http://www.php.net/%s"

context_action_cmd=devhelp -s "%s"

#### [build_settings] Section

Table 4.2. Build settings

Key | Description | Example
--- | --- | ---

compiler

This item specifies the command to compile source code files. But it is also possible to use it with interpreted languages like Perl or Python. With these filetypes you can use this option as a kind of syntax parser, which sends output to the compiler message window.

You should quote the filename to also support filenames with spaces. The following wildcards for filenames are available:

- %f - complete filename without path

- %e - filename without path and without extension

compiler=gcc -Wall -c "%f"

linker | This item specifies the command to link the file. If the file is not already compiled, it will be compiled while linking. The -o option is automatically added by Geany. This item works well with GNU gcc, but may be problematic with other compilers (esp. with the linker). | linker=gcc -Wall "%f"
run_cmd | Use this item to execute your file. It has to have been built already. Use the %e wildcard to have only the name of the executable (i.e. without extension) or use the %f wildcard if you need the complete filename, e.g. for shell scripts. | run_cmd="./%e"

### Special file filetypes.common

There is a special filetype definition file called `filetypes.common`. This file defines some general non-filetype-specific settings.

Table 4.3. General settings

Key | Description | Example
--- | --- | ---
default | This is the default style. It is used for styling files without a filetype set. | default=0x000000;0xffffff;false;false

selection

The style for colouring selected text. The format is:

- Foreground colour

- Background colour

- Use foreground colour

- Use background colour

The colours are only set if the 3rd or 4th argument is true. When the colours are not overridden, the default is a dark grey background with syntax highlighted foreground text.

selection=0xc0c0c0;0x00007F;true;true

brace_good | The style for brace highlighting when a matching brace was found. | brace_good=0xff0000;0xFFFFFF;true;false
brace_bad | The style for brace highlighting when no matching brace was found. | brace_bad=0x0000ff;0xFFFFFF;true;false
caret | The style for colouring the caret(the blinking cursor). Only the first argument is interpreted. | caret=0x000000;0x0;false;false
caret_width | The width for the caret(the blinking cursor). Only the first argument is interpreted. The width is specified in pixels with a maximum of three pixel. Use the width 0 to make the caret invisible. | caret=1;0;false;false
current_line | The style for colouring the background of the current line. Only the second and third arguments are interpreted. The second argument is the background colour. Use the third argument to enable or disable background highlighting for the current line (has to be true/false). | current_line=0x0;0xe5e5e5;true;false
indent_guide | The style for colouring the indentation guides. Only the first and second arguments are interpreted. | indent_guide=0xc0c0c0;0xffffff;false;false
white_space | The style for colouring the white space if it is shown. The first both arguments define the foreground and background colours, the third argument sets whether to use the defined foreground colour or to use the colour defined by each filetype for the white space. The fourth argument defines whether to use the background colour. | white_space=0xc0c0c0;0xffffff;true;true

folding_style

The style of folding icons. Only first and second arguments are used.

Valid values for the first argument are:

- 1 - for boxes

- 2 - for circles

Valid values for the second argument are:

- 1 - for straight lines

- 2 - for curved lines

folding_style=1;1;false;false

folding_horiz_line

Draw a thin horizontal line at the line where text is folded. Only first argument is used.

Valid values for the first argument are:

- 0 - disable, do not draw a line

- 1 - draw the line above folded text

- 2 - draw the line below folded text

folding_horiz_line=0;0;false;false

invert_all | Whether to invert all defined colours. This is useful if you like a dark background colour(e.g. black) and do not want to change every single line. Please note, at time of writing this was only tested with the C syntax highlighting. Only first argument is interpreted. Set it to 1 to invert all colours. | invert_all=0;0;false;false

Prev |  | Next
Keybindings | Home | Filetype extensions