现在的位置: 首页 > 综合 > 正文

EditPlus自定义stx语法文件说明(中英文)

2013年05月22日 ⁄ 综合 ⁄ 共 5855字 ⁄ 字号 评论关闭

1、中文版

语法高亮

EditPlus 支持强大的、可自定义的语法高亮功能,内置了 HTML, CSS, PHP, ASP, Perl, C/C++, Java, JavaScript, VBScript 的语法文件,你也可以创建自己的语法文件来支持其它设计语言。

要支持自己的语法类型,你必须创建一个语法文件并把它添加到“参数选择”对话框中的“设置与语法”中。

语法文件是一个扩展名为“.stx”并按预定格式编写的纯文本文件,这种格式非常简单。建议查看用于 JavaScript 的语法文件(js.stx),以它为例来学习创建这种语法文件。
头部信息 Header Information#TITLE=C/C++
#DELIMITER=,()}[]-+*%/="'~!&|/<>?:;.
#QUOTATION1='
#QUOTATION2="
#CONTINUE_QUOTE=n
#LINECOMMENT=//
#LINECOMMENT2=
#COMMENTON=/*
#COMMENTOFF=*/
#COMMENTON2=
#COMMENTOFF2=
#ESCAPE=/
#CASE=y
#PREFIX1=
#PREFIX2=
#PREFIX3=
#PREFIX4=
#PREFIX5=
#SUFFIX1=
#SUFFIX2=
#SUFFIX3=
#SUFFIX4=
#SUFFIX5=
#HTML_EMBEDDED=
#SCRIPT_BEGIN=
#SCRIPT_END=
#HEREDOC=
#AUTOCASE=
#NUMBER_PATTERN=cpp
#SPECIAL_STX=cpp

所有语法声明必须以“#”为前缀,具体解释如下:

#TITLE
    这里定义语法文件标题,它必须出现在语法文件的首行,否则 EditPlus 将不能正确读取它的信息。
#DELIMITER
    指定用于分解关键字的定界符。你不必指定空格和制表符,它们是程序内置的缺省定界符。
#QUOTATION1
    指定引用语标记,例如单引号,这里只能定义一个字符。
#QUOTATION2
    指定另一种引用语标记,例如双引号,这里只能定义一个字符。
#CONTINUE_QUOTE
    这个选项允许不停止引用而将它延续到下一行。定义为“y”时允许跨行引用,定义为“n”时不允许跨行引用,“n”是默认值。
#LINECOMMENT
    指定行内注释标记。如果你以“!”作为行内注释符的前缀,那么仅在它位于行首时才会起作用。
#LINECOMMENT2
    指定另一种行内注释标记。如果你以“!”作为行内注释符的前缀,那么仅在它位于行首时才会起作用。
#COMMENTON
    指定一个块级注释的启始标记。
#COMMENTOFF
    指定一个块级注释的结束标记。
#COMMENTON2
    指定另一种块级注释的启始标记。
#COMMENTOFF2
    指定另一种块级注释的结束标记。
#ESCAPE
    指定避让字符,这里只能定义一个字符。
#CASE
    指定敏感性。取值为“n”或“n” 默认值为“n”。
#PREFIX1 - #PREFIX5
    指定前缀关键字,任何跟随前缀的单词将被视为已经处理的关键字。
#SUFFIX1 - #SUFFIX5
    指定后缀关键字,任何在后缀之前的单词将被视为已经处理的关键字。
#HTML_EMBEDDED
    如果是像 PHP 这样的 HTML 植入脚本,指定为“y”。可以参考“php.stx”中的用法。
#SCRIPT_BEGIN
    指定 HTML 植入脚本的启始标记,仅在“#HTML_EMBEDDED”定义为“y”时发生作用,请参考“php.stx”中的用法。
#SCRIPT_END
    指定 HTML 植入脚本的结束标记,仅在“#HTML_EMBEDDED”定义为“y”时发生作用,请参考“php.stx”中的用法。
#HEREDOC
    指定一个字符串用于 Perl和 PHP 文件中的 heredoc。例如:#HEREDOC=<<EOF.
#AUTOCASE
    如果希望使用关键字自动完成特性,将它定义为“y”。
#NUMBER_PATTERN
    'cpp'用于 C/C++数字语法高亮。
#SPECIAL_STX
    “html”用于 HTML 语法文件,“cpp”用于 C/C++ 语法文件,“perl”用于 Perl 语法文件,留空则可用于其它语法文件。

同其它语言一样,你也可以在语法文件中插入注释,注释行必须以英文的分号“;”启始。如果你希望指定英文分号作为一个关键字,必须以避让字符“^”作为它的前缀。
关键字组 Keyword groups#KEYWORD=Reserved words
abstract
boolean
break
#KEYWORD=Compiler directives
...

每个关键字组以#KEYWORD=启始,之后定义该组的描述。关键字清单从下一行开始,如果需要在关键字里包含“#”,必须以避让字符“^”为前缀,像 “^#”这样。在这种情况下,“#”标记不应该包含在“#DELIMITER”定义中。你最多可以定义 10 个关键字组。

用户文件保存机制

在 EditPlus 网站的用户文件页面上有一个用户文件(stx、ctl、acp 文件)集合。若您愿意与其他用户分享您的文件,您可以提交您自己的语法文件到<submit@editplus.com>。

 

1、英文版

Syntax Highlighting

EditPlus supports powerful and customizable syntax highlighting for HTML, CSS, PHP, ASP, Perl, C/C++, Java, JavaScript and VBScript by default. Also, you can create your own syntax file to support other programming languages.

In order to add your own syntax type, you must create a syntax file and add it on Settings & Syntax page of the Preferences dialog box.

Syntax file is a plain text file which has ".STX" extension and should be written in predefined format. The format is very simple. The fastest way is to look into the sample .STX file such as JS.STX for JavaScript files (*.JS).

#TITLE=

C/C++
#DELIMITER=

,()}[]-+*%/="'~!&|/<>?:;.
#QUOTATION1=

'
#QUOTATION2=

"
#CONTINUE_QUOTE=

n
#LINECOMMENT=

//
#LINECOMMENT2=

#COMMENTON=

/*
#COMMENTOFF=

*/
#COMMENTON2=

#COMMENTOFF2=

#ESCAPE=

/
#CASE=

y
#PREFIX1=

#PREFIX2=

#PREFIX3=

#PREFIX4=

#PREFIX5=

#SUFFIX1=

#SUFFIX2=

#SUFFIX3=

#SUFFIX4=

#SUFFIX5=

#HTML_EMBEDDED=

#SCRIPT_BEGIN=

#SCRIPT_END=

#HEREDOC=

#AUTOCASE=

#NUMBER_PATTERN=

cpp
#SPECIAL_STX=

cpp

All statements must be prefixed with '#

' sign.

#TITLE

    The title of syntax file. It should be located at the first line of the file. Otherwise, EditPlus cannot load it.

#DELIMITER

    Specify delimiters for parsing keywords. You don't need to specify the space character and the tab character here, since those are treated as delimiter by default.

#QUOTATION1

    Specify quotation mark. Enter only one character.

#QUOTATION2

    Specify alternate quotation mark. Enter only one character.

#CONTINUE_QUOTE

    This option allows un-terminated quotation to be continued to next line. 'y' for yes and 'n' for no. 'n' is default value.

#LINECOMMENT

    Specify a string which turns on line comment. If you prefix ^! to the line comment string, it works only when located at the beginning of line.

#LINECOMMENT2

    Specify a string which turns on line comment 2. If you prefix ^! to the line comment string, it works only when located at the beginning of line.

#COMMENTON

    Specify a string which turns on block comment.

#COMMENTOFF

    Specify a string which turns off block comment.

#COMMENTON2

    Specify a string which turns on block comment 2.

#COMMENTOFF2

    Specify a string which turns off block comment 2.

#ESCAPE

    Specify escape character. Enter only one character here.

#CASE

    Specify case sensitivity. 'y' for yes and 'n' for no. Default value is 'n'.

#PREFIX1 - #PREFIX5

    Specify keyword prefix character. Any word that follows the prefix will be treated as a keyword.

#SUFFIX1 - #SUFFIX5

    Specify keyword suffix character. Any word that precedes the suffix will be treated as a keyword.

#HTML_EMBEDDED

    Specify 'y' if it is HTML-embedded script such as PHP. See 'PHP.STX' for an example.

#SCRIPT_BEGIN

    Specify the string which turns on HTML-embedded script. Valid only if #HTML_EMBEDDED is 'y'. See 'PHP.STX' for an example.

#SCRIPT_END

    Specify the string which turns off HTML-embedded script. Valid only if #HTML_EMBEDDED is 'y'. See 'PHP.STX' for an example.

#HEREDOC

    Specify a string for heredoc in Perl and PHP files. For example, #HEREDOC=<<EOF.

#AUTOCASE

    Specify 'y' if you would like to use the automatic keyword case correction feature.

#NUMBER_PATTERN

    'cpp' for C/C++ number syntax highlighting.

#SPECIAL_STX

    'html' for HTML sytax file, 'cpp' for C/C++ syntax file, and 'perl' for Perl syntax file. Leave blank for all other syntax files.

    You can also insert comment line in syntax file. Comment line must begin with semicolon(;). If you need to add a keyword which begins with semicolon, you must prefix an escape character '^' to it.

    Keyword groups

    #KEYWORD=

Reserved words

    abstract
    boolean
    break

    #KEYWORD=

Compiler directives

    ...

    Each keyword group begins with #KEYWORD

statement with optional description of the group. Keyword list follows from the next line. If you need to include '#' sign into a keyword, you must prefix an escape character '^' to it like this: '^#'. In this case, the '#' sign should not be included in #DELIMITER statement. You can specify up to 10 keyword groups.

    User files repository

    EditPlus web site has a collection of user files (stx, ctl, acp files) on User Files page

. You can submit your own syntax file to <submit@editplus.com

> if you would like to share your file with other users.

 

抱歉!评论已关闭.