- November 17, 2017 at 4:39 pm #22622
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!November 18, 2017 at 12:43 am #22624
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:
Just add the macro to the My Macros list and assign a shortcut.
Hope this helps.
PS Getting users to agree on toggle comment on/off behaviour is tricky business.November 18, 2017 at 4:13 am #22625
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?November 18, 2017 at 6:49 am #22626
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.November 18, 2017 at 1:18 pm #22627
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!
You must be logged in to reply to this topic.