Ned the dolphin


personalized expansion

Once expander is installed, the next step is to adjust the definition files to meet personal preferences. These include user expansion strings, coding style preferences, templates, and entire language modes. The definition files are in plain text, and have a simple format:

definition   expansion

The definition must start at the first column, and is terminated by the first whitespace character. The expansion then starts at the first non-whitespace character after the definition, and runs to the end of the line. Conventional UNIX line continuation can be used in the expansion string, but the length of the string is limited to 2550 characters. In the expansion a number of special character sequences are available:

character sequence function
|>field<| a field marker, selected when visited
|>^auto<| an auto-expand field, 'auto' is directly expanded
|>-delete<| an auto-delete field, deleted when visited
@@file a template file1)
@>ref@ a forward reference to another definition
@<ref@ a backward reference to another definition
\n a newline, autoindented to the abbreviation
\n[0-9] as \n, but indented deeper by the specified amount of indent levels
\N as \n, but indented one level deeper, equivalent to \n1
\r a newline, autoindented to the first non-whitespace
\r[0-9] as \r, but indented deeper by the specified amount of indent levels
\R as \r, but indented one level deeper, equivalent to \r1
\t, \b, \f tab, backspace, formfeed

1) the expansion string can only contain the template specification

For a simple demonstration of the possibilities, consider the case of expanding a curly brace into a code block. The definition can be specified as

{       {\R|>block<|\r}

Assuming an indent size of 4, expanding the string

if ( number > 0 ) {

(with the cursor directly after the curly brace) results in

if ( number > 0 ) {
    |>block<|
}

If \N and \n had been used in stead of \R and \r, the indent would be one level deeper than the column in which the curly brace is positioned:

if ( number > 0 ) {
                     |>block<|
                  }

Aside from expansion definitions, the files can contain some special syntax, all starting at the first column.

structure function
! comments out the rest of the line
@include file include definitions from file
@if mode
..
@fi
expansions inside are only available for the specified expander language mode
@when mode @use file shortcut notation for an @if-@include-@fi sequence

Adding an entirely new language to expander takes a few steps. The link between an NEdit language mode and an expander language name is made in the file pointed to by $EXPANDER_DIR/service. Thus, adding a new expander language starts there. The comments in the file describe the field components of a language entry and should be self-explanatory. After adding the new language entry in the service file, a set of language specific expansion definitions should be described. This can be done in the top level definitions file inside an @if clause, or in a separate file. In the latter case, expander should be instructed to load that file by adding a @when clause to the top level definitions file.

To make the circle complete, the expander package comes with an NEdit language mode for expander definitions files. There also is a macro that opens the definitions file for the appropriate language, or the top level definitions file if no language specific file is found.

Search nedit.org
Search by Google

Error: RSS file not found...
Niki - Recent changes [en]
Niki

Error: RSS file not found...
Sponsors

hosting and design by
Loco


unless otherwise stated all material is © 1999-2004 NEdit.org