Act on selected text

Help with writing and playing macros

Act on selected text

Postby JayPM » Fri Feb 25, 2005 11:03 am

I want to write a macro that acts on each line of the selected block of text.
If I select three lines, I want the macro to add a few characters to the beginning of each line. Anybody willing to provide a little help on how to do this?

Thanks in advance.

JayPM
User avatar
JayPM
Newbie
 
Posts: 3
Joined: Fri Feb 25, 2005 12:00 am

Re: Act on selected text

Postby mrainey56 » Fri Feb 25, 2005 1:25 pm

This is the general idea. If you leave the (.) out of the Find string, it puts the "added" string in twice. I don't know why.



InsertMode
ColumnModeOff
HexOff
UnixReOn
Find RegExp "^(.)"
Replace All SelectText "added\1"
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Act on selected text

Postby JayPM » Fri Feb 25, 2005 3:28 pm

Hmm.. so, I used your macro text and gave it a try.
This is my macro:

InsertMode
ColumnModeOff
HexOff
UnixReOn
Find RegExp "^()"
Replace All SelectText "//"
(add the two slashes to the beginning of each line - I'm editing
pascal source code, and I want to block comment lines out using UE)

In a source file I selected 4 lines and invoked the macro
and get a "Search String Not Found" error. Did I miss
something??
User avatar
JayPM
Newbie
 
Posts: 3
Joined: Fri Feb 25, 2005 12:00 am

Re: Act on selected text

Postby mrainey56 » Fri Feb 25, 2005 5:14 pm

Try this:


Macro > Edit Macro > Modify

Check the "Continue If A Find With Replace Not Found" box
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Act on selected text

Postby mrainey56 » Fri Feb 25, 2005 5:15 pm

Also, you left the period out in the search string, and the \1 in the replace string.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Act on selected text

Postby JayPM » Fri Feb 25, 2005 5:33 pm

InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "^(.)"
Replace All SelectText "//\1"

(and I made the switch) - but still nothing working.

-Jay
User avatar
JayPM
Newbie
 
Posts: 3
Joined: Fri Feb 25, 2005 12:00 am

Re: Act on selected text

Postby mrainey56 » Fri Feb 25, 2005 5:42 pm

Somehow you turned off Unix mode.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Act on selected text

Postby ASTTMan » Mon Feb 28, 2005 8:56 am

Do you realize that if you have syntax highlighting for Pascal, UE has a command to comment out (or uncomment) a block of text?

I added one line to my Wordfile.txt:

/L10"Pascal" Line Comment = // File Extensions = .psc

(I wasn't sure about the extension for Pascal!)

I made a test file with the .psc extension, then highlighted some lines, and did Edit | Comment Add.

There are probably full descriptions of Pascal that you can download to do all of the highlighting.

Dave
User avatar
ASTTMan
Basic User
Basic User
 
Posts: 26
Joined: Fri Feb 18, 2005 12:00 am
Location: Arlington, TX


Return to Macros

cron