Forum Replies Created
- AuthorPosts
- Patrick CParticipant
I think I found the root cause:
With
Treat CR and LF Separately disabled
and radio button Regular Expressions enabled.EmEditor’s Find in Files will interpret \n as LF as soon as the search term contains a regular expression token or actual regular expression.
Without a regular expression token, EmEditor behaves as if performing a Escape Sequence type search, presumably because this will speed up Find in File’s performance.{ and } are regular expression tokens, but most engines will treat it as a regular character until written as a complete regular expression, e.g a{3} for aaa.
Most of this is in line with EmEditor’s Help, which states:
● Find dialog box → Regex on → \n or \r\n (same meaning)
I.e. \n will match both CR+LF and LF.
● Find in Files dialog box → Regex on → \r\n, \r, or \n (depends on actual newline character)
Elaborated further in EmEditor Help → Tips
which explains that \r strictly matches CR and \n strictly matches LF, …… what is not explained in help is that
1) the Find in Files regex search will fall back to an escape sequence search when the search term does not contain at least one regular expression token
2) escaped regular expression tokens as in\{
, are no longer identified as regular expression tokens, with Find in Files then performing an escape sequence type search.Patrick CParticipantHello David
Sorry, I should have read your initial question more carefully, as you did explain that To be strange , img \{\n works.
I just tested this with EmEditor Version 24.4.0.
When selecting Escape Sequence instead of Regular Expressions, both Find and Find in Files work with
img {\n
.When selecting Regular Expressions (with the Boost.Regex engine) …
… and with Treat CR and LF Separately deactivated …
… and searching forimg {\n
:
● The regular find (not in files) works, regardless of CR+LF or LF line endings.
● Find in files will not find CR+LF, but it will find LF line endings.After experimenting a bit …
When using Find in Files with Treat CR and LF Separately deactivated:
As soon as the Find term contains a { or a }, \n seems to exclusively find LF but not CR+LF. This even when { is followed by text before the \n.Example:
Line 1 { abcd Line 2 def { abc Line 3
● Find in Files searching for abc\n works with both LF and CR+LF line endings.
● Find in Files searching for def { abc\n works only with LF line endings.
Adding a closing bracket as inLine 1 { abcd Line 2 def {a} abc Line 3
won’t help either, i.e.
● Find in Files searching for def {a} abc\n works only with LF line endings.What also won’t help is a complete regex, e.g. find
ab{1}c\n
.
……
Its as if { or } behave as a token to let \n match LF but no longer match CR+LF, even when Treat CR and LF Separately is disabled.As to why this is: Good question.
I guess that this is for Yutaka to answer.Cheers,
PatrickPatrick CParticipantWith
\r = carriage return = CR
\n = line feed = LFNew line characters across different operating systems:
All Linux / Unix: Newline = line feed = LF = \n
Old Mac OS: Newline = carriage return = CR = \r
Modern Mac OS: Newline = line feed = LF = \n
Windows & MS-DOS: Newline = carriage return followed by line feed = CR+LF = \r\n
Modern Windows: Newline = carriage return followed by line feed = CR+LF= \r\n
↳ However, as of 2024 Windows applications are increasingly capable of dealing with LF only line terminators (even Notepad).Many tools, EmEditor included, can be configured to let \n detect all newline characters, regardless of type LF, CR+LF or CR.
I.e. you can stick to \n without having to bother about what the current file’s line terminator is.Should you want to use \r\n:
In the find dialogue: ClickAdvanced...
→Treat CR and LF separately
Advanced dialog box → Treat CR and LF Separately check boxPatrick CParticipantThe VBScript Command is
editor.ExecuteCommandByID 3916
EmEditor Help: Negative (Filter Toolbar) command——————————————————————-
The JavaScript above expressed as VBScript is#title = "Set the negative filter flag to inactive" #language = "VBScript" #async = "off" ' get the filter toolbar’s negative status (id 3916) Dim negFilterStatus negFilterStatus = editor.QueryStatusByID(3916) ' if negative is enabled -> disable by toggling If ((negFilterStatus And eeStatusLatched) = eeStatusLatched) Then ' case negative is enabled → run the toggle command editor.ExecuteCommandByID 3916 End If
——————————————————————-
VBScript code to set all filters to 0 is (its ugly, couldn`t think of something better):#title = "Set the negative filter flag to inactive" #language = "VBScript" #async = "off" ' reset the filters list Dim filtersList Set filtersList = document.filters filtersList.Clear filtersList.Add "dummy", False, 0, 0 ' add a single item with all flags set to 0 (off) document.filters = filtersList ' apply the filter → flags are now 0 filtersList.Clear ' remove the filter again (removes ‘dummy’) document.filters = filtersList ' empty filter + the flags stay as they are
——————————————————————-
Note that VBScript is deprecated.Patrick CParticipantCorrection: One must test for eeStatusLatched.
#title = "Set the negative filter flag to inactive" #language = "V8" #async = "off" // get the filter toolbar’s negative status (id 3916) let negFilterStatus = editor.QueryStatusByID(3916); // if negative is enabled → disable by toggling if ((negFilterStatus & eeStatusLatched) === eeStatusLatched ) { // case negative is enabled → run the toggle command editor.ExecuteCommandByID(3916); }
EmEditor Help: Negative (Filter Toolbar) command
EmEditor Help: QueryStatusByID MethodRegarding
(negFilterStatus & eeStatusLatched) === eeStatusLatched
EmEditor uses bitwise flags for statuses. The & is a bitwise and.Patrick CParticipant#title = "Set the negative filter flag to inactive" #language = "V8" #async = "off" // get the filter toolbar’s negative status (id 3916) let negFilterStatus = editor.QueryStatusByID(3916); // if negative is enabled → disable by toggling if ((negFilterStatus & eeStatusEnabled) === eeStatusEnabled) { // case negative is enabled → run the toggle command editor.ExecuteCommandByID(3916); }
EmEditor Help: Negative (Filter Toolbar) command
EmEditor Help: QueryStatusByID MethodRegarding
(negFilterStatus & eeStatusEnabled) === eeStatusEnabled
:
EmEditor uses bitwise flags for statuses. The&
is a bitwise and.Patrick CParticipantAutosave:
Save the document automatically at specified time intervals.
EmEditor Help: AutosaveBackup:
When saving existing files, save the original files into the folder specified in the Backup Folder text box.
EmEditor Help: Backup
→ Basically saves a backup copy of the old version on each save. To be truly useful the Rename if the Same File Name Exists check box should also be activated.Patrick CParticipantIs there a way to run a macro from a custom menu?
Are you referring to a custom menu bar entry (Tools → Customise Menus)?If yes: In my case this works. I can, for example, add
“M&y Custom Date” to the Insert menu and associate it with “My Macros → MyCustomDateMacro.jsee”Inserting MyDate then is possible via
Alt+I YPatrick CParticipantI just realised that this also allows querying the Num, Caps and Scroll lock states 🙂🙃😃
let iScrollState = 0; iScrollState = shell.GetKeyState(0x91); if(iScrollState === 1) { alert("Scroll Lock is enabled"); } else if(iScrollState === 0 ) { alert("Scroll Lock is disabled"); } else if(iScrollState === -127) { alert("Scroll Lock is enabled and its key is down, i.e. pressed"); } else if(iScrollState === -128) { alert("Scroll Lock is disabled and its key is down, i.e. pressed"); } else { alert("Unexpected Scroll Lock state:" + iScrollState); }
🙏 🙇
Patrick CParticipantI once had a similar problem and resorted to PowerShell:
Get-Content .\my_UTF8_file.txt | Set-Content -Encoding utf32 my_UTF32_file.txt
or
Get-Content .\my_UTF16_file.txt | Set-Content -Encoding utf32 my_UTF32_file.txt
Kudos to https://superuser.com/questions/1163753/converting-text-file-to-utf-8-on-windows-command-prompt
+ reference https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-content?view=powershell-7.4#-encodingPatrick CParticipantExample code (formatted version):
#title = "URL open or select" #icon = "C:\\Windows\\System32\\shell32.dll",135 #tooltip = "URL open or select" #language = "V8" #async = "off" // Self test: https://www.emeditor.com/ // Issue with control + single click: https://www.emeditor.com/forums/topic/control-click-triggers-double-click/ // PC, Version 1.0 "use strict"; bCtrlDown = shell.GetKeyState( 0x11 ) < 0; if( bCtrlDown ) { // OutputBar.writeln( '"'.concat(document.selection.Text, '"') ); shell.Run( "c:\\Program Files\\Vivaldi\\Application\\vivaldi.exe", 1, false, '"'.concat(document.selection.Text, '"') ); document.selection.Collapse(); }
Patrick CParticipantIn case someone runs into an error when installing EmEditor`s local help emed_help_en_24.2.0.msi (https://www.emeditor.com/download-help/):
I did first uninstall the old help. Nonetheless the error remained.
Solution:
Remove all remaining files in
c:\ProgramData\Emurasoft\EmEditor\Help\Patrick CParticipantOh thank you Yutaka 😃, I`m super grateful for this and for EmEditor as a whole – best text editor ever 😃 🙏 🙇
Patrick CParticipantThanks!
My only use would be the Active String ctrl modifier, just in case that’s easier.
But anyway, adding the modifiers just a suggestion, if you can add it: Great. If not: I’ll be fine and appreciate all the other features that are added instead.Patrick CParticipantRegarding the macro: I`m currently stuck with the condition on the pressed shift / alt / ctrl key.
See: https://www.emeditor.com/forums/topic/modifier-key-ctrl-alt-shift-is-was-pressed/Patrick CParticipantOk I’ll try to write a Macro sometime this week and will post it here.
Many thanks for considering!Patrick CParticipantIn my case it works fine.
Copy / pasting outputted
E:\ProgDB\EmEditor\Macros\Toggle_read_only.jsee \t 0x00000000 E:\ProgDB\EmEditor\Macros\insert_date_only.jsee \t 0x00000000 E:\ProgDB\EmEditor\Macros\insert_date_time.jsee \t 0x00000000 E:\ProgDB\EmEditor\Macros\insert_date_long_time.jsee \t 0x00000000 E:\ProgDB\EmEditor\Macros\delete_between_bookmarks.jsee \t 0x00000000
Where \t is the tab character.
It looks like the \t and 0x00000000 can be omitted from the list.
Pasting allows me to run the Macro, but when trying to edit them I get your “The following files do not exist error”. → Restarting EmEditor fixes this.Patrick CParticipantThough just noticed a shortcoming: Macro shortcuts are not or only partially preserved 😐
Patrick CParticipantWow, this is ultra-useful for me because sometimes my Macros end up in a mess and this makes cleaning up a whole lot easier 😃
Many thanks to spiros for asking the question and Yutaka for answering it!
Patrick CParticipantGlad I could help 😀
Thanks for the feedback!Patrick CParticipantI use the following .jsee macro, perhaps it helps (you could assign ctrl+shift+. to the macro, I use ctrl+D, which works reliably).
var date = new Date(); var dd = date.getDate(); // returns the day of the month (from 1 to 31) if( dd < 10 ) dd = "0" + dd; var MM = date.getMonth() + 1; // returns the month (from 0 to 11)! if( MM < 10 ) MM = "0" + MM; var yyyy = date.getFullYear(); // Returns the year (4 digits) // “Output” document.write( yyyy + "-" + MM + "-" + dd);
Patrick CParticipantI’ve got an old script that gets close, perhaps it helps.
// Inspired by & resources // https://www.emeditor.com/forums/topic/option-to-adjust-the-datetime-format-edit-insert-time-and-date/ // https://www.emeditor.com/forums/topic/insert-long-date/ // https://www.w3schools.com/jsref/jsref_tolocaledatestring.asp + jsref_getmonth.asp + jsref_getdate.asp function return_date_long_time() { var date = new Date(); // var n = d.toLocaleDateString(); // old approach - unreliable // Date assembly var dd = date.getDate(); // returns the day of the month (from 1 to 31) if( dd < 10 ) dd = "0" + dd; var MM = date.getMonth() + 1; // returns the month (from 0 to 11)! if( MM < 10 ) MM = "0" + MM; var yyyy = date.getFullYear(); // Returns the year (4 digits) // time assembly var hh = date.getHours(); // Returns the hour (from 0-23) if( hh < 10 ) hh = "0" + hh; var mm = date.getMinutes(); // Returns the minutes (from 0-59) if( mm < 10 ) mm = "0" + mm; var ss = date.getSeconds(); // Returns the seconds (from 0-59) if( ss < 10 ) ss = "0" + ss; // “Output” return( yyyy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss ); } document.write( return_date_long_time() );
Patrick CParticipantSorry, not done yet.
The cursor’s colour is set analogously by the “Selection” property (second entry from top on my installation).Patrick CParticipantMenu bar:
Tools → Properties for all Configurations → Display → Scroll way down and select “Search string” → Select the […] located next to the background colour combobox.Cheers
PatrickPatrick CParticipantYes, its displayed on bottom left part of the status bar:
Menu Bar → View → Status barThe only annoying thing is that the Find/Replace dialogue will not show you the number of found strings, but it will show the number of replaced strings.
In contrast the Find (without replace) dialogue allows you to count the number of finds.*) I’ll ask Yutaka if he could add the find dialogue’s count matches tickbox to the replace dialogue.
- AuthorPosts