Does EmEditor have a way to automate a workflow? My workflow involves a sequence of commands that could easily be automated if there was a way to do so.
1 Answer
The macro feature in EmEditor can automate a series of steps that otherwise need to be done manually. A macro is a JavaScript file that automates a sequence of EmEditor commands. If you have a task that requires a lot of clicking in EmEditor, a macro may reduce the amount of manual labor required.
To get started on a macro, you can record which buttons you click on in EmEditor, which will be written to a macro.
- Go to Macros | Start/Stop Record (or click on the Start Recording button in the toolbar).
- Now select the commands that you want to record in the macro. Click on Start/Stop Record or Stop Recording in the toolbar when you are done.
- Go to Macros | Edit (or Edit Macro in the toolbar). It opens a macro showing the series of commands that you called. Here is an example of a macro which sorts, replaces a string, selects all, then deletes.
document.Sort("A+",eeSortBinaryComparison | eeSortIgnorePrefix,"en-US");
document.selection.Replace("a","d",eeReplaceAll,0);
document.selection.SelectAll();
document.selection.Delete(1);
- Save the macro as a
.jsee
file. - Select the macro to run with Macros | Select... and open the
.jsee
file to run. Then run the macro with Macros | Run [yourMacro].jsee (or Run Macro in the toolbar).
You can now edit the .jsee
macro for complex tasks with variables, loops, functions, etc. The newer v8 engine can be used for the latest ECMAScript features.
See the macros documentation for all available functions for interacting with EmEditor. Some commands are not available as named functions but can be called with editor.ExecuteCommandByID()
by passing the command ID listed on every command page. For example, the Open command is editor.ExecuteCommandByID(4097);
.
Input and output
There are many ways to input and output information.
For inputting, you may get the selected text in the document as a string with document.selection.Text
. You can display an input control with var input = prompt("message", "", 0);
.
To output information, you can write to the current document with document.selection.Text = "text";
You can write a short message to the status bar with status = "Status text";
. You can display a dialog box with alert("Task complete.")
.
emeditor
for this question but I do not have 300 reputation. Could someone create this tag for me? EmEditor is a text editor app. If you search foremeditor
, you can see that there are a lot of questions already. We anticipate more questions to be asked about EmEditor on this site. Although SO has this tag, Super User is a better suited since the questions are primarily about the app and not programming.Notepad++
tag on SU so this does seem appropriate foremeditor