Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22622
    ldm
    Participant

    Hi All,

    How can I define a shortcut/key to TOGGLE comments? I know I can define different shortcuts to comment and uncomment lines, but is it possible to define a single shortcut to toggle comments (as I use in others editors)?

    Thank you!

    #22624
    Patrick C
    Participant

    I wrote a macro for this purpose. However, it is customised according to my preferred behaviour, i.e.:
    1) Only single line comments (you can select multiple lines and comment them all at once, but only with a single line comment on each line).
    2) Comments always start on column 1 (the beginning of the line).

    Should this suit your needs:
    2017-11-18_line_comment_toggle.jsee
    Just add the macro to the My Macros list and assign a shortcut.

    Hope this helps.
    Patrick

    PS Getting users to agree on toggle comment on/off behaviour is tricky business.

    #22625
    ldm
    Participant

    Thanks a lot! I tried the macro and it works just fine (despite some delay about 1sec in execution…)!
    BTW, is there a way to reduce this execution delay? Are all macros suffer from execution delay? Is there a way to make them a part of the edior code?

    #22626
    Patrick C
    Participant

    some delay about 1sec in execution

    Strange – on my PC with Emeditor version 17.2.4 the macro executes without any delay.
    And its not that sluggish – just tested commenting 128’000 lines of a 1096 kB file.
    Adding comments takes <0.1s, but removing comments takes 1.7 seconds for 128’000 lines.
    Removing comments is slow because the algorithm checks each line in order to properly cover special cases.

    is there a way to reduce this execution delay?

    Try running the macro without using the shortcut. In some cases the choice of shortcut key can lead to an execution delay

    all macros suffer from execution delay?

    None of mine do (i.e. at least on both my PC and my laptop).

    Is there a way to make them a part of the edior code?

    You can ask Yutaka, but as I hinted, making a comment on/off behaviour which suits all users is not as straightforward as it initially may seem.
    Perhaps writing your own compiled DLL to use as a plug-in might also speed up the code. So far doing this isn’t necessary for me.

    #22627
    ldm
    Participant

    OK, actually the time delay is just for the first time when the macro is get executed. after that there is no a time delay…. Probably for the first time the macro is loaded to the memory and this add about 1sec delay in the execution. after that there is no delay (also for the macro shortcut execution).

    Again, thank a lot for sharing your macro!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.