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

Save a selection

Expand Messages
  • shawn wilson
    My problem is that I often select a portion of code and do multiple ... and I need to select that area again if I want to replace something else. I can
    Message 1 of 8 , Oct 17, 2013
      My problem is that I often select a portion of code and do multiple
      :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
      and I need to select that area again if I want to replace something
      else. I can remember line numbers or put a mark at the end. Is there a
      way to save the selected area or a better way to do this?

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • LCD 47
      ... /lcd -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more
      Message 2 of 8 , Oct 17, 2013
        On 17 October 2013, shawn wilson <ag4ve.us@...> wrote:
        > My problem is that I often select a portion of code and do multiple
        > :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
        > and I need to select that area again if I want to replace something
        > else. I can remember line numbers or put a mark at the end. Is there a
        > way to save the selected area or a better way to do this?

        :help gv

        /lcd

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • David Fishburn
        ... Just type gv after the command finishes, and the visual selection will be re-selected. HTH, David -- -- You received this message from the vim_use
        Message 3 of 8 , Oct 17, 2013



          On Thu, Oct 17, 2013 at 8:48 AM, shawn wilson <ag4ve.us@...> wrote:
          My problem is that I often select a portion of code and do multiple
          :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
          and I need to select that area again if I want to replace something
          else. I can remember line numbers or put a mark at the end. Is there a
          way to save the selected area or a better way to do this?

          Just type gv after the command finishes, and the visual selection will be re-selected.

          HTH,
          David 

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
           
          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Ethan Hereth
          gv FTW!! I use this all the time. ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
          Message 4 of 8 , Oct 17, 2013
            gv FTW!! I use this all the time.


            On Thu, Oct 17, 2013 at 9:00 AM, David Fishburn <dfishburn.vim@...> wrote:



            On Thu, Oct 17, 2013 at 8:48 AM, shawn wilson <ag4ve.us@...> wrote:
            My problem is that I often select a portion of code and do multiple
            :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
            and I need to select that area again if I want to replace something
            else. I can remember line numbers or put a mark at the end. Is there a
            way to save the selected area or a better way to do this?

            Just type gv after the command finishes, and the visual selection will be re-selected.

            HTH,
            David 

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
             
            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
             
            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Ben Fritz
            ... Everybody suggested gv to reselect the area, I m surprised nobody mentioned that you don t NEED to reselect the visual area, nor do you need to manually
            Message 5 of 8 , Oct 17, 2013
              On Thursday, October 17, 2013 7:48:25 AM UTC-5, shawn wilson wrote:
              > My problem is that I often select a portion of code and do multiple
              >
              > :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
              >
              > and I need to select that area again if I want to replace something
              >
              > else. I can remember line numbers or put a mark at the end. Is there a
              >
              > way to save the selected area or a better way to do this?

              Everybody suggested gv to reselect the area, I'm surprised nobody mentioned that you don't NEED to reselect the visual area, nor do you need to manually set marks.

              Every time you create a visual selection, Vim automatically sets the '< and '> marks.

              So to run several sequential commands on the same visual selection:

              {make visual selection}
              :'<,'>FirstCommand
              :'<,'>SecondCommand
              :'<,'>ThirdCommand
              :'<,'>Etc

              Note that for FirstCommand, as soon as you press :, the marks '<,'> are inserted for you by Vim. The others you can enter manually or use command-line history to recall a previous command you can edit.

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • shawn wilson
              ... Well, it is what I asked for :) And I definately appreciate that - it ll come in handy when I yank something and realize I wanted more/less and the like
              Message 6 of 8 , Oct 17, 2013
                On Thu, Oct 17, 2013 at 9:53 AM, Ben Fritz <fritzophrenic@...> wrote:
                > On Thursday, October 17, 2013 7:48:25 AM UTC-5, shawn wilson wrote:
                >> My problem is that I often select a portion of code and do multiple
                >>
                >> :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
                >>
                >> and I need to select that area again if I want to replace something
                >>
                >> else. I can remember line numbers or put a mark at the end. Is there a
                >>
                >> way to save the selected area or a better way to do this?
                >
                > Everybody suggested gv to reselect the area, I'm surprised nobody mentioned that you don't NEED to reselect the visual area, nor do you need to manually set marks.
                >

                Well, it is what I asked for :)
                And I definately appreciate that - it'll come in handy when I yank
                something and realize I wanted more/less and the like to.

                > Every time you create a visual selection, Vim automatically sets the '< and '> marks.
                >

                For some reason, I just didn't think that was stored. No idea why. Thanks.

                > So to run several sequential commands on the same visual selection:
                >
                > {make visual selection}
                > :'<,'>FirstCommand
                > :'<,'>SecondCommand
                > :'<,'>ThirdCommand
                > :'<,'>Etc
                >
                > Note that for FirstCommand, as soon as you press :, the marks '<,'> are inserted for you by Vim. The others you can enter manually or use command-line history to recall a previous command you can edit.
                >
                > --
                > --
                > You received this message from the "vim_use" maillist.
                > Do not top-post! Type your reply below the text you are replying to.
                > For more information, visit http://www.vim.org/maillist.php
                >
                > ---
                > You received this message because you are subscribed to the Google Groups "vim_use" group.
                > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                > For more options, visit https://groups.google.com/groups/opt_out.

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Nikolay Pavlov
                ... mentioned that you don t NEED to reselect the visual area, nor do you need to manually set marks. ... and marks. ... inserted for you by Vim. The others
                Message 7 of 8 , Oct 17, 2013


                  On Oct 17, 2013 5:53 PM, "Ben Fritz" <fritzophrenic@...> wrote:
                  >
                  > On Thursday, October 17, 2013 7:48:25 AM UTC-5, shawn wilson wrote:
                  > > My problem is that I often select a portion of code and do multiple
                  > >
                  > > :%s/foo/bar/g (or /gc - whatever) after, the code selection disappears
                  > >
                  > > and I need to select that area again if I want to replace something
                  > >
                  > > else. I can remember line numbers or put a mark at the end. Is there a
                  > >
                  > > way to save the selected area or a better way to do this?
                  >
                  > Everybody suggested gv to reselect the area, I'm surprised nobody mentioned that you don't NEED to reselect the visual area, nor do you need to manually set marks.
                  >
                  > Every time you create a visual selection, Vim automatically sets the '< and '> marks.
                  >
                  > So to run several sequential commands on the same visual selection:
                  >
                  > {make visual selection}
                  > :'<,'>FirstCommand
                  > :'<,'>SecondCommand
                  > :'<,'>ThirdCommand
                  > :'<,'>Etc
                  >
                  > Note that for FirstCommand, as soon as you press :, the marks '<,'> are inserted for you by Vim. The others you can enter manually or use command-line history to recall a previous command you can edit.

                  One can use :*Command as a shortcut for :'<,'>Command. If this does not work check out 'cpoptions' value, it should not contain star (:h cpo-star).

                  > --
                  > --
                  > You received this message from the "vim_use" maillist.
                  > Do not top-post! Type your reply below the text you are replying to.
                  > For more information, visit http://www.vim.org/maillist.php
                  >
                  > ---
                  > You received this message because you are subscribed to the Google Groups "vim_use" group.
                  > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  > For more options, visit https://groups.google.com/groups/opt_out.

                  --
                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php
                   
                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Tim Chase
                  ... I started a similar reply but Ben beat me to the button. It s also helpful to know that you can also use * to mean the same visually selected
                  Message 8 of 8 , Oct 17, 2013
                    On 2013-10-17 06:53, Ben Fritz wrote:
                    > On Thursday, October 17, 2013 7:48:25 AM UTC-5, shawn wilson wrote:
                    > > My problem is that I often select a portion of code and do
                    > > multiple
                    > >
                    > > :%s/foo/bar/g (or /gc - whatever) after, the code selection
                    > > disappears
                    > >
                    > > and I need to select that area again if I want to replace
                    > > something
                    > >
                    > > else. I can remember line numbers or put a mark at the end. Is
                    > > there a
                    > >
                    > > way to save the selected area or a better way to do this?
                    >
                    > Everybody suggested gv to reselect the area, I'm surprised nobody
                    > mentioned that you don't NEED to reselect the visual area, nor do
                    > you need to manually set marks.
                    >
                    > Every time you create a visual selection, Vim automatically sets
                    > the '< and '> marks.
                    >
                    > So to run several sequential commands on the same visual selection:
                    >
                    > {make visual selection}
                    > :'<,'>FirstCommand
                    > :'<,'>SecondCommand
                    > :'<,'>ThirdCommand
                    > :'<,'>Etc
                    >
                    > Note that for FirstCommand, as soon as you press :, the marks '<,'>
                    > are inserted for you by Vim. The others you can enter manually or
                    > use command-line history to recall a previous command you can edit.

                    I started a similar reply but Ben beat me to the <send> button.

                    It's also helpful to know that you can also use "*" to mean the same
                    visually selected range, so you can

                    1) highlight some lines
                    2) press ":" which autopopulates the range '<,'>
                    3) add your first command and execute it
                    4) type ":*Command2" and execute it to reuse the same '<,'> range

                    And I'm all about the lazy :-)

                    -tim

                    PS: this only works if "*" isn't in 'cpoptions' according to ":help
                    cpo-star", though that should be the default shown at ":help 'cpo'"







                    --
                    --
                    You received this message from the "vim_use" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  Your message has been successfully submitted and would be delivered to recipients shortly.