Forum Replies Created

Viewing 25 posts - 51 through 75 (of 85 total)
  • Author
    Posts
  • in reply to: Add option to scroll window instead of moving cursor #22763
    Patrick C
    Participant

    Emeditor’s default shortcut for this is ctrl + ↑ and ctrl + ↓

    Speaking of which:
    Back in the old days the scroll lock key would do this, but these days that functionality seems to be almost extinct.

    in reply to: Question of "User menu 1-9"? #22725
    Patrick C
    Participant

    You have to manually add them to a menu entry or toolbar icon; or assign a shortcut.

    By default User Menu 1 is assigned to ctrl+k :
    http://www.emeditor.org/en/cmd_tools_user_menu1.html

    As far as I understand (and the way I use them) is that the user menus will appear at the cursor location, similar to right clicking, but with different menu options.

    To assign a shortcut / button / menu entry to a user menu, you will find them under
    Category: Tools
    Commands: User Menu (x)

    PS Let me know if you need further detail

    Patrick C
    Participant

    Sounds like macro to me.

    Paste the following two lines in a file and save as yourChoiceOfFileName.jsee

    document.selection.Paste();
    document.selection.NewLine(1);

    Add the file to the MyMacros list you’ll find under Macros → Customise.

    You can then assign a shortcut under Tools → Properties for All Configurations → Keyboard → Category: MyMacros

    in reply to: copying nothing #22650
    Patrick C
    Participant

    This is because by default ctrl+C is assigned to Edit → Copy

    Assigning ctrl+C to Edit → Copy Selection should solve your issue.

    Reassign by:
    Tools Properties for All ConfigurationsKeyboard Category: Edit + Commands: Copy Selection + hit ctrl+C in the Press New Shortcut key box + then click Assign

    This should solve your problem (it does on my machine with EmEditor Professional (64-bit) Version 17.2.5 and Windows 10 Version 1709).

    Patrick

    in reply to: shortcut/key to toggle comments #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.

    in reply to: shortcut/key to toggle comments #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.

    in reply to: How to include other macros DYNAMICALLY from macros? #22600
    Patrick C
    Participant
    in reply to: How to include other macros DYNAMICALLY from macros? #22599
    Patrick C
    Participant

    So far I used the Windows Registry «semi-hack ‘solution’», the following is an example:

    In script 1:

    var WshShell = new ActiveXObject( "WScript.Shell" );
    
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\str1", "ab cd",  "REG_SZ"    );
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\str2",  "1234",  "REG_SZ"    );
    WshShell.RegWrite( "HKCU\\_Patrick_custom_\\num1",   1234 ,  "REG_DWORD" );
    
     editor.ExecuteMacro( “d:\\script2.jsee”, eeRunFile | eeMacroLangJScript );

    In script 2:

    var WshShell = new ActiveXObject( "WScript.Shell" );
    
    var str1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str1" );
    var str2 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str2" );
    var num1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\num1" );
    
    OutputBar.writeln( "str1     = " + str1                                                                      );
    OutputBar.writeln( "str2 + 1 = " + (str2 + 1)   +  "  // an imported string is not automatically a number"     );
    OutputBar.writeln( "num1 + 1 = " + (num1 + 1)   +  "  // an imported DWORD really is an integer"               );

    Hope this helps

    in reply to: Serious bug regarding macros mapped to shortcuts! #22590
    Patrick C
    Participant

    Now I recall – I had to reassign the macro shortcuts after the bug was fixed.

    In my case this wasn’t too bad an issue as I have a list of my custom shortcut settings. EmEditor isn’t the only program where my custom shortcuts got reset after updating (LibreOffice was another recent one) so over time I learnt – it remains annoying nevertheless.

    in reply to: Serious bug regarding macros mapped to shortcuts! #22588
    Patrick C
    Participant

    Are you using the latest version (17.2.2)?

    As far as I can remember this was one of the early v17.0 perhaps also v17.1 bugs which were fixed with ≈ v17.1 or v17.2.

    I btw just re-tested on v17.2.2 – in my case this error doesn’t occur.

    in reply to: How to include other macros DYNAMICALLY from macros? #22586
    Patrick C
    Participant

    Executing macros is simple:
    editor.ExecuteMacro( “d:\example.jsee”, eeRunFile | eeMacroLangJScript );
    http://www.emeditor.org/en/macro_editor_editor_executemacro.html

    However, I don’t whether or not dynamical includes are possible.

    Patrick C
    Participant
    Patrick C
    Participant

    Just tested and implemented in my save macro – Version 17.2.1 now trims the cursor’s line when using the Delete Spaces at End of Lines command :)
    For large files this is much more efficient than document.selection.Replace( “[ \t]+$”, “”, eeFindReplaceRegExp + eeReplaceAll );
    (tested with a 100 MB file having 2 million lines).

    My save macro now is

    editor.ExecuteCommandByID(4278);         // Delete Spaces at End of Lines command
    editor.ExecuteCommandByID(4099);

    I think this is a good compromise solution.
    Thank you Yutaka!

    Patrick C
    Participant

    Not really as I just used to hit ctrl+s to both trim and save.

    However I’ve just written a macro and assigned ctrl+s to achieve the same effect:

    document.selection.Replace( "[ \t]+$", "", eeFindReplaceRegExp + eeReplaceAll );
    editor.ExecuteCommandByID(4099);

    So if its too much trouble for you, I can stick with the macro as an alternative solution.

    Patrick C
    Participant

    Thank you Yutaka!

    Patrick C
    Participant

    Hello Yutaka,

    Basically I selected with the keyboard (ctrl+F8 for line; shift + end + arrow right for stream)
    Written as macro code this would be:

    to select in line selection mode
    editor.ExecuteCommandByID(4154);

    To select in stream selection mode
    document.selection.StartOfLine(false,eeLineView | eeLineHomeText);
    document.selection.EndOfLine(true,eeLineView);
    document.selection.CharRight(true,1);

    Importance of virtual space
    I now noticed, that a visually (images of the first post #22457) identical selection made in stream selection mode is only different from line selection mode when virtual space is enabled.

    To me it will remain confusing, that BottomPointY – TopPointY covers n+1 lines when only n were selected with CommandID(4154). Nevertheless, I’ll be fine as long as I can count on this (n+1 lines) consistently being the case when the selection’s last character is a new-line character.

    Thanks!
    Patrick

    Patrick C
    Participant

    Ok, figured out one consistency in this:
    If the last character of the selection is a newline character (or the last two are CR+LF), then BottomPointY will be one line below the actual selection.

    With one exception:
    When the last line is empty but line-selected,
    last line empty + line selected
    then the last character of that selection is not a new line character but BottomPointY still is one line beyond the end of the selection.

    Provided future EmEditor versions will continue to have have this BottomPointY behavior, my issue should be solved as I now can simply test whether the last character is new-line or not.

    in reply to: Command ID for “Remove from this (favorite) list” #22452
    Patrick C
    Participant

    Hello Yutaka,

    Thank you for your reply!
    It seems however, that
    editor.ExecuteCommandByID(4465);
    doesn’t really achieve anything.
    Probably this is what you meant with “not available for keyboard shortcut assignment”.

    It would be nice to have something analogous to:

    editor.ExecuteCommandByID (4609 + i); // i is an integer from 0 through 63 (List of Recent Documents command)
    EEID_FILE_MRU_FILE1 through EEID_FILE_MRU_FILE1 + 63 (from 4609 through 4609 + 63)
    Just with removing the file from the list instead of opening the file.

    Best regards,
    Patrick

    Patrick C
    Participant

    hit CTRL+SHIFT+F8 ; let go; then use the arrow up down keys

    See
    http://www.emeditor.org/en/features_box_editing.html

    in reply to: "Macros Toolbar" position problem #22408
    Patrick C
    Participant

    Have you tried dragging the toolbar back with the ↔ cursor?
    drag cursor

    Keeping the EmEditor toolbar locations at bay is tricky. My recommendation is to set your toolbar locations for the window size you usually work with (e.g. maximised on your main screen) and then lock their locations.
    In case you frequently hide and unhide toolbars: Set the locations with all toolbars shown, lock, then hide again.

    Lock by right clicking a toolbar:
    Lock by right clicking a toolbar

    in reply to: "Quick Launch" problems #22400
    Patrick C
    Participant

    This is odd – it works on my machine:
    Windows 10 with EmEditor Professional (64-bit) Version 17.1.2

    Quick launch history

    in reply to: \n is not replaced in 17.1.2 #22399
    Patrick C
    Participant

    I first panicked when I read this, but wasn’t able to reproduce it.

    Filter and replace for example works fine on my Windows 10 machine with EmEditor Professional (64-bit) Version 17.1.2

    Newline escape

    Patrick C
    Participant

    Dear LifeTimer,

    Sorry I wasn’t able to post this earlier, though better late than never…

    How to pass command line arguments using registry values without having to close EmEditor:

    Approach 1: using multiple command line statements

    reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ    /f /d "ab cd"
    reg add "HKCU\_Patrick_custom_" /v str2 /t REG_SZ    /f /d "1234"
    reg add "HKCU\_Patrick_custom_" /v num1 /t REG_DWORD /f /d 1234

    Regarding the syntax:
    // /v value name (“variable name”)
    // /t variable type: REG_SZ = string; REG_DWORD = 32-bit integer
    // /f force overwrite already existing value without prompting for Y/N
    // /d data to be written (“assigned to the variable”)

    to visualise the values in the registry:
    Registry

    then call the EmEditor macro
    "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee

    with the macro code being

    var WshShell = new ActiveXObject( "WScript.Shell" );
    var str1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str1" );
    var str2 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str2" );
    var num1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\num1" );
    alert( str1 );
    alert( str2 + 1 );   // an imported string is not automatically a number
    alert( num1 + 1);    // an imported DWORD really is an integer

    Approach 2: using one single command line statement
    If, and only if it really has to be a one liner:
    reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ /f /d "xyz" && "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee"

    I hope this will be of use for someone.

    Credits:
    https://www.windowscentral.com/how-edit-registry-using-command-prompt-windows-10
    http://www.emeditor.org/en/macro_tutorial_tutorial_regread.html

    Patrick C
    Participant

    Just worked on the same problem today – guess I was lucky

    The command line therefore is
    set myarg=blabla && start "" "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee

    The macro file code then is

    var she = new ActiveXObject("wscript.shell");
    myarg = she.ExpandEnvironmentStrings("%myarg%");
    alert(myarg);

    There is one important issue though:
    Emeditor must not yet run when calling. Most likely because once running it would only have access to environment variables which existed upon starting EmEditor

    Hope this helps
    Patrick

    PS Credits for those who brought me on the right path:
    https://www.emeditor.com/forums/topic/macro-scripting-importexport-of-filter-settings/
    https://stackoverflow.com/questions/21315708/reading-environment-variables-with-javascript
    https://superuser.com/questions/424001/launch-windows-program-with-custom-environment-variable

    Patrick C
    Participant

    Hello Yutaka,

    explain why

    To be honest: Because I’m lazy.
    I’d like to have a Runs at Events on/off button → 1 mouse click required
    Presently it take 4 mouse clicks to turn an event on and off.

    As I have to do this often, it does make a difference

    Regarding priorities:
    I don’t urgently need this – its more like a “very nice to have” convenience feature.

    Thank you for your great support!
    Patrick

Viewing 25 posts - 51 through 75 (of 85 total)