Forum Replies Created
- AuthorPosts
- StefanParticipant
JavaScript code???
Try doubling the backshlash as that has a special meaning in JS.
>>> “C:\\install.ini”
“C:\install.ini” means: “C:” + “\i” + “nstall.ini”
“C:\\install.ini” means: “C:” + “\” + “install.ini”StefanParticipant“””have a footer with the line count of the highlighted lines”””
Try “Tools > Customize… > [Status] > [X] Number of Lines”StefanParticipantTested with beta 2: solved! Good work!
I will exchange my above linked video with a new one.
StefanParticipantHi Yutaka.
Since this is an often missed feature, I want to remind you on reconsidering this idea please.
Issue:
On performing an action, the selection goes lost and have to be re-select by hand again.
Wish:
Keep the coordinates and restore the selection for us.
Idea:
1) New option like Properties for xxx > General > “[X] Remember Selection” // Store the current selection coordinates for each document.
2) New Edit menu entry “Restore Selection” // Restore last made selection
3) New Macro command “document.selection.SelectLast();” // Restore last made selection
Further improvements for following-up versions:
– Save the selection coordinates for each document, based on the filename, to EmEditor settings.
– Store more than one last coordinates.
– improve macro command to”document.selection.SelectLast( nSelectionIndex );”Save e.g. as:
[Selections]
filename | last selection | second last | third …
test file.txt|1,56,233,72|1,56,200,0|
Thanks for making EmEditor.StefanParticipantExplanation video added > http://youtu.be/Uqrs42tOnlA
StefanParticipantGeneral description:
1. Paste in a CSV file ( no matter if semicolon or tab separated)
2. Be sure one column have quoted data with an line break.
3. Switch to CSV mode (semicolon or tab respectively)
4. Lines are joined and the “MJ ” are visible.
5. Switch back to Normal mode and some of the last lines are NOT switched back to multiple lines, but still have the “MJ” visible.
Details:
My first test was this semicolon separated example:
– Paste in the “example of the original data” from http://stackoverflow.com/questions/14396605/read-csv-file-with-embedded-newlines
– In EmEditor use User-defined separated = ;
– Lines are joined and the “MJ ” are there
– Switch to “Normal Mode” >>> only the first line is restored to multi-lines.My second test was with the example from above post too:
ID;Name Ver.;Lang
10;”Acrobat Vollversion
5.05″;German
My third test was this tab separated example:
1) paste a few lines of the “Suppliers” list from “http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_join_inner”
2) in “SupplierName” column add quotes and an line break where you want.(example below)
3) Switch to tab CSV mode.
4) Lines are joined and the “MJ ” are visible.
5) Switch back to Normal mode and some of the last lines are NOT switched back to multiple lines, but still have the “MJ” visible.
6) Add some more lines to the end and test again: now the “MJ” are transformed to line break.
7) Manipulate fourth or sixth last line again by adding quotes and line breaks.
8) Test again and you will see that the “MJ” are NOT transformed back to line break.
This happens always with just the last few lines.
I will create a video for better explanation…. tomorrow.
Examples from “Suppliers” list from “http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_join_inner”SupplierID SupplierName ContactName Address
1 Exotic Liquid Charlotte Cooper 49 Gilbert St.
2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934
3 Grandma Kelly’s Homestead Regina Murphy
SupplierID SupplierName ContactName Address
1 Exotic Liquid Charlotte Cooper 49 Gilbert St.
2 “New Orleans Cajun
Delights” Shelley Burke P.O. Box 78934
3 “Grandma Kelly’s
Homestead” Regina MurphyStefanParticipantHello Yutaka,
thanks for feedback!1) Yes, question about “Embedded newlines” is answered.
2)
>> “Match Embedded Newlines in CSV” check box from the Find dialog box <<
I think, after some more tests I understand this now:
This option works as a limitation to match CSV line breaks (MJ) ONLY,
and ONLY if we are in one of the CSV modes.
It will not match ANY line break if this option is enabled for Normal mode.With out that option enabled, search for line breaks will match everywhere.
(tested with above Stack Overflow example and RegEx search for “ul.+?ul”)
So I understand it as “Match CSV Embedded Newlines only”
Right?
BTW:
me think the “Match Embedded Newlines in CSV” check box
should be located under “Customize > CSV”
and not in the main Find dialog,
as that is an option only a few would need in an text editor.3)
>> Switching to “Normal Mode” only the first lineS are restored to multi-lines. <<
Some more investigation to the bug mentioned in my above first post:
After a few tests, it seams, always only the last five/ten lines
are involved and not transfered back to multi line mode.If I add for an test some more “last” lines,
the before last lines are transfered back correctly now.It seams your for statement if off by some indices?
HTH?
Thanks for making EmEditor.StefanParticipantAnd thanks for EmEditor v14.6.0:
“CSV > Fixed Width Columns” (keeps formating / the vertical alignment of columns)
StefanParticipantTest now “Match Embedded Newlines in CSV check box from the Find dialog box”.
Have:
ID;Name Ver.;Lang
10;”Acrobat Vollversion
5.05″;German
102;”Acrobat Elements Version 5.05″;German
2380;”Active Sync 3.7″;GermanSearch for “version.+5”
[x]RegEx
[x]Match embedded newlinesResult:
Found only 1 match: “Acrobat Elements Version 5.05”
Did not found “Acrobat Vollversion
5.05”
or
“Acrobat VollversionMJ5.05”No matter if in Normal Mode or User-defined separated = ;
Tested with emed32_14.8.901_portable.zip – and with functions from Find dialog only.
HTH? Thanks for making EmEditor.
—-
Forgot: The new feature “Remove Embedded Newlines” works for me..
StefanParticipantFirst: what are “Embedded Newlines in CSV”?
I found some answer there:
http://en.wikipedia.org/wiki/Comma-separated_values
(Fields with embedded line breaks must be quoted)and there:
http://stackoverflow.com/questions/14396605/read-csv-file-with-embedded-newlines“2030”;”NH Amersfoort”;”Stationsstraat 75″;”3811 MH AMERSFOORT”;”www.some-hotels.tld”;”Info line 1
Info line 2
Info line 3
Info line 4″– – –
Now I have test this new feature:
– Paste in the “example of the original data” from http://stackoverflow.com/questions/14396605/read-csv-file-with-embedded-newlines
– In EmEditor use User-defined separated = ;
– Lines are joined and the “MJ ” are there
– Switch to “Normal Mode” >>> only the first line is restored to multi-lines.– – –
Another test example:
ID;Name Ver.;Lang
10;”Acrobat Vollversion
5.05″;German
102;”Acrobat Elements
“;German
2380;”Active Sync
3.7”;German– UDS = ;
– Lines are joined and the “MJ ” are there
– Switch to “Normal Mode” >>> only the first lineS are restored to multi-lines.– – –
Tested with emed32_14.8.901_portable.zip – and with functions found on tool bar only.
HTH?
StefanParticipantif(document.selection.IsEmpty){document.selection.SelectWord()}
document.selection.ChangeCase(eeCaseCapitalize); //Title caseStefanParticipantWhy are there space right under “print”?
That indention should be only till the “p” of print.for i in range(1, 10, 1):
~~~~print i
~~~~ # where the line starts
I have tried, v0.01 adds an additionally blank line, making two of them.
V0.02 remove the indenting whitespace, leaving one blank line only.
Did you have enabled line numbers? I had got unintentional additional empty line too on pressing enter; the indented one and a additional line break.
Maybe that is what you see too?
Sorry, right now I see no issue here. But I will test some more later on…..StefanParticipantShavok
it does not work with the Auto Indentation activated
WHAT? do not work? I don’t see what you want to tell.The v0.02 just deletes auto-indented-whitespace from last line and use that last line as trailing empty line.
V0.01 adds an additionally blank last line first and deletes the auto-indented-whitespace from that new last line, ending up in two empty last lines.
Test with v0.02
Code:der Test
der Test
der TestA blank line is added.
Code:der Test
der Test
der Test
No line is added.
Code:der Test
der Test
der Test
~~~Trailing blanks are removed, left a blank line.
Code:der Test
der Test
der Test
~~~der Test
~~~der Test
~~~Trailing blanks are removed, left a blank line.
“~~~” indicates whitespace here.
“”does not work”” helps nobody. Tell what you get and what you had expect instead. That could led to improvement.StefanParticipantSorry, update again.
Better logic:
if last line have whitespace only, just remove these blanks and done.
Else, if last line is not empty, but not whitespace only, add a new line.
(This way we not end up with too “visible blank” lines)
I also added cursor handling to went back from EOF to origin cursor place.
(Not needed for this thread purpose as event script, but if script is used on demand)Not asked for, but just done for the fun:
//JavaScript Macro for EmEditor, v0.02 by Stefan //Purpose: Ensure that last line is a blank one, by adding one if need. //// Don't show the cursor move//// //EmEditor Help - EmEditor Macro Reference - Window Object //prevents changes in EmEditor from being redrawn: Redraw = false; ////Store cursor position//// //EmEditor Help - EmEditor Macro Reference - Selection Object //Returns the column number of the cursor position. xPos = document.selection.GetActivePointX(eePosLogical); //Returns the line number of the cursor position: yPos = document.selection.GetActivePointY(eePosLogical); ////Check status of last line//// //EmEditor Help - EmEditor Macro Reference - Document Object //Retrieves the number of the lines in the document: nLines = document.GetLines(); //Retrieves the text on the specified line: str = document.GetLine(nLines); //Moves the cursor to the end of the document: document.selection.EndOfDocument(); //If last line only contains indenting white space, just remove the whitespace// if(str.match(/^\s+$/) != null){ //Selects a line at the cursor: document.selection.SelectLine(); //Deletes the selected text: document.selection.Delete(); }else if (str.length != 0){ //If last line is NOT empty, but not whitespace only, add one blank line// document.selection.NewLine(); } ////Restore cursor position//// //Sets the cursor position: bExtendSelection = false; document.selection.SetActivePoint(eePosLogical, xPos, yPos, bExtendSelection); //<EOF>
StefanParticipantOh, you was faster than I?
I have just this moment worked on this too :
//JavaScript Macro for EmEditor, v0.01 by Stefan //Purpose: Ensure that last line is a blank one, by adding one if need. //EmEditor Help - EmEditor Macro Reference - Document Object //Retrieves the number of the lines in the document: nLines = document.GetLines(); //Retrieves the text on the specified line: str = document.GetLine(nLines); if(str.length != 0){ //If last line is NOT empty, add one blank line: document.selection.EndOfDocument(); document.selection.NewLine(); //Workaround: Delete automatically added indenting from line above,// //if line was not empty but indented by white space// //Selects a line at the cursor: document.selection.SelectLine(); //Deletes the selected text: document.selection.Delete(); }
StefanParticipantThere is nothing like that on the default settings dialog:
http://www.emeditor.com/forums/topic/automatic-saving-of-all-documents-as-lf-only/Me guess, the only way currently available, is to write a macro and enable the event “Before Saving” for that macro.
See a how-to >> http://www.emeditor.com/forums/topic/automatically-determine-xml-documents/
HTH? :DStefanParticipant\r is right, basically.
But for EE us rather \n, no matter if for CR or CRLFSee help
EmEditor Home – EmEditor Help – How to – Search
To Specify New LinesAn good indicator are also the line numbers (View > Line Numbers)
and also View > Marks > Returns
and View > Marks > CR and LF with different Marks.
July 11, 2014 at 11:49 am in reply to: Option to highlight entire line that cursor is currently on in wrapped line mode #18650StefanParticipantFYI
You can highlight the current line (not all wrapped) from menu
> Tools > Properties for xxxx Configuration… > [ Display ] > Part: Current line > Background color > CustomYou can identify wrapped lines for they have no line numbers (but depends on your settings)
For highlighting the whole wrapped line I have no solution I am afraid.
.
July 11, 2014 at 7:19 am in reply to: Option to lock first line when using CSV / TSV / DSV mode #18649StefanParticipant>>Option to lock first line when using CSV / TSV / DSV mode
It’s already possible:
– execute Window > Split
– split to two horizontal panes (put the vertical delimiter far to the right to not split vertically),
—- while making the top of both panels very small, so you just see the first lines.Now you can scroll the file in the lower pane as far as you like, while seeing the header line still in the upper pane.
.
.
StefanParticipantRethinking.
Optional restore selection after undo is cool.
But separate restore selection would be better because we often need to restore an selection for another operation, without an undo in between.
So please provide both, or at least the separate restore feature.
Thanks for making EmEditor-
StefanParticipantInteresting.
The above shown ways should do it. Well, at least with smaller files size.Unfortunately I can’t really test on my 32-bit system,… I have to many things running and not enough free memory for testing.
For an test I created a 581 MB text file with 130.000 x 4689 signs.
Open that in 32-bit EmEditor 14.4.0b2 shows this dialog:--------------------------- EmEditor --------------------------- This file contains a very long line. Very long lines will be split into several lines while the document is open, but will be recombined when saved. Highlighting very long lines is disabled, and some other features such as find and replace text containing CR or LF might not work correctly for very long lines. c:\temp\jsout.txt --------------------------- OK Abbrechen ---------------------------
and I ended up with 5 lines:
4x 134217729 chars
1x 072699089 chars“Wrap by Char” was disabled.
RegEx s&r allocated 1,2 GB and I canceled after 3 minutes.So I just quickly split the lines with SED.exe
c:\temp>sed -e “s/.\{4689\}/&\n/g” jsout.txt > jsoutSplitted.txtUnfortunately here I also run out of memory, but with a smaller file this works well.
So on a 64-bit system that should be no problem,…I will try tomorrow just out of curiosity.Code to create a test file (due to little memory I had to do a additional step as workaround)
Line=""; for(B=1, Bs=4689; B<=Bs; B++){ Line += "X"; } File=""; for(L=1, Ls=13000; L<=Ls; L++){ File += Line ; } fso = new ActiveXObject("Scripting.FileSystemObject"); oFile = fso.OpenTextFile("C:\\temp\\jsout.txt", 2, true) for(F=1; F<=10; F++) oFile.Write( File ); oFile.Close();
StefanParticipantHi slav.
You could utilize a macro script for that, which acts on event “File Opened”
Steps:
– save the macro as “DetectXML.jsee” to your EmEditor folder (I have a sub folder “Macros” created for that use)
– utilize “Macros > Select…” and select this new macro file to add it to MyMacros category.
– chose “Macros > Customize…”
– select the macro (at the end of the list),
– enable “[x] Run at Events”
– press at [Events…] and chose “[x] File Opened”
– ok
– ok
Test by opening an file containing XML structured text but lacks the XML extension (or not)The macro:
(you may want to delete the “alert()” lines)
if (document.selection.Find("<?xml",eeFindNext)){ alert ('xml file detected'); //this line can be delete alert("Current Configuration: " + document.ConfigName); //line can be delete document.ConfigName = "XML"; //switch configuration to XML alert("Configuration switched to: " + document.ConfigName); //line can be delete }
Could be improved with
strFirstLine = document.GetLine( 1 ); if strFirstLine.indexOf(“<?xml”)…..
to detect at top of document only.
.StefanParticipantAH, and I forgot the official way:
– Tools > Properties for current Configuration
– General > Wrap by Chars : 4689
OK
To make this permanent by insert real line breaks:
– Select All
– Edit > Convert Selection > Split Lines
If often need, this could be also stored as macro and added as Menu button or executed by shortcut key.StefanParticipantFor to create a macro you could do this:
– go to top of file
– go to start of line
– Macros > Start
– press right arrow key one time
– press Enter key
– Macro > Stop
– Macro > Edit (choose JavaScript)
– change ‘1’ to ‘4689’ for CharRight
– save file (to temporary file, (or to your EmEditor folder for later reuse)
– Macro > Select This
– go back to your document
– undo
– execute macro with temporary options– – –
To make the macro execution much more quicker, add this at top of the macro:
Redraw = false;
StefanParticipantRegEx could be a little bit slow (by its nature), but you may try this too:
Search & Replace
Find: (.{4689}\s)
Replace: \1\n
Explanation:
Find one piece of any sign (char, digit, sign) by the dot, and that at least 4689 times.
The \s ensures that we break at a whitespace only.
I don’t know why this works, as the normal syntax would be {4689, } ( {m,n}, so 4689 at least, but more possible till a whitespace is found)
But it works fine.Then we replace by what was matched into (…) back reference group and insert an line break. (\n is enough, even on DOS/Windows, see Help)
HTH? - AuthorPosts