AutoIt setup for EditPlus (in progress)
is my favourite text editor for Windows; I basically use it for everything. And AutoIt
is my favourite Windows development language. So getting the two to work together flawlessly is very important to me. It's also fairly easy.
This page explains how to setup EditPlus for AutoIt coding, with some example configurations, and hopefully shows why EditPlus makes such a choice AutoIt IDE
. I'll also go on to demonstrate some neat ways you can link them together and maximize the combination; compile and run AutoIt applications from within EditPlus, compare files, receive debug output in EditPlus' built-in console, and more..
Sure, SciTe (the recommended AutoIt IDE) is functionally
very good (at what it does), but I bet at least 99% of the tasks that SciTe users do every day could be done in EditPlus, or indeed any decent text editor, if you knew how to set it up
. If you want to use EditPlus to code AutoIt, this page will show you how to set it up.
Note, many of these tips and tricks will apply to other quality text editors
, but EditPlus is where I live and breath; work; so I'll stay focused on what I know best. If you can't get your chosen editor to play ball, perhaps somewhere out there is a developer passionate enough about his
text editor to do a page just like this for your
chosen combo; go Google for him!
If you haven't yet decided on a text editor, and are reading this page to help you decide, I'll cut to the chase: for my money (and it's not free) EditPlus is the best text editor for Windows, syat (and I've tried literally hundreds of them, and keep testing the best regularly), but it does lack the following features..
- File Compare. TextPad still reigns here, though it hasn't had an update since 1945 or thereabouts; worth keeping the shareware version around for this feature alone. note: there are plugins for EditPlus that enable you do do this, but not quite so elegantly as TextPad's built-in file compare; though its output always makes my eyes hurt!
As you can see in the "get tooled up" screenshot below, you can do file compare in EditPlus, you simply create a tool command utilizing WinMerge or WinDiff (which comes with windows, but if you don't have it handy, you can get it here.). WinDiff is actually pretty good, though the colors make the output as painful to read as TextPad's! Learn some WinDiff tricks, here.
WinMerge is better, and allows you to change the colors, as well as many other settings. It even boasts explorer integration, enabling you to select two files, and then compare them directly from your context menu. It also uses the colour orange a lot, which I like. Very nice.
EditPlus' ability to draw in the services of external applications in meaningful ways, is one of its greatest features, and I'll delve more deeply into this, later on.
- Search & Replace in files. If only other text editors had the balls of UltraEdit, except with proper regular expression matching, My God! It would be like PowerGrep right in your text editor!
That's it. Apart from that, EditPus has just about every imaginable facility a coder/writer/poet/programmer/web-coder/thinker could ever want - and now with code-folding! Thank you Sangil! Now, when do I start getting commission? Just kidding; using the application every day is payment enough; the gui is uncluttered and effective, Unicode handling; excellent, configurability; Oh Boy! Let's start with the important stuff..
Are you Color Blind?
First off, you need to sort out your syntax highlighting. Don't even think about coding without syntax highlighting! Every decent text editor can do this, even command-line editors like mc
. This is some code; before syntax highlighting..
Clearly this is something you want, and Notepad isn't going to cut it. Start by downloading my AutoIt syntax file
(and if you are so inclined, my ACP (Auto-Completion) file
- I don't use it). Dump that inside your EditPlus program folder (I know, messy, but there you have it
(in EditPlus 3, you can now specify a folder)) and find your way into EditPlus' preferences.
Files > > Settings & Syntax
, and get it looking roughly like this..
That is; add a new file type, and enter those details. Note the path to the syntax file you just downloaded, simply browse and locate it (next to EditPlus). Although I do have an "autocompletion" file, I find that functionality annoying, though I can see how it could be a great time-saver for some folk. For the "Func Pattern", you can simply use "func", though mine is currently, "^[ \t]*func ".
So now you have syntax highlighting, and you can see what's-what in your code This will give you massive gains in productivity. Next we need to link EditPlus and AutoIt together in meaningful ways, and we'll start by creating some "User Tools"..
Get tooled up..
EditPlus has loads of features, and very few that I don't use, which says a lot about its design. One of its greatest features is user-configurable tools, aka. "User Tool Groups". This enables the user, you, to put all sorts of goodies into EditPlus' tools menu.
As the name implies, you can also "group" these tools. Currently I'm using the "web tools" group, which I created for doing web development work..
F9, F12 and ALT+A are the three HotKey combos I use most often, in ALL the groups; they are configured to do the same thing in each group; F9 always provides help for the currently selected word, for example. But I'm getting ahead of myself; first we'll need to create these tools..
There are four different kinds of user tool in EditPlus; program, help (.hpl), help (.chm), and keystroke recording. The two I'll describe in detail are program, and chm help.
The "program" tool enables you to run an external program with a specific set of parameters, and (optionally) have output piped back into EditPlus' built-in console output window. The most obvious use is for running scripts, and checking debug output, live.
As you can see, I've plugged quite a few tools into my "AutoIt Beta" menu.
The chm help tool enables you to link to a real .chm help file somewhere on your system, and with the correct paramteters, a simple hotkey will pop up the correct help page for whatever word you have selected in your script. You don't have to select the whole word, either, just put your cursor in it somewhere.
You can have any number of tools in each group (as far as I know - I've not hit a limit, yet, though you can't create more than Twenty tool keyboard shortcuts, so perhaps it's Twenty), and up to ten separate groups of tools, so there's scope for setting up a one-tool-does-all environment capable of handling most any project, including AutoIt coding.
But before you begin creating program and help tools, you'll need to create a tool group
to put them in, named perhaps "AutoIt Tools" (you can call it whatever you like).
You can either get to the user tools configuration via the regular preferences, or directly from Tools >> Configure User Tools (you can make a keyboard shortcut for that, too). Once there, select an empty group and rename it by clicking the "Group Name..." button. Now you are ready to create some tools.
The Run tool..
The "Run" tool is the one you will use most of all (after the help!). This tool saves your script, and sends it to the AutoIt executable to run. If your script contains any "ConsoleWrite" commands (handy for debug lines), that output will be piped right back into EditPlus console output window, which pops-up when you activate the tool.
Click the "Add Tool >>" button and select "program", enter the details so that it looks something like the image to the right, inserting your own path to wherever you keep AutoIt, of course (you can click the "..." button to browse for AutoIt3.exe (or whatever your preferred binary is called).
You can click the buttons to the right of the inputs to get special variables into the mix, the ones we'll use are "$(FilePath)", which automatically transforms at run-time, into the full path to your current document; and "$(FileDir)", which you can guess. Here's a script to test your new tool..
; example script
for $i = 1 to 10
Run that (either by selecting the menu item or, better; using a HotKey) and the console output will pop up and you should see something like this..
The .chm Help tool..
I really like .chm help files, which are "Compressed Help Manuals". Basically, you take a heap of regular .html files, even a whole web site, and compile them all-together into an indexed, compressed document. Quite nifty; and because of the indexing, EditPlus is able to link right in to the exact page required, no more searching the help file! (well, almost).
You can make your own .chm help manuals without too much trouble; there's a Windows SDK
available, and plenty tools out there to make the process almost easy. Fortunately, AutoIt already comes with a quite excellent .chm help file that you can just use
Click the "Add Tool >>" button and select "HTML Help File (*.chm)", enter your own path to wherever you keep AutoIt help file, and you're done.
If you click the mouse somewhere inside the word "ConsoleWrite", in our example script (above), then hit the HotKey combo you setup for help (I like F9), the AutoIt help file will launch, and the ConsoleWrite function reference page will be right there in front of you. Very Handy!
I usually leave the help file running, and just ALT-Tab back to EditPlus. If it's still running, subsequent help queries will simply bring it to the front.
EditPlus tricks for coders..
EditPlus has a lot more fun up its sleeve when it comes to AutoIt coding..
Remember the simple Function Pattern; "func"; that we put in our AutoIt file type? That wasn't for no reason..
Go to Search >> Function List, and will get a pop-up window with all your functions. Double-click any one of them (or select it, and choose 'Go to'), and your trusty editor will take you straight to that function (closing the function list window in the process). Neat. This is something else you will probably want a keyboard shortcut for; that's easy to in EditPlus.
Think of this as a snippets library for your code. There are loads of these available for downoad at the EditPlus site, and you can easily make your own (same goes for syntax files and most other EditPlus custom files).
While downloaded cliptext libraries are good, the best ones are the ones you make yourself, and this is drag-and-drop easy. Simply select some code, and drag it into the cliptext library. A window will pop up asking you to give the item a name, and you're done.
This is something I've just started using, though it's been available for a while. Briefly, EditPlus enables you to group files into "Projects" and do meaningful things with the entire group, like load them all into the editor together. You can switch between projects from the main Projects menu, or the 'almost hidden' menu in the far-left of the tabbed window list. My tabs are at the bottom, though the default is top, I think.
The projects facility is proving to be handy. You can even set the window order in the project prefs; something I find very useful, expecting a particular windows to be 'right there'. Every little helps.
More Handy Stuff..
Bracket Matching (Search >>Match Brace)..
Click on a bracket, and its matching bracket also gets highlighted. This happens all the time, and you just get used to using it. More than that, you can also click in any old place and EditPlus will seek the nearest brace for you. This is amazingly handy. I have it set to F5. And for F6 I have..
Bracket Matching 2 (Search >>Select Brace)..
I most often use this for navigation. click somewhere, hit F6 (my shortcut for this) and then use the arrow keys to get to either end of the bracketed code.
I came across this about a year ago and use it thousands of times a day. Simply hold down the Ctrl key when you click a word, and the whole word gets selected. I'l do anything to avoid double-clicking, and this is a real boost.
Note: Whatever is set as your delimeter in your sytntax file, will define the boundries of what is selected when you hold the Ctrl key. You can use this to your advantage. For example, in my syntax file for .md5 files, I have only "*" as a delimeter, and I can basically select the entire filename with one click. Note that space is always a delimeter.
Comprehensive Format commands
I could do a whole page about these. Like most text editors, you can select some text, and then hit Tab to indent it, and Shift-Tab to unindent it. On top of this, EditPlus also enables you to easily, trim, join, split, align, and you name it! The one I use most often is "Reformat", which needs you to have the word-wrap setup correctly (hint: even if you don't actually USE word-wrap); but once it is, Wow! …
If you ever write plain text, trying to keep things within a certain line width, I'm sure you'll appreciate the problem that arises then you want to insert something; you need to chop off the end of that line to make it fit, and add that text to the next line, which is now too long, and needs chopped, which is added to the next line, and so on, and so on, all the way to the end of the paragraph. I used to do this manually! Now it's ALT-Q, and I use it a lot
I don't use word-wrap for AutoIt code, but whatever you set as your word-wrap value is used for the Reformatting. This means you can have nice wide pages of code (my editor wraps around 150 characters) and keep the notes parts nice, tight, 80 character block. The Reformat command can be used to tame all sorts of paragraphs. Very handy.
This is another one of these things that I've so taken for granted, that it's only when I unthinkingly try it in another application - AND IT DOESN'T WORK! that I remember that it's an EditPlus-Only feature…
You search for words. If you are anything like me, you do this a zillion times a day. Old-School methods go along the lines of.. double-click the word, Hit F3, hit enter. Well, we already know that Ctrl-clicking a word will select the whole word (as defined by our delimeter boundries), so that would save one click. But it's even easier that that..
"Find Next Word". I recommend you set it to ALT-F3, and from now on, you just click anywhere inside a word, and do ALT-F3, and Editplus jumps to the next
instance of that word, selects it. ALT-F2 is plugged into "Find Previous Word", and between them, I save lots and lots of time finding stuff.
There may actually be a limit, but I've not seen it. What I HAVE seen is me holding down Ctrl-Z for so long that I rewind a script back through two weeks of evolution (kinda zippy to watch), copy some long-lost code, and then Ctrl-Y (or whatever) to Redo all the way back to the current version. So it must be thousands and thousands of levels of undo! Probably limited only by available memory, or something like that.
It's probably because I have a macro engine running full-time on my Windows dekstop, that I haven't explored EditPlus' macro features a great deal. A macro is basically a keystroke recording that you can play back at any time, usually with a keyboard shortcut. EditPlus also allows playback of multiple macros together.
But although I use Macro Express
for all my macros, I do have one permanently plugged into EditPlus, and that is "Toggle Undo", simply me doing "Ctrl-Z Ctrl-Y", which sounds devastatingly simple, but does one very useful thing.. moves your cursor to the last thing you did.
You can either see the immense usefuless of this, or you can't.
(more to come...)