Forum Replies Created
- AuthorPosts
- January 10, 2018 at 12:12 am in reply to: Add option to scroll window instead of moving cursor #22763Patrick CParticipant
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.Patrick CParticipantYou 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.htmlAs 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
November 29, 2017 at 4:24 am in reply to: If possible to move the cursor to next line automatically after pasting? #22660Patrick CParticipantSounds 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
Patrick CParticipantThis 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 Configurations → Keyboard → Category: Edit + Commands: Copy Selection + hit ctrl+C in the Press New Shortcut key box + then click AssignThis should solve your problem (it does on my machine with EmEditor Professional (64-bit) Version 17.2.5 and Windows 10 Version 1709).
Patrick
Patrick CParticipantsome 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.Patrick CParticipantI 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.
PatrickPS Getting users to agree on toggle comment on/off behaviour is tricky business.
October 28, 2017 at 1:10 am in reply to: How to include other macros DYNAMICALLY from macros? #22600Patrick CParticipantbtw – for more information on WScript.Shell with RegRead and RegWrite:
https://msdn.microsoft.com/en-us/library/aew9yb99(v=vs.84).aspx
https://msdn.microsoft.com/en-us/library/x05fawxd(v=vs.84).aspx
https://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.84).aspxOctober 28, 2017 at 12:51 am in reply to: How to include other macros DYNAMICALLY from macros? #22599Patrick CParticipantSo 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
Patrick CParticipantNow 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.
Patrick CParticipantAre 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.
October 27, 2017 at 12:18 am in reply to: How to include other macros DYNAMICALLY from macros? #22586Patrick CParticipantExecuting macros is simple:
editor.ExecuteMacro( “d:\example.jsee”, eeRunFile | eeMacroLangJScript );
http://www.emeditor.org/en/macro_editor_editor_executemacro.htmlHowever, I don’t whether or not dynamical includes are possible.
October 26, 2017 at 11:52 pm in reply to: How to get the name of the currently executing EmEditor macro? #22585Patrick CParticipantIts ScriptName and ScriptFullName
October 21, 2017 at 6:51 am in reply to: Version [17.2] will not delete spaces at the current cursor line […] #22555Patrick CParticipantJust 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!October 19, 2017 at 12:43 pm in reply to: Version [17.2] will not delete spaces at the current cursor line […] #22544Patrick CParticipantNot 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.
October 19, 2017 at 12:39 pm in reply to: Increase / decrease line indent doesn't work when nothing is selected #22543Patrick CParticipantThank you Yutaka!
October 4, 2017 at 12:15 am in reply to: Bug or intended feature: doc*.selection.GetBottomPointY(eePosLogical) off by 1 #22460Patrick CParticipantHello 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!
PatrickOctober 3, 2017 at 10:10 am in reply to: Bug or intended feature: doc*.selection.GetBottomPointY(eePosLogical) off by 1 #22458Patrick CParticipantOk, 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,
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.
September 22, 2017 at 12:02 pm in reply to: Command ID for “Remove from this (favorite) list” #22452Patrick CParticipantHello 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,
PatrickSeptember 16, 2017 at 1:57 am in reply to: Question: Multi-Cursor select next line above/below via CTRL+ALT Key-UP/Key-DOWN #22441Patrick CParticipanthit CTRL+SHIFT+F8 ; let go; then use the arrow up down keys
Patrick CParticipantHave you tried dragging the toolbar back with the ↔ 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:
Patrick CParticipantThis is odd – it works on my machine:
Windows 10 with EmEditor Professional (64-bit) Version 17.1.2Patrick CParticipantI 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
September 7, 2017 at 8:36 am in reply to: How to provide parameters for macros executed from the command line? #22388Patrick CParticipantDear 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:
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.htmlSeptember 5, 2017 at 7:22 am in reply to: How to provide parameters for macros executed from the command line? #22359Patrick CParticipantJust 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 EmEditorHope this helps
PatrickPS 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-variableSeptember 1, 2017 at 3:19 am in reply to: Enabling / disabling Macro Events using a macro in EmEditor Version 17+ #22346Patrick CParticipantHello 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 - AuthorPosts