EmEditor (text editor) Forum Index Macro Samples
Learning by doing: Loop through all lines | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| Stefan | Posted on: 11/2/2011 3:54 am |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 262 |
Learning by doing: Loop through all lines No useful script. Just an little lesion.
Loop virtually through all lines in file The cursor will not move! We access each line by its number only. - - - Best to learn is to do some lessons. So i will show my steps creating an macro for others. I am not saying that this is the best way to do it, it is just an start. If you have an better way to do it, or other suggestions, just reply |
| Stefan | Posted on: 11/2/2011 12:45 pm |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 262 |
Re: Learning by doing: Loop through SELECTED lines No useful script. Just an little lesion.
Loop virtually through only the selected lines in file. The cursor will not move! We access each line by its number only. - - - Best to learn is to do some lessons. So i will show my steps creating an macro for others. I am not saying that this is the best way to do it, it is just an start. If you have an better way to do it, or other suggestions, just reply |
| Stefan | Posted on: 11/2/2011 1:12 pm |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 262 |
Re: Learning by doing: Loop through SELECTED lines Some examples for <Your Code> section:
////Delete start of line (Remove first sign/char): redraw = false; document.selection.SetActivePoint( eePosLogical, 1, Line ); str = document.GetLine( Line ); if (str != "") { document.selection.StartOfLine(); document.selection.Delete(); } ////Delete end of line (Remove last sign/char): redraw = false; document.selection.SetActivePoint( eePosLogical, 1, Line ); str = document.GetLine( Line ); if (str != "") { document.selection.EndOfLine(); document.selection.DeleteLeft(); } ######################################## However, for just this task there would be an easier solution then such an big script as shown above: //Remove first sign from selected lines redraw = false; document.selection.Replace("^.","", eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); document.HighlightFind = false; //Remove last sign from selected lines redraw = false; document.selection.Replace(".$","", eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); document.HighlightFind = false; |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |


