我想知道是否有人有使用 Notepad++ 编写脚本的技术/技巧。我知道我用过的真正的 IDE 程序(比如 python)有很多内置的自动格式化功能。当我编写
IF
语句或 LOOP
时,它将创建一些所需的包围。我使用 Notepad++ 编写 AutoHotKey,它工作得非常好,但如果它具有一些自动格式化功能,我会很高兴。
类似的东西;我输入
if
然后变成...
if ()
{
}
或将
RegExMatch
等功能输入... RegExMatch(,,,)
如果 Notepad++ 可能不是 AHK 的最佳工具,我想我可以采纳您可能使用的其他编辑器的建议。
为了在编辑器中输入AHK命令和函数,我在主脚本中使用上下文敏感的热字符串以及特殊的结束字符:
; === auto-execute section === (top of the script)
; create a group of those editors:
GroupAdd, myEditors, ahk_class Notepad
GroupAdd, myEditors, ahk_class Notepad++
; ...
RETURN ; === end of auto-execute section ===
; Hotstring-Options:
; C0: Case-insensitive
; O: Omit the ending character
; T: Send the replacement text raw
; EndChar: <
#Hotstring T O C0
#Hotstring EndChars <
#IfWinActive ahk_group myEditors
::if:: ; type if< to send
Send {Text}
(
if ()
{
}
)
return
; type rexm< or RegExMatch< to send RegExMatch(,,,)
::rexm::RegExMatch(,,,)
::RegExMatch::RegExMatch(,,,)
#IfWinActive ; turn off context-sensitivity