fte allows each file extension to have a different editing mode. Mode is a collection of editor settings such as keybindings, tab settings, autoindent settings, syntax highlighting,...

Syntax of mode command is

    mode NAME { mode settings }
    mode NAME: PARENT { mode settings }

Mode with name NAMEinherits settings from mode PARENT if parent mode is specified at mode declaration.

When editor is searching for a mode to use for a file it will first check if the mode has been overriden by a FileOpenInMode command or a command line option (-m).

Then it will check if the file name matches FileNameRx defined in mode declarations.

If the mode has still not been found, it will read the first line (max 80 chars) of the file, and attempt to match the FirstLineRx with the first line.

If this fails, the editor will use mode specified by DefaultModeName global setting to load a file. If that mode does not exist, first mode defined in the configuration file will be used.

## Mode Settings

The following settings can be specified for each mode:

### ExpandTabs

{0,1}

Should be set to 1 if tabs are to be expanded when displayed. Use ToggleExpandTabs command to toggle during editing.

### TabSize

{1-32}

Tab size when tabs are shown expanded on display.

### AutoIndent

{0,1}

Should be set to 1 if autoindent is to be used. Use ToggleAutoIndent command to toggle it on/off during editing.

### Insert

{0,1}

If set to 1, Insert mode is active by default. If set to 0, Overwrite mode is active by default.

Use ToggleInsert command to toggle it on/off during editing.

### StripChar

{ASCII code/-1}

This characted will be stripped if it is found the end of any line when the file is being loaded. If it is set to -1, no characted will be stripped.

Usually used to strip 13 (CR) characters from DOS text files.

### LineChar

{ASCII code/-1}

This character is used as a line separator when loading a file. If set to -1, there is no line separator. (WARNING: File will be loaded as one line if LineChar is set to -1).

Usually set to 10 (LF) as standard text file line separator.

### AddCR

{0,1}

If set to 1, CR (13, \r) character will be added to end of line when saving.

### AddLF

{0,1}

If set to 1, LF (10, \n) characted will be added to end if line when saving.

### ForceNewLine

{0,1}

Normally, when saving, the last line is saved without any CR/LF characters. This setting will override that behaviour.

### Hilit

{0,1}

If set to 1, syntax highliting will be active.

### ShowTabs

{0,1}

If set to 1, tabs will be visible as circles (EPM-like).

### IndentMode

{PLAIN,C,REXX}

Activates the specified smart indent mode. (PLAIN mode specifies no smart audoindenting, just normal autoindent).

### Colorizer

Specifies a previously declared colorize mode to use for syntax highlighting in this editing mode.

### EventMap

Specify the name of existing eventmap to use for current mode.

### UndoLimit

{Number}

Limit undo to this many recent commands (-1 = unlimited)

### UndoMoves

{0,1}

If set to 1, all cursor movements will be recorded on undo stack.

### KeepBackups

{0,1}

If set to 0, backup files will be deleted after a successful save operation.

### MatchCase

{0,1}

If set to 0, searches will be case insensitive. This can be toggled via ToggleMatchCase command when editor is running.

### BackSpKillTab

{0,1}

If set to 1, BackSpace will kill entire tabs instead of converting them to spaces.

### DeleteKillTab

{0,1}

If set to 1, Delete will kill entire tabs instead of converting them to spaces.

### BackSpUnindents

{0,1}

If set to 1, BackSpace will unindent to previous indentation level if issued on beginning of line.

### SpaceTabs

{0,1}

If set to 1, InsertTab command will insert spaces instead of tabs.

### IndentWithTabs

{0,1}

If set to 1, indentation will be done using tabs instead of spaces.

### WordWrap

{0,1,2}

If set to 1, editor wrap current line when right margin is reached. If set to 2, editor will wrap current paragraph continously. Paragraphs as recognised by WrapPara command must be separated by blank lines.

### LeftMargin

{1-xx}

Left margin for word wrap (WrapPara command).

### RightMargin

{1-xx}

Right margin for word wrap (WrapPara command).

### Trim

{0,1}

If set to 1, spaces on the end of line will be trimmed when editing.

### ShowMarkers

{0,1}

If set to 1, end of line and end of file markers will be shown.

### CursorTroughTabs

{0,1}

If set to 1, editor will allow cursor to be positioned inside tabs.

### DefFindOpt

'options'

Default search options for Find command.

### DefFindReplaceOpt

'options'

Default search/replace options for FindReplace command.

### SaveFolds

{0,1,2}

If 0, folds are not saved. If 1, folds are saved at beginning of line, if 2 folds are saved at end of line.

Folds are saved as comments in source files, depending on active editing mode.

See mode settings CommentStart and CommentEnd for configuration of fold comments.

### CommentStart

"comment-start-string"

String that starts comments (for saving folds)

### CommentEnd

"comment-end-string"

String that ends comments

### AutoHilitParen

{0,1}

If set to 1, editor will automatically highlight the matching bracket if it is visible on screen. This is equivalent to executing HilitMatchBracket command.

### Abbreviations

{0,1}

If set to 1, abbreviation expansion will be active in this mode.

### BackSpKillBlock

{0,1}

If set to 1, BackSpace command will delete block if it is marked, otherwise it will delete the previous character.

### DeleteKillBlock

{0,1}

If set to 1, Delete command will delete block if marked, instead of deleting the character below cursor.

### PersistentBlocks

{0,1}

If set to 1, blocks will stay marked even if cursor is moved in the file, if set to 0, block is unmarked as soon as the cursor is moved.

### InsertKillBlock

{0,1}

If set to 1, the marked block is deleted when a new character is typed.

### FileNameRx

"regexp"

Must be set to regexp that matches names of files that should be edited in this mode. Has priority over FirstLineRx

### FirstLineRx

"regexp"

Must be set to regex that matches the first line of files that should be edited in this mode. This is checked only if no FileNameRx matches the filename.

### RoutineRegexp

"regexp"

Regular expression that matches function header.

Used by editor commands: ListRoutines, MoveFunctionPrev, MoveFunctionNext, BlockMarkFunction, IndentFunction.

## Loading files in various formats

Here are settings for loading files in various formats:

DOS/Win/OS2/NT text files (CR/LF delimited):

                StripChar      13
                LineChar       10
                AddCR          1
                AddLF          1

Unix text files (LF delimited):

                StripChar      -1
                LineChar       10
                AddCR          0
                AddLF          1

MAC text files (CR delimited):

                StripChar      -1
                LineChar       13
                AddCR          1
                AddLF          0

Binary files (fixed record length):

                StripChar      -1
                LineChar       -1
                AddCR          0
                AddLF          0
                LoadMargin     64
                ForceNewLine   0

## Configuration of Tab options