Continue a select if in selection mode, else start select

Help with writing and playing macros

Continue a select if in selection mode, else start select

Postby StaticGhost » Thu Apr 07, 2005 8:33 pm

Hi All!

I want a macro that can act like control+shift+leftArrow or control+shift+rightArrow. If no text is selected then I want it to start selecting, but if there is already text selected then I want the macro to extend/reduce the selected text appropriately.

Here is my very simple macro so far:
InsertMode
ColumnModeOff
HexOff
UnixReOff
StartSelect
Key Ctrl+LEFT ARROW

The problem is that every time I run it, it starts a whole new select.

Is there any way around this?

Any help is most appreciated!

Rob
:)
User avatar
StaticGhost
Basic User
Basic User
 
Posts: 35
Joined: Sun Nov 21, 2004 12:00 am

Re: Continue a select if in selection mode, else start selec

Postby palou » Wed Jun 22, 2005 7:13 am

Hi StaticGhost,

You can try this macro:
Code: Select all
UnixReOn
IfSel
Find RegExp Up Select "."
Else
StartSelect
Key LEFT ARROW
EndIf
User avatar
palou
Basic User
Basic User
 
Posts: 46
Joined: Fri Dec 17, 2004 12:00 am
Location: Geneva / Switzerland

Re: Continue a select if in selection mode, else start selec

Postby StaticGhost » Thu Aug 03, 2006 11:12 am

Hi Palou,

Well, your suggestion got me a lot closer to the goal. :)

Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOn
IfSel
Find RegExp Select "[^\da-zA-Z]"
Else
StartSelect
Key Ctrl+RIGHT ARROW
EndIf


Problem is that the behaviour I was after is like these two Word macros:

Sub SelectWordBack()
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
End Sub
Sub SelectWordForward()
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
End Sub

So it would select up to but not including the next "[^\da-zA-Z]" - plus I can write one to do it backwards!

*world weary sigh*

Thank you very much for your suggestion. :)

Rob
:)
User avatar
StaticGhost
Basic User
Basic User
 
Posts: 35
Joined: Sun Nov 21, 2004 12:00 am

Re: Continue a select if in selection mode, else start selec

Postby palou » Thu Aug 03, 2006 1:06 pm

Hi Rob,

I know it's not perfect but this is another step in the right direction :wink:

Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOn
IfSel
Find RegExp Select "[\w]*"
Else
StartSelect
Key Ctrl+RIGHT ARROW
EndIf



Unfortunately for the backward (left) search it doesn't seem
to work well (perhaps a bug in the implementation?).

HTH (Hope This Help).

Regards from Switzerland.
User avatar
palou
Basic User
Basic User
 
Posts: 46
Joined: Fri Dec 17, 2004 12:00 am
Location: Geneva / Switzerland


Return to Macros