Viewing 1 post (of 1 total)
  • Author
  • #9786

    Best to learn is to do some lessons.
    So i will show my steps creating an macro for others.

    I am not saying that this is the best way to do it, it is just an start.

    If you have an better way to do it, or other suggestions, just reply ;-)

    Take the HTML tag on the left and put an closing tag on the right.

    For example write| and execute the macro to get|

    Save this an EmEditor macro as *.jsee (JavaScript)
    or add it as an macro snippet into the snippet plugin
    and add an shortcut just as Ctrl+.


    ////HowTo: write an opening HTML tag (like: <html>) and execute this macro.
    ////Awaited: macro should write the closing tag for you. (e.g. </html>)

    ////////// Script:
    ////Pause update of the view till script is finished:
    Redraw = false;

    ////Store current cursor position:
    Line = document.selection.GetActivePointX( eePosView );
    Colu = document.selection.GetActivePointY( eePosView );

    ////Use find to find the opening angle bracket "<" of the tag on the left:
    ////Erase the highlighting of found strings:

    ////Select the word on the right of the opening angle bracket:
    ////Store this selected word into an var called TAG:
    TAG = document.selection.text;

    ////Jump back to start (behind open tag):
    document.selection.SetActivePoint( eePosView, Line, Colu, false );
    ////Or to EOL if you prefer:
    //document.selection.EndOfLine( );

    ////Add some text:
    document.selection.text = " </" + TAG + ">";

    ////Jump back to start (between open and close tag):
    document.selection.SetActivePoint( eePosView, Line, Colu, false );
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.