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.

comment_use_indent=true

#### [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
--- | --- | ---

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
current_line | The style for colouring the background of the current line. Only the second argument is interpreted. | current_line=0x0;0xe5e5e5;false;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 colours or to use the colours defined by each filetype for the white space. | white_space=0xc0c0c0;0xffffff;true;false

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