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

Access recent searches when in command mode

Expand Messages
  • DwigtArmyOfChampions
    I do a lot of pattern-matching searches using the / search command. Then when I ve settled on the correct regular expression that grabs just the right group of
    Message 1 of 4 , Oct 9, 2013
    • 0 Attachment
      I do a lot of pattern-matching searches using the / search command. Then when I've settled on the correct regular expression that grabs just the right group of characters I want, I go :s/ to start a substitution command. Now I'm in the middle of the substitution command and I have to re-enter my complex regular expression that's in my search history from before. Is there an easy way to yank it so Ii don't to re-type it?

      --
      --
      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.
    • Guyzmo
      Hi, ... Indeed, you can, just use the magical key! ... Will substitute your last search regex! Have a look at the following SO answer:
      Message 2 of 4 , Oct 9, 2013
      • 0 Attachment
        Hi,

        On Wed, Oct 09, 2013 at 03:48:34AM -0700, DwigtArmyOfChampions wrote:
        > I do a lot of pattern-matching searches using the / search command.
        > Then when I've settled on the correct regular expression that grabs
        > just the right group of characters I want, I go :s/ to start a
        > substitution command. Now I'm in the middle of the substitution
        > command and I have to re-enter my complex regular expression that's in
        > my search history from before. Is there an easy way to yank it so Ii
        > don't to re-type it?

        Indeed, you can, just use the "magical" <C-r> key!

        like:

        :s,<C-r>/,,

        Will substitute your last search regex!

        Have a look at the following SO answer:

        http://stackoverflow.com/questions/4655484/convert-vim-search-to-search-and-replace-without-retyping-regular-expression

        where it gives a few other options, like using the `q:` for the
        command history and `q/` for the search history, that i did not know
        about.

        Cheers,

        --
        Guyzmo

        --
        --
        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.
      • Marco
        ... Either leave it empty, then the last one is being reused or insert the last pattern with /. Marco -- -- You received this message from the vim_use
        Message 3 of 4 , Oct 9, 2013
        • 0 Attachment
          On 2013–10–09 DwigtArmyOfChampions wrote:

          > Now I'm in the middle of the substitution command and I have to
          > re-enter my complex regular expression that's in my search history
          > from before. Is there an easy way to yank it so Ii don't to
          > re-type it?

          Either leave it empty, then the last one is being reused or insert
          the last pattern with <C-r>/.

          Marco

          --
          --
          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.
        • Dimitar DIMITROV
          ... This is my solution (in ~/.vimrc): Switch between command line commands cmap :call cmdline#switch( g ) defined in:
          Message 4 of 4 , Oct 9, 2013
          • 0 Attachment
            >I do a lot of pattern-matching searches using the / search command. Then when I've settled on the correct regular expression that grabs just the right group of characters I want, I go :s/ to start a substitution command. Now I'm in the middle of the substitution command and I have to re-enter my complex regular expression that's in my search history from before. Is there an easy way to yank it so Ii don't to re-type it?

            This is my solution (in ~/.vimrc):

            " Switch between command line commands
            cmap <silent> <c-g> <c-f>:call cmdline#switch('g')<cr>

            defined in:
            https://github.com/kurkale6ka/vim/blob/master/autoload/cmdline.vim

            Dimitar Dimitrov

            --
            --
            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.