Continue a select if in selection mode, else start select

Continue a select if in selection mode, else start select

44
Basic UserBasic User
44

    Apr 08, 2005#1

    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
    :)

    46
    Basic UserBasic User
    46

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

      Jun 22, 2005#2

      Hi StaticGhost,

      You can try this macro:

      Code: Select all

      UnixReOn
      IfSel
      Find RegExp Up Select "."
      Else
      StartSelect
      Key LEFT ARROW
      EndIf
      
      Never forget: "Above the clouds, The sky is blue and the sun shine"

      44
      Basic UserBasic User
      44

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

        Aug 03, 2006#3

        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
        :)

        46
        Basic UserBasic User
        46

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

          Aug 03, 2006#4

          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.
          Never forget: "Above the clouds, The sky is blue and the sun shine"