PL/SQL Syntax Highlighting in Textpad

PL/SQL Syntax Highlighting in Textpad – for when you can’t play with Penguins

When I’m mucking around at home, it’s Linux all the way. Unfortunately, at work ( in desktop terms, at least) I’m still stuck with being a Microsofty.

This leaves me with Textpad as my program editor of choice.

As promised then, here’s the quick and dirty guide to enabling syntax highlighting for PL/SQL in Textpad ( works for versions 4 and 5) …

Step 1 – write a syntax definition file

This file is split into sections :

The first line tells textpad how the language in question is likely to be structured. In the case of PL/SQL, it’s a ‘C’ like language in this sense ( pretty standard 3GL), so we specify :

C=1

This is followed by the syntax section, most of which is fairly self-explainatory :

[Syntax]
Namespace1 = 6
IgnoreCase = Yes
InitKeyWordChars = A-Za-z_
KeyWordChars = A-Za-z0-9_
PreprocStart =
SyntaxStart =
SyntaxEnd =
CommentStart = /*
CommentEnd = */
CommentStartAlt =
CommentEndAlt =
SingleComment = --
SingleCommentCol =
StringStart = '
StringEnd = '
StringAlt =
StringEsc =
CharStart = '
CharEnd = '
CharEsc =

Namespace1 is set to 6 because we’re going to divide our keywords into six different categories, each of which can – if we so wish – be highlighted using a different colour.

In this example, I’ve split the keywords into six categories :

  1. SQL keywords
  2. SQL functions
  3. Pseudo-columns
  4. PL/SQL keywords
  5. SQL*Plus formatting commands
  6. Other SQL*Plus commands.

The entire file looks like this :

001 C=1
002
003 [Syntax]
004 Namespace1 = 6
005 IgnoreCase = Yes
006 InitKeyWordChars = A-Za-z_
007 KeyWordChars = A-Za-z0-9_
008 PreprocStart =
009 SyntaxStart =
010 SyntaxEnd =
011 CommentStart = /*
012 CommentEnd = */
013 CommentStartAlt =
014 CommentEndAlt =
015 SingleComment = --
016 SingleCommentCol =
017 StringStart = '
018 StringEnd = '
019 StringAlt =
020 StringEsc =
021 CharStart = '
022 CharEnd = '
023 CharEsc =
024
025 [Keywords 1]
026 (+)
027 all
028 and
029 any
030 as
031 between
032 cast
033 commit
034 connect by
035 cube
036 delete
037 distinct
038 exists
039 explain plan
040 for update
041 from
042 group by
043 having
044 in
045 insert
046 is null
047 like
048 lock table
049 intersect
050 multiset
051 minus
052 not
053 or
054 order by
055 partition
056 returning
057 rollback
058 rollup
059 sample
060 savepoint
061 select
062 set constraint
063 set transaction
064 some
065 start with
066 subpartition
067 table
068 the
069 union
070 update
071 values
072 where
073 where current of
074 with
075
076 [Keywords 2]
077 abs
078 acos
079 add_months
080 ascii
081 asin
082 atan
083 atan2
084 avg
085 bfilename
086 bitand
087 ceil
088 chartorowid
089 chr
090 concat
091 convert
092 cos
093 cosh
094 count
095 dangling
096 decode
097 deref
098 dump
099 empty_blob
100 empty_clob
101 exists
102 exp
103 floor
104 glb
105 greatest
106 grouping
107 hextoraw
108 initcap
109 instr
110 instrb
111 last_day
112 least
113 length
114 lengthb
115 like
116 ln
117 log
118 lower
119 lpad
120 ltrim
121 make_ref
122 max
123 min
124 mod
125 months_between
126 new_time
127 next_day
128 nls_charset_decl_len
129 nls_charset_id
130 nls_charset_name
131 nls_initcap
132 nls_lower
133 nls_upper
134 nlssort
135 null
136 nvl
137 power
138 rawtohex
139 ref
140 reftohex
141 replace
142 round
143 rowidtochar
144 rpad
145 rtrim
146 sign
147 sin
148 sinh
149 soundex