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

Re: keeping lines selected even after a filter has been applied.

Expand Messages
  • Tony Mechelynck
    ... You can use the :
    Message 1 of 8 , Jun 2, 2008
    • 0 Attachment
      On 03/06/08 00:04, Rahul wrote:
      > Normally after using a visual select followed by a filter, the
      > selected lines lose focus (i.e. no longer remain selected).
      > That makes it hard to reapply the same filter over and over on a block
      > of lines. Is there a way to change this behaviour for a certain
      > command.
      >
      > A concrete example:
      >
      > I write a filter "Rot" that rotates a molecule (defined by a block of
      > visually selected lines) in small increments:
      >
      > command -range=% -nargs=* Rot '<,'>!rot %<args>
      >
      > It might make sense for a user to keep repeatedly applying it to the
      > same block. Thus, I want to keep the block selected until, say, the
      > user presses the Esc key. Is there a way of achieving this? (Of
      > course, my filter does not increase / decrease the number of lines.
      > i.e. operates on n visually selected lines to produce n modified
      > lines)
      >
      > --
      > Rahul

      You can use the :'<,'> range even when no visual area is selected -- it
      means "from start line to end line of the _latest_ visual selection.

      Best regards,
      Tony.
      --
      ARTHUR: Be quiet! I order you to shut up.
      OLD WOMAN: Order, eh -- who does he think he is?
      ARTHUR: I am your king!
      OLD WOMAN: Well, I didn't vote for you.
      "Monty Python and the Holy Grail" PYTHON (MONTY)
      PICTURES LTD

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tim Chase
      ... And if * is not in cpoptions (which is the default), you can just use ... instead of ... which is a heckuva lot easier to type, given the number of
      Message 2 of 8 , Jun 2, 2008
      • 0 Attachment
        > You can use the :'<,'> range even when no visual area is selected -- it
        > means "from start line to end line of the _latest_ visual selection.

        And if "*" is not in 'cpoptions' (which is the default), you can
        just use

        :*

        instead of

        :'<,'>

        which is a heckuva lot easier to type, given the number of
        shiftings and unshiftings required for the more verbose variant :)

        :help cpo-star

        I'm not sure where I originally stumbled across this, but it's
        one that I've used for quite a while now and very few folks seem
        to know about it.

        -tim





        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tony Mechelynck
        ... It is mentioned in the help -- at :help cpo-star and at line 2285 of version5.txt. At several other places, however, :* is said to be a synonym of :@
        Message 3 of 8 , Jun 2, 2008
        • 0 Attachment
          On 03/06/08 05:11, Tim Chase wrote:
          >> You can use the :'<,'> range even when no visual area is selected -- it
          >> means "from start line to end line of the _latest_ visual selection.
          >
          > And if "*" is not in 'cpoptions' (which is the default), you can
          > just use
          >
          > :*
          >
          > instead of
          >
          > :'<,'>
          >
          > which is a heckuva lot easier to type, given the number of
          > shiftings and unshiftings required for the more verbose variant :)
          >
          > :help cpo-star
          >
          > I'm not sure where I originally stumbled across this, but it's
          > one that I've used for quite a while now and very few folks seem
          > to know about it.
          >
          > -tim

          It is mentioned in the help -- at ":help cpo-star" and at line 2285
          of version5.txt. At several other places, however, :* is said to be a
          synonym of :@ which is the 'compatible' setting since version 5.2.

          :'<,'> (which on my fr_BE keyboard includes only one shifted key) is
          mentioned at :help v_: as well as :help '< and :help '> -- and, of
          course, it shows itself whenever you hit : in Visual mode, which makes
          it quite obvious indeed.


          Best regards,
          Tony.
          --
          OLD WOMAN: Well, how did you become king, then?
          ARTHUR: The Lady of the Lake, her arm clad in the purest shimmering samite,
          held Excalibur aloft from the bosom of the water to signify by
          Divine
          Providence ... that I, Arthur, was to carry Excalibur ... That is
          why I am your king!
          "Monty Python and the Holy Grail" PYTHON (MONTY)
          PICTURES LTD

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Rahul
          On Jun 2, 9:00 pm, Tony Mechelynck ... Thanks (again!) Has vim thought of *everything*!? I m amazed! -- Rahul
          Message 4 of 8 , Jun 3, 2008
          • 0 Attachment
            On Jun 2, 9:00 pm, Tony Mechelynck <antoine.mechely...@...>
            wrote:

            > You can use the :'<,'> range even when no visual area is selected -- it
            > means "from start line to end line of the _latest_ visual selection.


            Thanks (again!) Has vim thought of *everything*!? I'm amazed!

            --
            Rahul
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.