EmEditor (text editor) Forum Index Macro Samples
EmEditor TextApe :-) | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| Stefan | Posted on: 5/8/2012 12:07 pm |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 257 |
EmEditor TextApe :-) I collect here a few macros i have played with. I have them as Snippets always at hand. //Remove empty lines (incl. whitespace) - in Selection document.selection.Replace("^\\s*\\n","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Remove really empty lines only - in Selection document.selection.Replace("^\\n","",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); //Reduce many empty lines to one - in Selection document.selection.Replace("^\\s*$","",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); document.selection.Replace("(\\n\\n)\\n+","$1",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); //Reduce many blanks to one - in Selection document.selection.Replace(" \\s+"," ",eeFindNext | eeFindReplaceEscSeq | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //document.selection.Replace(" {2,}"," ",eeFindNext | eeReplaceAll | eeFindReplaceRegExp); //Remove every blanks - in Selection document.selection.Replace("\\s+","",eeFindNext | eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Remove leading blanks - in Selection //document.selection.Replace("^\\s+(.+)$","$1",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); document.selection.Replace("^\\s+","",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); //Remove trailing blanks - in Selection document.selection.Replace("^(.+?)\\s+$","$1",eeFindNext | eeReplaceAll | eeReplaceSelOnly | eeFindReplaceRegExp); //Remove first sign from selected lines redraw = false; document.selection.Replace("^.","", eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); document.HighlightFind = false; //Remove first non-blank sign from selected lines document.selection.Replace("^(\\s*).(.+)$","$1$2", eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Remove last sign from selected lines document.selection.Replace(".$","", eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Insert in front of selected lines Leader = prompt("What to insert in front?","// "); document.selection.Replace("^",Leader, eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Insert to the end of selected lines Trailer = prompt("What to insert to the end?"," //"); document.selection.Replace("$",Trailer, eeReplaceSelOnly | eeReplaceAll | eeFindReplaceRegExp); //Enclose selected word mySign = prompt( "Enter sign to enclose selection:", "%" ); selText = document.selection.Text; document.selection.Text = mySign + selText + mySign; ... |
| Stefan | Posted on: 5/9/2012 7:25 am |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 257 |
Re: EmEditor TextApe :-) The same (and more) as pop-up menu:
For example you can just press "Ctrl+Alt+M" + a to "Remove empty lines (incl. whitespace) - in Selection" As explained here http://www.emeditor.com/modules/newbb/viewtopic.php?viewmode=flat&topic_id=1879&forum=19 you can create your own menu in EmEditor, here e.g. an pop-up menu. To create your own pop-up menu follow this steps: 1. Copy the below code into EmEditor and Save as e.g. myMenu.jsee 2. Execute menu "Macros > Select This" to add this macro to My Macros 3. Assign an keyboard shortcut to launch this pop-up menu // Tools > Properties for all configurations > [Keyboard] // Category: My Macros // Commands: myMenu.jsee // Press new shortcut key: e.g. Ctrl+Alt+M // [Assign] // [OK] Now do: - open an test file - make an selection or press Ctrl+A - e.g. press "Ctrl+Alt+M a" to "Remove empty lines (incl. whitespace) - in Selection" Here is the macro code: |
| user | Posted on: 5/14/2012 1:52 am |
Home away from home ![]() ![]() Joined: 9/29/2006 From: Posts: 212 |
Re: EmEditor TextApe :-) congrats for the excellent topic, that should be sticky
as for: //Remove empty lines (incl. whitespace) wouldnt it be better to have \h, instead of \s? |
| Stefan | Posted on: 7/21/2012 8:02 am |
Home away from home ![]() ![]() Joined: 7/14/2008 From: Germany, EU Posts: 257 |
Re: EmEditor TextApe :-) Customizing the menu add own item Thanks user. Sorry, I missed this reply somehow.
I just want to share an idea i had for 30 minutes. Customizing the menu to add your own menu items. * Tools > Customize Menus... * choose here e.g. 'Main Menu' * click at the last item: '&Help' * click at [Insert Below] >> (o)Popup, Name: 'MyMenu' >> [OK] * click at the last item: 'MyMenu' * click at [Insert Right] >> (o)Command >> Category: My Macros >> Commands: TextApe.jsee >> [OK] > [OK] You should have an new main menu entry 'MyMenu' now after 'Help': |
| user | Posted on: 7/21/2012 9:17 am |
Home away from home ![]() ![]() Joined: 9/29/2006 From: Posts: 212 |
Re: EmEditor TextApe :-) Customizing the menu add own item thanks!
|
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |



