Automatically close brackets, parens, braces, and quotes with SciTE

In this short tutorial I walk through how I configured SciTE to automatically close: brackets, parens, braces, and quotes with SciTE.


Here’s what you need to do to try this:1) Export these lua files into your SciTE home directory
2) Open your UserLuaScript.lua script and add the following lines (in this order)

--***AutoClose Begin***
EventClass:BeginEvents() -- Start up the events (Calls onstartup()).
-- ***AutoClose END

Then just restart SciTE and you’ll be able to have SciTE close brackets, parens, quotes on its own!

Video demonstrating the process so SciTE can close brackets, parens, etc.

Webinar- SciTE4AutoHotkey is an amazing editor!


In this AutoHotkey Webinar we cover using/customizing  SciTE4AutoHotkey by FincsSciTE webinar

Video Hour 1High-level overview:

SciTE4AutoHotkey is a lightweight and easy to use SciTE-basedAutoHotkey script editor. It provides:

Demonstration of cool SciTE4AutoHotkey features

  1. Multi-line typing
  2. Dynamic Intellisense
  3. Move text up/down
  4. Comment / Un-comment
  5. Change applied Intellisense language
  6. Copy / Paste as RTF
  7. Custom Context Menu
  8. Search / Replace – with RegEx
  9. List of Extensions to “open”
  10. Highlight multiple instances of each word
  11. Change color of highlighting for found word
  12. Custom Status bar
  13. Configure hotkeys (w/o AutoHotkey)
  14. Custom your Status bar
  15. Setting default magnification level
  16. Import additional languages (here are an additional ~70 languages)
  17. Leverage the Output area as a GUI
  18. Customizing your context menu
  19. Running multiple instances of SciTE
  20. Debug your scripts
  21. Run selected text

Scripts / External Resources

  1. Main thread on SciTE4AutoHotkey
  2. 16 videos @ the-Automator on using / customizing SciTE
  3. 42 of built-in Hotkeys
  4. My SciTE file (backup yours before playing with it!)
  5. Adding Intellisense for an additional ~70 languages
  6. Scintilla / SciTE Documentation, Interface, Menu /Key commands
  7. UserGroup plus StackOverflow
  8. Second SciTE window by boiler (launch script, then do new window)
  9. Tweaking Intellisense to use your file / library from XeroByte
  10. Have Intellisense examine current file from lexikos

Video Hour 2Discussion and Q&A

Script Highlight: Button Clock

Why waste space for “Start” button.   Use Button_Clock_WINXP from Goyyah

#SingleInstance, Force
/*  * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Download    :
Description :  A "Button Clock" in lieu of "Windows Start Button" This script hides the "Start Button" and adds a new Button and keeps updating the "Button Caption" with a Time String - periodically - effectively making it a clock.
Author      : A.N.Suresh Kumar aka "Goyyah"
Email       : [email protected]
Control, Hide, , Button1, ahk_class Shell_TrayWnd
OnExit, Exitt  ; and restore the Start Button

cTime := A_Now
Gui, +ToolWindow -Caption
Gui, +Lastfound
GUI_ID := WinExist()
WinGet, TaskBar_ID, ID, ahk_class Shell_TrayWnd
DllCall("SetParent", "uint", GUI_ID, "uint", Taskbar_ID)

Gui, Margin,-28,1
Gui, Font, S13 bold , Arial Narrow ;change to make fit
Gui, Add,Button, w130 h20 gStartM vTime, % Time
;backup Gui, Add,Button, w113 h30 gStartM vTime, % Time
Gui, Show,x0 y0 AutoSize, Start Button Clock - By Goyyah

SetTimer, UpdateButtonTime, 10
; ----------------------------------------------------------------------------------------
  If cTime = %A_Now%
     cTime := A_Now
  SetTimer, UpdateButtonTime, OFF
  ;FormatTime,Time,,h:mm  MMM-dd ;adusted to show 12 hour time
  FormatTime,Time,,h:mm M/d ;adusted to show 12 hour time
  GuiControl,,Time , %Time%
  SetTimer, UpdateButtonTime, 10
  Send ^{ESCAPE}
  Control, Show, ,Button1, ahk_class Shell_TrayWnd


Personalizing SciTE Intellisense / Autocorrect

In this post I leverage two different scripts where I demonstrate how to personalize SciTE Intellisense / Autocorrect.   Both are great ways SciTE Intellisense / Autocorrectto increase your productivity while coding!

Adding Functions/Labels from files/folders to your SciTE Intellisense / Autocorrect

This script can be used to point to specific files/folders and grab labels, functions, etc. and pull them into your Intellisense for you.   This script will generate a “user.ahk.api” file in your default SciTE library and only needs to be run periodically (when you have new functions/labels you want to include).

  • Save BuildUserAhkApi.ahk to a location on your computer (if you save it in your local \lib\folder you will not need to #include it!)
  • From a separate file, call the function and tell it what file(s) /directory you want it to review and what you want it to include (functions and/or labels).  You can also decide to be recursive or not.   I had it import all of my functions from my standard AutoHotkey\lib\ folder but did not include my labels (as they’re really only relevant for an active script).
  • Here is the function and parameters (the last one should not be used):  BuildUserAhkApi(AhkScriptPath, [OverwriteAhkApi, RecurseIncludes, Labels, WrapWidth, AhkApiPath, RecursionCall])
  • Here is how I called mine (note you’ll need to dupate the destination path:
BuildUserAhkApi("B:\Progs\AutoHotkey_L\Lib\", 0, 0, 0, 265, "C:\Scite_Install\SciTE_Custom\user.ahk.api")

Video demonstrating how it works:

Adding Functions, Labels, Variables from your current file to your SciTE Intellisense / Autocorrect

In this second example I demonstrate how you can have variables, labels, functions in your current script populate the SciTE Intellisense / Autocorrect.  If you’re like me, you’ll LOVE this functionality because it will help prompt you of the variables, functions, labels you have in the current saved script.  This can drastically increase your productivity!

  • Save AutoComplete.lua to SciTE default directory  ;(See attached or download here)
  • Save UserLuaScript.lua to SciTE default directory (append if you have something there already –I had this file but it does not show up under Option)
  • I’m beta testing this but right now it looks like it works fine-  I added one line @ row 282 to my version . This tells SciTE to update all the time (not waiting for the document to be saved).  So far it seems to work fine but I’m going to give it a bit before recommending…
local events = {
    OnChar          = handleChar,
    OnKey           = handleKey,
    OnSave          = buildNames,
    OnUpdateUI      = buildNames, --I added this line @ line 282 
    OnSwitchFile    = function()


Great function for sending text to the SciTE Output Pane

SciTE Output paneWhile I predominately view text with Message boxes in AutoHotkey, sometimes they are not the right tool for the job.  I wrote a short function to automate sending text to the SciTE Output pane.

SciTE is a great editor however the Output pane is greatly underutilized.  Below is the function I wrote to manipulate it.  You can download the SciTE Output Function here or grab it below

SciTE Output Pane AutoHotkey Function

SciObj := ComObjActive("SciTE4AHK.Application") ;get pointer to active SciTE window
IfEqual,Clear,1,SendMessage,SciObj.Message(0x111,420) ;If clear=1 Clear output window
Sleep, 500
IfEqual, LineBreak,1,SetEnv,Text,`r`n%text% ;If LineBreak=1 prepend text with `r`n
SciObj.Output(Text) ;send text to SciTE output pane
;~ IfEqual, Exit,1,MsgBox, 36, Exit App?, Exit Application? ;If Exit=1 ask if want to exit application
;~ IfMsgBox,Yes, ExitApp ;If Msgbox=yes then Exit the appliciation

And here is a short video walking through how to use it