SciTE customisation with Lua Scripts

326 views
Skip to first unread message

Gavin Holt

unread,
Sep 9, 2020, 7:00:29 PM9/9/20
to scite-interest
Hi,

I have taken Neil's advice and turned my hand to customizing SciTE using only my own Lua script. Hopefully, this will be easier to maintain in the future.

Avoiding binary add-ons also maintains the very quick start up time for SciTE32.exe (200-260ms on my system).

Please find attached a single Lua file which is the fruit of my labor (NB. targeting a windows environment). In order to make it a single file the first section is extending the standard Lua libraries, then comes the SciTE specific stuff. Any external tools are marked with **.

These ideas are very much "standing upon the shoulders of giants" - many thanks to all those who have contributed directly and indirectly :)

Kind Regards Gavin Holt

N.B. Some TODOs are work waiting, some are outside my workflow and some are just to difficult!


SciTEStripped.lua

Gavin Holt

unread,
Oct 27, 2020, 8:27:56 AM10/27/20
to scite-interest
Hi

Updated lua customisation script (designed for WindowsOS but could be ported) including the following:

User strips with per session command history
Message strip -- Single line message
Goto strip -- Just to move insertion point
Windows strip -- (Re)open Recent Buffers
Snippets strip -- Insert saved snippets
Templates strip -- New File then insert saved template
Locations strip -- Select a location from any line edited in any file in this sessions
Open Project File Strip -- Select and open a file from this subtree
Insert Project File strip -- Select and insert a file from this subtree
Lua Command strip -- Execute lua commands
Run Lua Macro Strip -- Select stored Lua macro
Edit Lua Macro -- Edit stored Lua macro
DOS Command strip -- Execute and see in output
Command menu -- List and execute user defined commands
Review versions -- Select and load backup versions
Search output strip -- Allow searching of the output pane

Custom OnKey function to detect keyboard shortcuts
Many :)

Custom OnDoubleClick function
Popup spelling suggestions (Windows with Hunspell.EXE)

Kind Regards Gavin Holt

SciTEStripped.lua

guit...@gmail.com

unread,
Oct 27, 2020, 11:50:40 PM10/27/20
to scite-interest
Hi Gavin,
Good Job! could you please also guide me how to use this Lua script? thank you

Gavin Holt

unread,
Oct 29, 2020, 10:07:11 AM10/29/20
to scite-interest

Hi,

For any Lua customisation you will need to define a Lua Startup Script - see Options Menu.
My script is designed to be the one and only Lua script for any given installation of scite


1. Place this in your Global (or User) options file - see Options Menu.:-

    ext.lua.startup.script=$(SciteDefaultHome)\mod\SciTEStripped.lua
    ext.lua.directory=$(SciteDefaultHome)\mod
    ext.lua.auto.reload=1

    and optionally :

    # Status Bar
    statusbar.visible=0
    statusbar.number=1
    statusbar.text.1=\
    Position : $(LineNumber):$(ColumnNumber)  | Lines : $(NbOfLines) | Words : $(buffer.wordCount) | Chars : $(BufferLength) | Selected: $(SelLength) | KeyCode: $(KeyCode) | KeyIndex: $(KeyIndex) | LastFind: $(find.what)

2. Please note the expected directory structure so the script can find files:-

    SciteDefaultHome\
        dic     Dictionaries - these are just allowed word lists for each file type
        mac     Macros
        mod     My script and external tools
        tem     Templates
        snp     Snippets

    Below is a listing of these folders on my machine:

    Directory of P:\MYPROG~1\EDITORS\SCITE
        11/09/2020  20:45         1,149,952 SciTE32.exe - 4.4.5
        11/09/2020  20:44           629,248 Lexilla.dll
        11/09/2020  20:44           589,824 Scintilla.dll
        14/08/2020  14:49               299 SciTEGlobal.properties
        12/09/2018  22:04         1,587,200 SciTE.exe - 3.7.5
        12/09/2018  21:23         1,977,344 SciLexer.dll
                  10 File(s)      5,935,810 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\mod
        12/10/2020  19:06             7,207 SciTEStripped.properties
        28/07/2020  18:14             6,955 props.api
        06/08/2020  00:41             8,386 props.properties
        12/10/2020  19:02             8,398 lua.api
        15/10/2020  11:37               949 lua.properties
        12/08/2020  19:05           128,441 SciTELua.api
        06/08/2020  13:46             1,461 SciTELua.properties
        12/08/2020  18:45               347 SciTE.session
        29/10/2020  12:18            94,503 SciTEStripped.lua
        04/05/2013  15:17           390,896 gwFindReplace.exe
        18/10/2009  19:29            61,952 GetPlainText.exe
                  13 File(s)        709,601 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\user
        29/10/2020  09:03               548 SciTE.session
        13/09/2020  21:42               191 user.dic
                   4 File(s)          1,676 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\mac
        05/08/2019  18:55               221 ListIDMandSCIconstants.lua
        31/08/2020  22:10                20 phone_number.lua
        26/06/2017  23:25               386 test.lua
                   4 File(s)          1,168 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\tem
        27/04/2017  20:26               255 default.awk
        24/09/2017  22:33               263 default.bat
        07/10/2020  20:33               113 default.gsl
        18/07/2019  20:11               513 HipandKnee.lua
        11/02/2015  17:48               109 default.cpp
        11/02/2015  17:48               237 default.css
        11/02/2015  17:48               163 default.htm
        11/02/2015  17:48               226 default.java
        11/02/2015  17:48               140 default.js
        11/02/2015  17:48               185 default.jsp
        11/02/2015  17:48               186 default.php
        11/02/2015  17:48                46 default.pl
        11/02/2015  17:48                88 default.py
        11/02/2015  17:48                23 default.rb
        11/02/2015  17:48               140 default.tex
        11/02/2015  17:48               133 default.vbs
        11/02/2015  17:48               205 default.wsf
        11/02/2015  17:48               445 default.xml
        07/09/2020  11:25               544 SciteMacro.lua
        18/09/2020  11:47               693 html.lua
        19/09/2020  17:36             3,487 html_board.lua
        19/09/2020  17:21             6,613 html_min_css.lua
        19/09/2020  17:37             3,110 html_board_draft.lua
                  23 File(s)         17,917 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\dic
        09/09/2020  23:31               499 lua.dic
                   1 File(s)            499 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\snp
        07/10/2020  18:57    <DIR>          html
                   0 File(s)              0 bytes

     Directory of P:\MYPROG~1\EDITORS\SCITE\snp\html
        31/08/2020  11:41               247 table.htm


3. My shortcut key defintions as extracted from the script.

["[+Ctrl+Editor"] = function()      -- Toggle this header TODO go up to visible line
["[+Alt+Editor"] = function()       -- Toggle child folds TODO go up to visible line
["[+Ctrl+Alt+Editor"] = function()  -- Toggle all headers TODO go up to visible line
["]+Ctrl+Editor"] = function()      -- Insert []
["2+Ctrl+Editor"] = function()      -- Insert ""
["(+Ctrl+Editor"] = function()      -- Insert ()
[")+Ctrl+Editor"] = function()      -- Insert ()
["=+Ctrl+Editor"] = function()      -- Run text as Lua
["?+Ctrl+Editor"] = function()      -- Lua Command strip
[".+Ctrl+Editor"] = function()      -- Repeat last Lua Strip Command
["?+Ctrl+Alt+Editor"] = function()  -- Run Lua Macro Strip
["?+Alt+Editor"] = function()       -- Create Lua Macro
["?+Alt+Shift+Editor"] = function() -- Edit Lua Macro
["#+Ctrl+Editor"] = function()      -- Open your shell
["#+Ctrl+Shift+Editor"] = function()-- Open Explorer
["#+Ctrl+Alt+Editor"] = function()  -- DOS Command strip
["F8+Editor"] = function()          -- Show output AND focus
["F9+Editor"] = function()          -- Command strip
["Up+Ctrl+Editor"] = function()     -- Find previous
["Down+Ctrl+Editor"] = function()   -- Find next
["Up+Ctrl+Shift+Editor"] = function()-- Block Up
["Down+Ctrl+Shift+Editor"] = function()-- Block Down
["B+Ctrl+Editor"] = function()      -- Goto bol - for my mini keyboard
["B+Ctrl+Shift+Editor"] = function()-- Select to bol - for my mini keyboard
["B+Ctrl+Alt+Editor"] = function()  -- Make a backup - uses **xcopy
["V+Ctrl+Alt+Editor"] = function()  -- Review versions
["D+Ctrl+Editor"] = function()      -- Duplicate line or block
["E+Ctrl+Editor"] = function()      -- Goto eol - for my mini keyboard
["E+Ctrl+Shift+Editor"] = function()-- Select to eol - for my mini keyboard
["F+Ctrl+Editor"] = function()      -- Find strip
["F+Ctrl+Alt+Editor"] = function()  -- TODO Find in files Strip
["G+Ctrl+Editor"] = function()      -- Goto strip
["G+Ctrl+Alt+Editor"] = function()  -- TODO GIT Strip
["H+Ctrl+Editor"] = function()      -- Call replace strip
["H+Ctrl+Alt+Editor"] = function()  -- Replace in files **uses gwFindReplace.exe
["I+Ctrl+Alt+Editor"] = function()  -- Insert Project File strip
["J+Ctrl+Editor"] = function()      -- Jump to "end" or delimiter
["J+Ctrl+Shift+Editor"] = function()-- Select delimiter
["J+Ctrl+Alt+Editor"] = function()  -- TODO CTAGs Strip
["K+Ctrl+Editor"] = function()      -- Delete to EOL
["K+Ctrl+Shift+Editor"] = function()-- Delete to BOL
["L+Ctrl+Editor"] = function()      -- Lookup definition TODO search outside SciteLua!
["L+Ctrl+Alt+Editor"] = function()  -- Locations strip
["M+Ctrl+Editor"] = function()      -- Mark and list occurrences
["M+Ctrl+Alt+Editor"] = function()  -- Multicursor Editing
["N+Ctrl+Alt+Editor"] = function()  -- Open New Editor
["O+Ctrl+Alt+Editor"] = function()  -- Open Project File Strip
["R+Ctrl+Alt+Editor"] = function()  -- Save and Run current file
["S+Ctrl+Alt+Editor"] = function()  -- Insert Snippets
["T+Ctrl+Alt+Editor"] = function()  -- New File then Insert Template Strip
["U+Ctrl+Editor"] = function()      -- Unmark words
["X+Ctrl+Alt+Editor"] = function()  -- Execute in shell
["Y+Ctrl+Editor"] = function()      -- Yank line or block
["Z+Ctrl+Shift+Editor"] = function()-- Redo
["Tab+Ctrl+Output"] = function()    -- Switch to editor
["2+Ctrl+Output"] = function()      -- Insert ""
["F+Ctrl+Output"] = function()      -- Search Output
["Up+Ctrl+Output"] = function()     -- Find prev
["Down+Ctrl+Output"] = function()   -- Find next
["H+Ctrl+Output"] = function()      -- Toggle Horizontal
["N+Ctrl+Output"] = function()      -- New (Clear)
["W+Ctrl+Output"] = function()      -- Close

4. Some User Commands don't have shortcuts - see F9 Command Strip for a list.

    Setting up spell checking requires Hunspell.exe with its libraries and dictionaries - I have used absolute paths see in the script.


Hope this helps

Kind Regards Gavin Holt

PS Will need modification for non-windows OS


guit...@gmail.com

unread,
Oct 29, 2020, 9:21:58 PM10/29/20
to scite-interest
Hi Gavin,
Thank you for the detailed guidance. it worked for me with SciTE 4.4.5.
PS, could you please post your whole directory of Scite here?
thank you.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

holt...@gmail.com

unread,
Oct 31, 2020, 3:52:50 PM10/31/20
to scite-interest
Hi

As requested a zip of my SciTE windows installation.
I have moved hunspell.exe into the installation.
There are some other utilities also with credits.

This is portable, but uses a SciTE_USERHOME env variable
e.g. setx SciTE_USERHOME P:\MyPrograms\EDITORS\Scite\user

TODO: Use MultiMark.exe and LuaCheck6.exe

Kind Regards Gavin Holt

I have tried many times to upload my 5.5MB zip file and it won't go
Anybody got a suggestion?

guit...@gmail.com

unread,
Nov 1, 2020, 2:40:09 AM11/1/20
to scite-interest
Hi Gavin,
you can try to use 7-Zip to split the 5.5MB file to 2-3 small size file and upload the small size file.
Message has been deleted
Message has been deleted

holt...@gmail.com

unread,
Nov 1, 2020, 7:31:15 AM11/1/20
to scite-interest
Hi

I tried several different approaches (small zips, flat zips, zips without binary files) and I can't post my installation here.


I'm not planning to "maintain" the repo, and may delete if it I get unwanted traffic - so discussions on this thread please.

Kind Regards Gavin Holt

guit...@gmail.com

unread,
Nov 1, 2020, 8:32:48 PM11/1/20
to scite-interest
Thanks Gavin. I have stared the repo. :)

gui...@gmail.com

unread,
Jan 17, 2024, 4:53:23 AMJan 17
to scite-interest
Hi Gavin,

Your script is gem.

I'm also trying to find the config that fits well for the daily usage, after years using a patchwork of herratic patched-up files. 
Even if the dev-editors galaxy is full of amazing tools, very seducing, I'm still in love with SciTE for her lightliness and her flexibility.
I'm under linux only and tried to adapt most of this script to my usage (and NGL trying also to simulate some of amazing modern IDE features if possible).
I'm confuse not to have early discovered your script. But I have some questions, if you have the time :

- What is the "extension" in require("extension") ? a dll ? a lua lib ? The comment says " -- Simple additions to Lua for Command Strip" But seeking the web, your github or the mailing-list, no clue.
- extman was a time savior, but I read multiple times people trying to get rid of it (like in this script). I wonder why.

Actually, unless I missed something, SciTE lacks a centralised ressource to allow people to easily install and configure her. 
There are scattered initiatives, mostly olds. Nevertheless, this group and lua-users site are a good start.
Maybe there could be a megathread where veterans share their bests configs, plateform-specific or crosse-plateform.
I always was curious of some people's configs, such as Neil's (which I imagine is powerfull but sleek and simple) ;-)

Scitally,
Pascal

Neil Hodgson

unread,
Jan 17, 2024, 4:01:56 PMJan 17
to scite-interest
Pascal:

> Actually, unless I missed something, SciTE lacks a centralised ressource to allow people to easily install and configure her.
> There are scattered initiatives, mostly olds. Nevertheless, this group and lua-users site are a good start.

There is https://github.com/moltenform/scite-files but I just noticed a link to its old location on the web page.

> I always was curious of some people's configs, such as Neil's (which I imagine is powerfull but sleek and simple) ;-)

My configuration is always very messy as I add items to check reported bugs and never clean it up properly.

Neil

gui...@gmail.com

unread,
Jan 18, 2024, 5:08:20 AMJan 18
to scite-interest
Neil, thanks for your answer !
> There is https://github.com/moltenform/scite-files but I just noticed a link to its old location on the web page.
Oh yes, I know well this ressource. It's an almost complete digest of what have been done in the SciTEsphere.

BTW by "centralized ressource" I think more of something easyer for new adopters, like unique startup script allowing easy extensions integration (such as extman), videos/pictures of what can be done... the lua-users wiki could be a good base because of its editablility.

My configs are all messy as yours (as early adopter and daily user), and the molteform repo is more a do-what-you-can-whith-this list :D

I know SciTE purpose was at first a proof of concept for Scintilla, although her maturity, lightliness and flexibility give her the chance to be among the best editors/IDE.

Pascal

Gavin Holt

unread,
Jan 21, 2024, 1:19:11 PMJan 21
to scite-interest
Hi,

Answering your questions:

extensions.lua  -  is a lua script I use for many lua projects. It adds functions to the standard libraries which are missing. The necessary functions are now in SciTE.lua.

extman.lua - was a way of combining different plugin lua scripts, so they play nicely together. I have stopped using this and have all my SciTE scripting in a single file - attached.

My current windows SciTE installation for reference:

----+/SciTE/
    ---- Sc541.exe
    ---- SciTEGlobal.properties    
            (ext.lua.startup.script=$(SciteDefaultHome)\SciTE.lua)
            (import $(SciteDefaultHome)\mod)
    ---- SciTE.lua                  
            (This is my only script)
    ----+ /mod/                      
            (modifications and additions to the Sc1.exe bundled properties files)
        ---- ahk.properties
        ---- kix.properties
        ---- lua.api
        ---- lua.properties
        ---- markdown.properties
        ---- props.api
        ---- props.properties
        ---- SciTELua.api
        ---- SciTELua.properties
        ---- sql.properties

SciTE is not my only editor and the script is dependent upon several external tools/files most of which are annotated in the script (e.g. Hunspell.exe, paste.exe, shelexec.exe, GrepWin.exe).
       
I have given up on using any third party binary (DLL) addins for SciTE - see dead batteries.

Kind Regards Gavin Holt
SciTE.lua.txt

andrew strain

unread,
Jan 31, 2024, 9:24:36 PMJan 31
to scite-interest
Hi - I'm assuming this bumped topic as the latest centralised resource to share lua scripts ;) 
So here are three refined features yanked out of my sprawling collection (codeberg.org/lusci/lusci) to work under Gavin's neat set up.
There is also a GetClipboard() function with no dependencies at the top that is not used within but might be handy.

The three main functions are:
  keypr_sort() - toggles standard and natural sort order in selected text
  keypr_twiddle() - reverses selected words or lines or column, or flips letters at caret
  keypr_cyclecase() - cycles through lower > Sentence > First Letter > ALL CAPS of selected

They are made to work with normal or monospaced rectangular selections.
I put twiddle and sort on ctrl+t and shift+ctrl+t  and cyclecase on ctrl+u

It occurs to me momentarily, the sort would be better if it included a shuffle phase...
...a future version. Best wishes - andrew
lusci3.lua
Reply all
Reply to author
Forward
0 new messages