EmEditor (text editor) Forum Index
   Questions and Answers about Macros
     How to make replaced text automatically selected
Register To Post

Threaded | Oldest First Previous Topic | Next Topic | Bottom
Poster Thread
Yutaka
Posted on: 12/1/2010 7:47 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: How to make replaced text automatically selected
Hi snovic,

Unfortunately, the macro recorder can only record keyboard activities in the editor. It can record mouse activities toward other applications, but it won't record mouse activities within EmEditor.

To delete selected text,

document.selection.Delete();


is the macro you need.

Please let me know if you have further questions.

Thank you,


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

snovic
Posted on: 12/1/2010 1:01 am
Just popping in
Joined: 11/25/2010
From: Serbia, Niš
Posts: 4
Re: How to make replaced text automatically selected
Many thanks Mr. Yutaka, now it works, finaly!

I am still interested in whether the activities of the mouse can be saved as macros. For example, open, and select options from the drop-down menu from toolbar, as for example replacing characters in a text file.
And specifically, can you make a macro that would delete (selected and) highlighted text.
Yutaka
Posted on: 11/29/2010 12:49 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: How to make replaced text automatically selected
Hi snovic,

eeFindSaveHistory is a new flag introduced on new version of EmEditor. I recommend you use the latest version of EmEditor, currently v10. If you need to use an old version, please remove "eeFindSaveHistory | " from the macro.

Thank you,


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

snovic
Posted on: 11/29/2010 4:20 am
Just popping in
Joined: 11/25/2010
From: Serbia, Niš
Posts: 4
Re: How to make replaced text automatically selected
Something is wrong again

http://photoserver.ws/images/2D2P4cf3a7a32ea21.png

probably I make again some mistake. I saved macro like "xsb Generator.jsee", maybe is that wrong? I use text configuration.
I must thank you again for your time and patiens, EmEdiror's help is brilliant, unfortynetly for me, with tehnical stuff I don't understand well.

Where to find aproved EmEditor macros, which I can download and use?
And at video section I can't find what I need, i.e. how to use macro with files from another aplications.
Yutaka
Posted on: 11/28/2010 12:42 pm
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: How to make replaced text automatically selected
Hi snovic,

You shouldn't use the macro recorder when you use my macro.
Please open a new file, paste the above macro, and save it as "a.jsee".
Please select "Select..." on the Macros menu to select this macro (a.jsee).
Then open a .xsb file, and click "Run Macro a.jsee" on the Toolbar.
I hope this helps.


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

snovic
Posted on: 11/27/2010 7:21 am
Just popping in
Joined: 11/25/2010
From: Serbia, Niš
Posts: 4
Re: How to make replaced text automatically selected
I supose, you write previous macro for me, thank you very much for your time and response.

Shall I copy this in Notepad with *jsee extension, or copy in EmEditor? I don't know how to save and use this macro.

I apologize, I never befor haven't used macros.

Update: I tryed to make macro in EmEditor with entering row by row from your file, with using enter for each row, and macro recorder activ with *jsee extension by save.
Result is something strange, which open several windows aplications at attempt to use it on file like on my first puzzle picture.
Probably I maked bad job.
Yutaka
Posted on: 11/26/2010 10:03 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: How to make replaced text automatically selected
I made a macro for you. Please let me know if you have any questions. Thank you!


document.selection.StartOfDocument(false);
document.selection.Find("^\\s*?<L>.*?</L>",eeFindNext | eeFindSaveHistory | eeFindAround | eeFindReplaceRegExp);
document.selection.CharLeft(false,1);
document.selection.StartOfDocument(true);
document.selection.Delete(1);
document.selection.EndOfDocument(false);
document.selection.Find("<L>.*?</L>\\s*?$",eeFindPrevious | eeFindSaveHistory | eeFindAround | eeFindReplaceRegExp);
document.selection.CharRight(false,2);
document.selection.EndOfDocument(true);
document.selection.Delete(1);
document.selection.Replace("^\\s*?<L>(.*?)</L>\\s*?$","\\1",eeFindNext | eeFindSaveHistory | eeReplaceAll | eeFindReplaceRegExp);


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

snovic
Posted on: 11/25/2010 3:00 am
Just popping in
Joined: 11/25/2010
From: Serbia, Niš
Posts: 4
Re: How to make replaced text automatically selected
Hi gays, this is my very first post at forum, and please don't be angry, because I don't know how to make new post (thread) and where.
Moderator will probably move this at right place.

I have this question about recording makro(s):

When in Sokoban for Windows 2.3 build 6 I save some game as *.xsb file, I have this situation

http://photoserver.ws/images/Bqnt4cee47932c50b.png

and I need this one

http://photoserver.ws/images/Yaqz4cee479351727.png

So, I need to remove all unnecessary caracters from file at first picture, to make file at second, to be able to load that file in Sokoban Puzzle solver v3.7.2

http://codecola.net/

I wish to record Macro which will remove unnecessary tekst from *.xsb files.
This is 5 operations:
1) Remove text above the first pair <L>...</L>
2) Remove text bellow the last pair <L>...</L>
For this I use Cut from menu
3) Remove all remaining <L> caracters
3) Remove all remaining </L> caracters
For this I use Search -> Replace ->Replase All, and than replace <L> and </L> with empty caracter
5) Save that file like *.xsb

Is it possable to make one macro for this, or I must use combination of several macros?
chjfth
Posted on: 9/26/2010 6:55 pm
Quite a regular
Joined: 10/20/2006
From:
Posts: 41
Re: How to make replaced text automatically selected
Thank you for replying. Hope you can provide an easy way to accomplish that. For example, add a flag to Replace so that replaced text is selected automatically.
Yutaka
Posted on: 9/26/2010 10:09 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: How to make replaced text automatically selected
Hello chjfth,

There is no easy way to do this, but I wrote this code for you:

if( document.selection.Find( "<(.+)>", eeFindReplaceRegExp | eeFindNext) ){
    x1 = document.selection.GetTopPointX( eePosLogical );
    y1 = document.selection.GetTopPointY( eePosLogical );
    x2 = document.selection.GetBottomPointX( eePosLogical );
    y2 = document.selection.GetBottomPointY( eePosLogical );

    sLine1 = document.GetLine( y2 );
    document.selection.Replace( "<(.+)>", "@\\1", eeFindReplaceRegExp);
    sLine2 = document.GetLine( y2 );
    x2 += sLine2.length - sLine1.length;
    
    document.selection.SetActivePoint( eePosLogical, x1, y1 );
    document.selection.SetActivePoint( eePosLogical, x2, y2, true );
} 


I am sorry, but this code doesn't support eeReplaceSelOnly flag. I still hope this helps.


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

(1) 2 »
Threaded | Oldest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文