前ふり

ずっと使っていたテキストエディタMeryを最新にアップデートしてみると非常に良い感じ。 ただPythonの組み込み関数(lenとかrangeとかね)がハイライトされないのが気になったので公式をみて独自に追加してみた話。複数に色分けできるようなのでPython 3.7.2の公式から予約語を取ってきてよい感じに分類した。例えば構造化制御系のifとかelseとかは同じ色に、andとかorも同じいろに、という感じ。専門家ではないのでその他の分類には異論がありえるかも。 同じくPython3.7.2の公式から組み込み関数のリストをとってきて同じ色の強調表示にぶちこんだ。組み込みライブライもいれようかと思ったが余りにも量が多く動作に支障をきたしそうだったのでやめた。

やり方

以下をコピペしてpython.msyとして保存。

#TagBegin=
#TagEnd=
#CommentBegin1="""
#CommentEnd1="""
#LineComment1=#
#CommentBegin2=
#CommentEnd2=
#LineComment2=
#SpecialSyntax=None
#ScriptBegin=
#ScriptEnd=
#QuoteSingle=True
#QuoteDouble=True
#QuoteContinue=False
#EscapeCharacter=\

#Word Color=0, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
del
from
global
import
nonlocal

#Word Color=1, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
as
break
continue
elif
else
for
if
pass
return
while
with
yield

#Word Color=2, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
and
in
is
not
or

#Word Color=3, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
False
None
True

#Word Color=5, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
__import__
all
any
ascii
bin
bool
breakpoint
bytearray
bytes
callable
chr
classmethod
compile
complex
delattr
dict
dir
divmod
enumerate
eval
exec
filter
float
format
frozenset
getattr
globals
hasattr
hash
help
hex
id
input
int
isinstance
issubclass
iter
len
list
locals
map
max
memoryview
min
next
object
oct
open
ord
pow
print
property
range
repr
reversed
round
set
setattr
slice
sorted
staticmethod
str
sum
super
tuple
type
vars
zip

#Word Color=6, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
assert
async
await
except
finally
raise
try

#Word Color=7, WholeWord=True, RightSide=False, MatchCase=True, InsideTag=False, RegEx=False
class
def
lambda

Meryのメニューから表示>編集モード>編集モードの設定>Pythonを選択>プロパティ>インポート>はい、で完了。