Forum Replies Created

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
  • in reply to: snippets indentation bug and question #7824


    The bugs do seem to be fixed in the latest version. Thanks.

    Is there a way to get snippets triggers to work without the snippets sidebar open?


    You can do this with HTMLTidy. It has a clean-up mode that works specifically for xml. To attach HTMLTidy into emeditor, just run it like a regular scripting tool against the file you are currently editing.

    in reply to: save files with a custom name #6792


    Save the following example to h1_rename.jsee in your macro directory. Then open an html file that you want to rename. Run h1_rename.jsee while that file is open and the output file will be saved (copied) with the new name in the same directory.

    // helper function that we use to put the entire text of a file in a string
    // **************************************************
    function string_fromfile(sUrl){
    var ForReading = 1, ForWriting = 2, ForAppending = 8;
    var fso, fob;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    fob = fso.OpenTextFile(sUrl, ForReading);
    var strRead = fob.ReadAll();
    fso = null;
    return strRead;
    else if(e.message == 'Input past end of file'){return '';} // blank file
    else if(e.message == 'File not found'){return ''} // not found
    else if(e.message != ''){return ''} // other problem

    // main code
    // **************************************************
    stext = (string_fromfile(document.FullName));
    smatch = '';

    // look inside the raw text and see if we can find something inside the h1 tag
    amatch = stext.match(/<h1>([^<]+)<.h1>/);
    smatch = amatch[1];
    }catch(ex){ smatch = '';}

    // did we actually find something inside the h1 tag?
    if(smatch != ''){
    // fix what we found so that unwanted characters get changed into a dash
    smatch = smatch.split(/[W]+/).join('-');
    // extract the parent directory and combine it with what we found to form a new filename
    newname = (document.FullName.split(/x5c/).slice(0,-1).join("x5c") + "x5c" + smatch + '.htm');
    // save a copy of the document with its new name
    document.Save( newname );

    NOTE: Using this script could be cumbersome and annoying. The reason is because it would be tedious to open 100 files, one at a time, and then run this macro against the file. Therefore, you may want to modify this macro to loop through the directory, grab all the names and save the files. Another problem, however, is it may be annoying and cumbersome to have a script open EmEditor to do this.

    Therefore, the easiest way to accomplish this task may be simply to write a WSH script file and have it process the files in a without using EmEditor to do it. That’s probably how I would do it anyway.

    Nevertheless, you asked for an example and there it is!

    in reply to: FYAT… Find-As-You-Type for "Core" feature? #6790


    Greetings cjkawe,

    Here are some quick points:

    1) Generally, you do not have to duplicate a post in multiple parts of the forum. The EmEditor home page shows all recent posts regardless of the specific forum sub-area. One post should be enough for someone to catch your question eventually.

    2) EmEditor has the Highlight all feature, and there is also a “FindBar” plugin. I tried the FindBar plugin only once and then never tried it again, therefore I don’t have any details but you can try it yourself and see if it meets your requirements. For more details on the feature that works similar to Firefox CTRL+F, search for the following items in EmEditor help:

    — “highlight previously searched strings”
    — “HighlightFind Property”
    — “Erase Find Highlight command”

    If you include the double-quotes, the CHM help file will know you are searching for these exact phrases.

    in reply to: Request: Code Hinting #6774


    There are already a few options available in EmEditor:

    1) have you had a chance to look at the autocomplete plugin?

    2) have you had a chance to look at the wordcomplete plugin?

    One or both of these may come close enough to what you are looking for. If not, you might still be able to design something like this yourself using regular EmEditor macros, specifically with the “popup” menu feature therein.

    3) have you had a chance to see if macros can do this for you?

    I’ve already implemented a version of “dynamic snippets” that pretty much does exactly what you describe (unless I misunderstood you). The user types in a word and then presses tab key (or other shortcut key), and a snippet comes up based on that trigger word. If there is more than one snippet that has that trigger word as a substring, a menu appears to let the user pick which one they want to insert.

    For more details of what it looks like, watch the videos at:

    in reply to: Feature request: Outlining/highlighting nested blocks #6768


    This is a pretty interesting idea. Have you ever seen something like this actually implemented in a text editor before? The closest I have seen is “outlining” and “folding” which EmEditor already has.

    in reply to: Can we insert the content of a jsee file in a jsee file? #6765


    You can still do what you want if you make sure that standard.jsee encloses its code in a javascript function or a javascript class definition.

    For example:

    function say_hello(name){
    return “hello world from ” + name + ” ! ” ;
    // filename = say_hello.jsee

    #include “say_hello.jsee”

    var name = ’emeditor’;

    name = ’emacs??’;

    name = ‘vim??’;

    The #include feature of EmEditor is powerful enough to allow you to ‘insert’ code wherever you want as long as the code you are ‘inserting’ is correctly enclosed in a function or class, then you use the function or class to invoke the code you want to run at the exact place where you want to run it.

    in reply to: Customizable configuration order #6681


    Greetings wdscxsj,

    In case you had not already considered it, or in case anyone else reading this would like to know, another alternative would be to write a macro that you assign to a shortcut key, and the macro could contain only those configurations that you use on a regular basis.

    If you use the CreatePopupMenu Method, you can pretty easily create a list that contains only those configurations that you use regularly, and just have that menu create the new document. The nice thing about this is that you can edit the macro any time you like if you want to change the contents or the ordering of the list.

    in reply to: Code auto format (pretty-print) plugin #6680


    Greetings Maxim,

    This can be done very easily with a macro if you have a parser or processor that can be run from the Windows command line against a file via your own custom function.

    For example, you can pass the currently selected text to a function that cleans up the code for whatever default syntax you are using.

    mysyntax = document.ConfigName;
    mycode = document.selection.Text;
    myresult = MyCleanupSyntax(mysyntax,mycode);
    document.selection.Text = myresult;

    The hard part will be finding a code-formatter that you can plug into your MyCleanupSyntax function. I am sure there are plenty available for Java-style syntax.

    in reply to: Are there onKeyPress, onMouseClick or somethike like those ? #6656


    I don’t know if there is a way to trigger a macro with a mouse click, but you can trigger a macro using a keyboard shortcut. You can also use a single keyboard shortcut to trigger multiple choices for the user, so you do not have to restrict your macro to doing just one “action”.

    The following example uses the document.selection and the CreatePopupMenu function inside a jsee macro. The popup menu gives the user multiple choices before displaying the result.

    var vtext = document.selection.Text;
    var result = '';
    var menu = CreatePopupMenu();
    menu.Add( "look north", 1 );
    menu.Add( "look south", 2 );
    menu.Add( "look east", 3 );
    result = menu.Track( 0 );
    if( result != 0 ) {
    result = ( menu.GetText( result ) );
    Window.alert([result,vtext].join(' '));
    in reply to: EmEditor window redraw and "jittery" text and phantom scrollbar #6638


    Ok, the issue is resolved. The issue was apparently caused by the Outline plugin.

    The plugin was enabled with the option to display outline when the outline pane is closed. The problem can be solved by turning off the outline plugin or enabling outline only when the side pane is open.

    Thanks for your help.

    in reply to: macro to convert content to html? #6625


    Although this is not an example of converting html, it is an introduction to the “Run” feature of the windows scripting host:

    var shell = new ActiveXObject(“WScript.Shell”);
    shell.Run(“”C:Program FilesInternet ExplorerIExplore.exe””);

    This example will work on most systems to open MSIE. You can paste this into an EmEditor macro file and run it. The important point is that all macros in EmEditor are also scripts that you can run in regular Windows. This is useful because it means anything you can do from Windows, you can do it from inside EmEditor also.

    An example for converting html could be to create a macro that runs HTMLTidy against the currently-focused document in EmEditor, where you just pass the path to HTMLTidy and the path of the current document to EmEditor.

    For those who are not programmers, but willing to learn a little bit about Windows Scripting in order to get more out of EmEditor macros, a good thing to try is a search on your favorite search engine:

    “What is WSH”


    “What is Windows Scripting Host”

    If you are familiar with EmEditor macros, you are already familiar with WSH, so you may want to take a moment to read some of the tutorials and the reference from Microsoft.


    For this feature to be useful (to me anyway), all that would be needed is for EmEditor to check the “program root” directory for the file:


    and if the file is not found there, EmEditor could check:


    If the file is found in either of these two locations, EmEditor can assume the ini files are being used. If the file is *not* found in either of these two locations, EmEditor can assume the Registry. Using this approach would require only the small change to EmEditor that it checks in two places instead of just one.

    Of course, some windows applications also check in the “Documents and Settings” folder of the currently-logged-in user for windows, but I don’t need anything that fancy. All that’s needed (for me) is just a way to save the ini files in some directory besides the EmEditor program root without breaking the “use INI files” feature. If this directory is “hard coded” into EmEditor, that’s not a problem, just as long as its documented somewhere so I will know where I can put the ini files.

    Thanks for your reply and for considering this idea, best regards.

    in reply to: macro to convert content to html? #6615


    That makes sense. Just as a reminder (to others who may read this, in case you already know) EmEditor allows you to create a macro that runs an external script as well. This is a built-in feature of windows scripting host.

    You can mix EmEditor macro code with the code that someone else has written so that you never have to leave the editor to do anything you want. This means you never actually have to write custom code (ulness you prefer to do so of course).

    This aspect of EmEditor (direct support for windows scripting host) is really powerful, and as far as I have seen, unique for windows editors. Even editors that support macro scripting don’t usually integrate with the windows scripting host.

    It does get a little tricky if you try to use Ruby or Python ActiveScript engines, but the built-in javascript and vbscript support seems to work very well.

    in reply to: macro to convert content to html? #6612


    You might want to try a script that is designed for this purpose. One example is txt2tags.

Viewing 15 posts - 1 through 15 (of 22 total)