The PSPad Language System Demystified

(so you don't have to search everywhere on the pspad site or in the forums for this information, which is scattered in many different places, or bug Jan Fiala with stupid questions about this subject. All pertinent information about language support for PSPad is in one place - here! )

PSPad's language support system consists of 4 major components:

  • Context clip definition .DEF files in the Context folder
  • User Highlighter definition .INI files in the Syntax folder
  • New file template Default.[fileExtension] files in the Template folder
  • Language compiler settings and supported parameters

Context clip definition files

What are clips?

This is PSPad's crude attempt at implementing real Intellisense. You invoke it by Pressing Shf-Ctrl-Space. Every clip consists of a name, a description and statement or parameter syntax. The name and description is displayed in the clip list that pops up when you invoke it. Choose a line, press Enter, and the selected clip's content is inserted at the cursor position. The content of a clip can be an unlimited number of lines and the structure of the clip in the definition is kept when it is inserted into your file.

Note: If you upgrade PSPad via the installer instead of manually via the zipfile, the .DEF files are usually reinstalled with each new STABLE version of PSPad, so if you edit them you should ensure that you have copies before upgrading.

Clip Definition File Format

.DEF file syntax: [name |x description]*shortcut. Lines beginning with a semicolon (;) are comments and are ignored.

  • [ - This a required character.
  • name - This is the name of the clip that will appear in the clip list and will appear in a bold font.
  • | - This is a required character that separates the clip name from the description.
  • X - This (optional) character sets the colour that the clip entry will appear as in the list.
    Choose one of:
    • M - Maroon
    • R - Red
    • N - Navy
    • B - Blue
    • P - Purple
    • F - Fuchsia
    • G - Green
    • D - Dark gray
  • * - This character is optional and is only required if a shortcut or hotkey is to be defined for the clip.
  • Shortcut - This entry is only required if a shortcut or hotkey is defined. If multiple keys are required for the hotkey then they should be key1+key2. (See Keyboard commands)

The clip content starts on the line immediately after the definition and continues until the start of the next definition or the end of the file.

The content is entered into your file exactly as it is entered here. There are 2 special characters that you can use in your content; | and § (ALT+167). When your clip is used the cursor will be placed at the position occupied by the | character. If you include this character more than once in your clip content then only the first position will be used. If you have any text highlighted in your file when you call the clip and the clip's content includes the § character then that character will replace the selected text. You can use the § character multiple times; each occurrence will be replaced with the selected text in your file.

You can add comments to the clip definition by starting the line with a semicolon ;. If your clip content needs to include a line that starts with a colon, enter two colons ;;.

Note: You cannot have a line in your clip content that starts with the open square bracket, [ character as this marks the beginning of the next clip definition.

Example:

[Alert Alert]*Ctrl+Alt+A|
alert("§|");


User Highlighter definition files

What are User Highlighters?

User highlighter .INI files implement PSPad's syntax highlighting. When you finish typing a language keyword, for example, PSPad will let you know that you spelled it correctly by coloring the word.

User Highlighter file format

;PSPad user highLighter definition file. Uncommented entries mean they are obvious or undocumented
[Settings]
Name=VBscript.NET
HTMLGroup=0
Label=1
FileType=*.dsh
CommentString='
; list of allowed comment delimiters
SlashComment=1
REMComment=1
Preprocessors=1
IndentChar=
UnIndentChar=
TabWidth=2
DoubleQuote=1
EscString=1
EscChar=\
KeyWordChars=
; last 3 characters are the file extension
CodeExplorer=ftDSH
DocComment=

; You must include the equals sign (=) at the end of each word
[KeyWords]
AddHandler=
AddressOf=
Alias=
And=
AndAlso=
Ansi=
As=
Assembly=
Auto=
Binary=
ByRef=
ByVal=
Call=
Case=
Catch=

[....]

[ReservedWords]
Array=
ArrayList=
BaseDataList=
Boolean=

Template files

These are just plain text files having code in them that PSPad will load up at language start. If you always use a custom code block as a skeleton for all your scripts or projects for a language, place it in one of these. Their name is always the word Default, and their extension is the extension for code files for the language. For example, a powershell script template file would be:  Default.ps1

Language Compiler Settings in the PSPAD.INI File and Supported Compiler Parameters

Settings for the compiler (or interpreter) for your language are kept in sections in the main PSPAD.INI file. An example section is shown below.

; Comments are ignored. Uncommented lines are either obvious or undocumented.

[Windows Shell Script]

Filter=Windows shell script (*.cmd;*.bat;*.nt)|*.cmd;*.bat;*.nt

; these 2 lines mean indent with 2 spaces
HLTabWidth=2
HLRealTabs=0

RightEdge=0
IndentChar= 
UnIndentChar= 
DocComment=

; the full path of the compiler executable
Compilator File=cmd.exe

; compiler parameters. These can get tricky to get right. See below for a complete list of them.
Compilator Param=| /c %File%|
Compilator LOG=
Compilator Run=
Compilator Help=
Compilator SaveAll=0
Compilator ParsLog=

; set to 1 to get the STDOUT of the compiler
Compilator Capture=1

Compilator HideOutput=0

; set to 1 so save all files before compiling
Compilator ProgSaveAll=1

Compilator DefaultDir=

[...]

List of Supported Compiler Parameters


%File%

Full path name, including drive specifier, of current file.

Example:
C:\MyProg.exe "%File%"

Becomes:
C:\MyProg.exe "C:\Documents and Settings\user\This File.txt"

Note: The quotation marks around the variable name are required if the path name includes spaces.

%Dir%

Full path, including drive specifier, of directory in which current file is saved.

Example:
C:\MyProg.exe -o "%Dir%" ...

Becomes:
C:\MyProg.exe -o "C:\Documents and Settings\user\"

Note: The quotation marks around the variable name are required if path name includes spaces. Also note that the %Dir% variable includes the trailing slash (\).

%DosFile%

Short path name, including drive specifier, of current file.

Example:
C:\MyProg.exe "%File%"

Becomes:
C:\MyProg.exe "C:\DOCUME~1\user\MYDOCU~1\ThisFi~1.txt"

Note: The quotation marks around the variable name are required if the path name includes spaces.

%DosDir%

Full short< path, including drive specifier, of directory in which current file is saved.

Example:
C:\MyProg.exe -o "%Dir%" ...

Becomes:
C:\MyProg.exe -o "C:\DOCUME~1\user\MYDOCU~1\"

Note: The quotation marks around the variable name are required if the path name includes spaces. Also note that the %Dir% variable includes the trailing slash (\).

%Name%

Name, without extension, of current file.

Example:
C:\MyProg.exe "%Name%"

Becomes:
C:\MyProg.exe "This File"

Note: The quotation marks around the variable name are required if file name includes spaces.

%Ext%

Extension of current file name.

Example:
C:\MyProg.exe -e %Ext%

Becomes:
C:\MyProg.exe -e .txt

Note: Extension includes preceding perid (.).

%Project%

Current project name.

Example:
C:\MyProg.exe -p "%Project%"

Becomes:
C:\MyProg.exe -p "New Project"


%ProjectDir%

Current project file path.

Example:
C:\MyProg.exe -p "%ProjectDir%"

Becomes:
C:\MyProg.exe -p "c:\projectfile.ppr"


%PSPath%

PSPad application path.

Example:
C:\MyProg.exe -p "%PSPath%"

Becomes:
C:\MyProg.exe -p "C:\Program Files\PSPad\"

Note: Path includes trailing slash (/).

%URLFile%

Full path name, including drive specifier, of current file preceded by "file://localhost/"

Example:
C:\MyProg.exe "%URLFile%"

Becomes:
C:\MyProg.exe "file://localhost/C:/Documents and Settings/user/This File.txt"

Note: The quotation marks around the variable name are required if the path name includes spaces.

%HttpFile%

Full path name, including drive specifier, of current file preceded by "http://localhost/"

Example:
C:\MyProg.exe "%HttpFile%"

Becomes:
C:\MyProg.exe "http://localhost/C:/Documents and Settings/user/This File.txt"

Note: The quotation marks around the variable name are required if the path name includes spaces.

%PHPFile%

If start of path of current file matches value of setting in "Settings > Program Settings > Internet > Document Root" then the variable will be replaced with the value "http://localhost/" + the path relative to Document Root. Otherwise variable equates to %File%.

Example:
Assume the Document Root is set to "C:\Inetpub\wwwroot" and the current file path is "C:\Inetpub\wwwroot\test.htm" C:\MyProg.exe "%PHPFile%"

Becomes:
C:\MyProg.exe "http://localhost/MySite/text.htm"

Note: The quotation marks around the variable name are required if the path name includes spaces.

%SelText%

Currently selected text.


%Input%

Prompt user to enter value.

Note: If "Cancel" is pressed when prompt is displayed, command will not be run. To run command with no value, delete any text in prompt's input box and press "OK"

%Word%

Word at current cursor position.


%Line%

Line number of current cursor position.


%AppData%

Path where applications store data by default.


%HomePath%

Path to the user's home directory.

Example:
C:\MyProg.exe -p "%HomePath%"

Becomes:
C:\MyProg.exe -p "\Documents and Settings\UserName"

Note: Path excludes drive (C:) and trailing slash (/).

%Temp%

Default temporary directory used by applications for current user.

Example:
C:\MyProg.exe -p "%Temp%"

Becomes:
C:\MyProg.exe -p "C:\DOCUME~1\UserName\LOCALS~1\Temp"

Note: Path is short and usualy excludes trailing slash (/).

%UserProfile%

Path of profile for current user.

Example:
C:\MyProg.exe -p "%UserProfile%"

Becomes:
C:\MyProg.exe -p "C:\Documents and Settings\UserName"

Note: Path excludes trailing slash (/).

%WinDir%

Path of operating system directory.

Example:
C:\MyProg.exe -p "%WinDir%"

Becomes:
C:\MyProg.exe -p "C:\WINDOWS"

Note: Path excludes trailing slash (/).