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

Re: ":normal /pattern" can't take effect in gVim 7.3.46

Expand Messages
  • Christian Brabandt
    ... Well, when you are searching using / you need to press enter to stop entering pattern and actually start the search. So you are at least missing the
    Message 1 of 4 , Jul 11, 2013
      On Thu, July 11, 2013 09:31, xjtuei@... wrote:
      > Hi All
      > I want to use the below command in command line to search my specified
      > pattern in the text
      > :normal /pattern
      >
      > However, it doesn't take effect in my current version:gVim 7.3.46
      >
      > anyone knows how to correct this command or other comments?
      >
      > My request is from below case:
      > used for I want to set my own command to search the pattern when I did the
      > selection on the konsole terminal
      >
      >
      > currently I could use below succesfully to insert some text which I
      > selected on the konsole.
      > :command Joe :exec "normal i" . @*
      >
      > but can't I can't use below to search the pattern text which I selected on
      > the konsole.
      > :command Joe2 :exec "normal /" . @*
      >
      > and I guess it's due to the "normal /" is not a correct or complete
      > command here.
      >
      Well, when you are searching using '/' you need to press enter to stop
      entering pattern and actually start the search. So you are at least missing
      the ."\<cr>" part at the end of your command. But using normal for this
      is clumsy and I would do it like this:

      :com Joe :let @/=@*|norm! n

      Depending on your pattern, you might need to escape certains things, e.g.
      to search literally use something like this:

      :com Joe :let @/='\V'.escape(@*, '\\')|norm! n


      BTW: you usually want :norm! instead of :norm

      See also the help:
      :h escape
      :h :norm

      regards,
      Christian

      --
      --
      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.
    • xjtuei@...
      在 2013年7月11日星期四UTC+8下午7时58分17秒,Christian Brabandt写道: ... thanks Christian, I have read some pages and :he normal and :help exec
      Message 2 of 4 , Jul 11, 2013
        在 2013年7月11日星期四UTC+8下午7时58分17秒,Christian Brabandt写道:
        > On Thu, July 11, 2013 09:31, xjtuei@... wrote:
        >
        > > Hi All
        >
        > > I want to use the below command in command line to search my specified
        >
        > > pattern in the text
        >
        > > :normal /pattern
        >
        > >
        >
        > > However, it doesn't take effect in my current version:gVim 7.3.46
        >
        > >
        >
        > > anyone knows how to correct this command or other comments?
        >
        > >
        >
        > > My request is from below case:
        >
        > > used for I want to set my own command to search the pattern when I did the
        >
        > > selection on the konsole terminal
        >
        > >
        >
        > >
        >
        > > currently I could use below succesfully to insert some text which I
        >
        > > selected on the konsole.
        >
        > > :command Joe :exec "normal i" . @*
        >
        > >
        >
        > > but can't I can't use below to search the pattern text which I selected on
        >
        > > the konsole.
        >
        > > :command Joe2 :exec "normal /" . @*
        >
        > >
        >
        > > and I guess it's due to the "normal /" is not a correct or complete
        >
        > > command here.
        >
        > >
        >
        > Well, when you are searching using '/' you need to press enter to stop
        >
        > entering pattern and actually start the search. So you are at least missing
        >
        > the ."\<cr>" part at the end of your command. But using normal for this
        >
        > is clumsy and I would do it like this:
        >
        >
        >
        > :com Joe :let @/=@*|norm! n
        >
        >
        >
        > Depending on your pattern, you might need to escape certains things, e.g.
        >
        > to search literally use something like this:
        >
        >
        >
        > :com Joe :let @/='\V'.escape(@*, '\\')|norm! n
        >
        >
        >
        >
        >
        > BTW: you usually want :norm! instead of :norm
        >
        >
        >
        > See also the help:
        >
        > :h escape
        >
        > :h :norm
        >
        >
        >
        > regards,
        >
        > Christian

        thanks Christian,
        I have read some pages and :he normal and :help exec and have some new findings now. My issue has been resolved...



        For the normal and execute usage:
        Refer to
        http://vim.wikia.com/wiki/Using_normal_command_in_a_script_for_searching
        http://vim.wikia.com/wiki/Searching_for_expressions_which_include_slashes
        https://groups.google.com/forum/#!searchin/vim_use/normal/vim_use/s0Q3RYiwupY/Y5L_jaWb0kMJ

        when use the :normal ? or :normal /
        it expects an finish signal, such as \n (return) or ^M (first type Ctrl-V then Ctrl-M to input it on the command line), all these are known as <CR>, but we can’t type <CR> or <Enter> here, due to <CR> and <Enter> are only used in command line or .vimrc or other vim scripts.


        So we could use below:

        1) Single use :normal




        :normal /pattern^M (here ^M is first type Ctrl-V then Ctrl-M)


        2) Together With execute ,supposed the pattern is plain text and contains no symbols.


        :exec “normal /pattern\n”
        :exec “normal /pattern\<CR>”


        Or
        :exe “normal /pattern” . “\n”
        :exe “normal /pattern” . “\<CR>”
        Or




        :exe ‘normal /pattern’ . “\n”
        :exe ‘normal /pattern’ . “\<CR>”

        Or
        :exe “normal /” . “pattern” . “\n”
        :exe “normal /” . “pattern” . “\<CR>”


        So, use below command to search the pattern which is selected in a konsole terminal or other.


        :execute "normal /". @* . "\<CR>"

        :execute "normal ?". @* . "\<CR>"

        --
        --
        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.
      • xjtuei@...
        在 2013年7月11日星期四UTC+8下午7时58分17秒,Christian Brabandt写道: ... Your below point ... is used to search text which may include slash or
        Message 3 of 4 , Jul 11, 2013
          在 2013年7月11日星期四UTC+8下午7时58分17秒,Christian Brabandt写道:
          > On Thu, July 11, 2013 09:31, xjtuei@... wrote:
          >
          > > Hi All
          >
          > > I want to use the below command in command line to search my specified
          >
          > > pattern in the text
          >
          > > :normal /pattern
          >
          > >
          >
          > > However, it doesn't take effect in my current version:gVim 7.3.46
          >
          > >
          >
          > > anyone knows how to correct this command or other comments?
          >
          > >
          >
          > > My request is from below case:
          >
          > > used for I want to set my own command to search the pattern when I did the
          >
          > > selection on the konsole terminal
          >
          > >
          >
          > >
          >
          > > currently I could use below succesfully to insert some text which I
          >
          > > selected on the konsole.
          >
          > > :command Joe :exec "normal i" . @*
          >
          > >
          >
          > > but can't I can't use below to search the pattern text which I selected on
          >
          > > the konsole.
          >
          > > :command Joe2 :exec "normal /" . @*
          >
          > >
          >
          > > and I guess it's due to the "normal /" is not a correct or complete
          >
          > > command here.
          >
          > >
          >
          > Well, when you are searching using '/' you need to press enter to stop
          >
          > entering pattern and actually start the search. So you are at least missing
          >
          > the ."\<cr>" part at the end of your command. But using normal for this
          >
          > is clumsy and I would do it like this:
          >
          >
          >
          > :com Joe :let @/=@*|norm! n
          >
          >
          >
          > Depending on your pattern, you might need to escape certains things, e.g.
          >
          > to search literally use something like this:
          >
          >
          >
          > :com Joe :let @/='\V'.escape(@*, '\\')|norm! n
          >
          >
          >
          >
          >
          > BTW: you usually want :norm! instead of :norm
          >
          >
          >
          > See also the help:
          >
          > :h escape
          >
          > :h :norm
          >
          >
          >
          > regards,
          >
          > Christian
          Your below point
          :com Joe :let @/=@*|norm! n
          is used to search text which may include slash or not
          :com Joe :let @/='\V'.escape(@*, '\\')|norm! n
          is used to search any text literally which may have ",@,/,\ ...etc and without extra manual escape process.
          is like something they are talked about in

          http://vim.wikia.com/wiki/Searching_for_expressions_which_include_slashes

          this issue has been resolved.
          thanks a lot.

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