On Thu, July 11, 2013 09:31, xjtuei@gmail.com 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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thursday, July 11, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment