Loading ...
Sorry, an error occurred while loading the content.

Re: Vim Commands over a range

Expand Messages
  • Tim Chase
    ... There s no need to reselect the range (with gv) if you don t have * in your cpoptions , as you can use * as a shorthand for
    Message 1 of 7 , May 3, 2005
    • 0 Attachment
      > selection, Vim automatically inserts "'<,'>", which means,
      > "start to the end of the selection". To repeat more than one
      > command on the same range, you can continue to use "'<,'>".
      > you can also use "gv" command (as long as you don't make
      > another selection, as vim remembers only the last selection at
      > any time) to reselect the original selection, and start
      > typing another command.

      There's no need to reselect the range (with gv) if you don't have
      "*" in your 'cpoptions', as you can use "*" as a shorthand for
      '<,'> such as

      first time:

      :'<,'>s/foo/bar/g

      subsequent times

      :*s/foo/bar/g

      which, if the search and replace expressions are the same, can be
      condensed further to

      :*&&

      which can be decoded as

      * the last selected range ('<,'>)
      & the same search/replace as before
      & with the same options as before.

      Ah, the fun one can have playing with obscure corners of vim :)

      -tim
    • Marian Csontos
      what a shame :-) is not a command. but :*& is nice too... -- Marian ... -- Mgr. Marián Csontos programátor POS AXA, a.s. Radnièné námestie 4 821 05
      Message 2 of 7 , May 4, 2005
      • 0 Attachment
        what a shame :-) is not a command.
        but :*& is nice too...

        -- Marian

        On Tue, 03 May 2005 18:51:23 +0200, Tim Chase <vim@...> wrote:

        >> selection, Vim automatically inserts "'<,'>", which means, "start to
        >> the end of the selection". To repeat more than one command on the same
        >> range, you can continue to use "'<,'>". you can also use "gv" command
        >> (as long as you don't make another selection, as vim remembers only the
        >> last selection at
        >> any time) to reselect the original selection, and start typing another
        >> command.
        >
        > There's no need to reselect the range (with gv) if you don't have
        > "*" in your 'cpoptions', as you can use "*" as a shorthand for
        > '<,'> such as
        >
        > first time:
        >
        > :'<,'>s/foo/bar/g
        >
        > subsequent times
        >
        > :*s/foo/bar/g
        >
        > which, if the search and replace expressions are the same, can be
        > condensed further to
        >
        > :*&&
        >
        > which can be decoded as
        >
        > * the last selected range ('<,'>)
        > & the same search/replace as before
        > & with the same options as before.
        >
        > Ah, the fun one can have playing with obscure corners of vim :)
        >
        > -tim
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > ________ Information from NOD32 ________
        > This message was checked by NOD32 Antivirus System for Linux Mail Server.
        > http://www.nod32.com
        >
        >
        > __________ Informacia od NOD32 1.1087 (20050503) __________
        >
        > Tato sprava bola preverena antivirusovym systemom NOD32.
        > http://www.eset.sk
        >
        >



        --
        Mgr. Marián Csontos
        programátor POS
        AXA, a.s.
        Radničné námestie 4
        821 05 Bratislava
        tel. +421 2 4829 4218
        mailto:csontos@...
        www.axa.sk



        ________ Information from NOD32 ________
        This message was checked by NOD32 Antivirus System for Linux Mail Server.
        http://www.nod32.com
      • Antony Scriven
        ... You might have to use your imagination a little! ... Also a quick cmap might be helpful if the range is structural rather than specific line numbers, e.g.
        Message 3 of 7 , May 4, 2005
        • 0 Attachment
          On May 04, Marian Csontos wrote:

          > what a shame :-) is not a command.

          :-> :-c :-P :-l :=| :-| :-/ :v) :@_ :v-\|

          You might have to use your imagination a little!

          > but :*& is nice too... [for repeating a sub over a
          > previous visual range]

          Also a quick cmap might be helpful if the range is
          structural rather than specific line numbers, e.g.

          :cno _ ?foo?;/bar/

          Antony
        Your message has been successfully submitted and would be delivered to recipients shortly.