Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3860

    Rohit
    Member

    Konbanwa Emura san! :)

    Is it possible to comment / uncomment the current line in a document when no text has been selected on that line?

    I can see the commands “Comment” and “Uncomment” in “Edit” | “Convert Selection,” but they are disabled unless some text is first selected.

    Thanks,
    Rohit

    #3863

    Yutaka Emura
    Keymaster

    It is a specification that text must be selected before you can select each command in Convert Selection sub menu. However, it is possible to make it an option if many users like that way.

    #3906

    Simon
    Member

    It makes sense for this option to be in the “Convert Selection” menu when you wish to comment multiple lines. However, it becomes restrictive when commenting just the current line. For correctness, I would suggest keeping the option as it is but also adding new options to the “Advanced” menu: Comment Line and Uncomment Line. They would fit nicely with the other options in that menu such as Duplicate Line.

    #3907

    Yutaka Emura
    Keymaster

    If you have EmEditor Professional, you can write a macro like this (JavaScript):

    var bEmpty = false;
    if( document.selection.IsEmpty ){
    editor.ExecuteCommandByID(4154); // Select line if not selected
    bEmpty = true;
    }
    editor.ExecuteCommandByID(4371); // Comment. Use 4372 for Uncomment.
    if( bEmpty ){
    document.selection.Collapse();
    }

    This macro can comment selected lines if selected, or comment the current line if not selected.

    Then you can customize menus to insert this macro to anywhere you would like.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.