Monday, November 25, 2013

Re: How to search for alternatives in :tag /pattern ?

On 2013-11-25, Benji Fisher wrote:
> On Sun, Nov 24, 2013 at 8:31 AM, Micha Moskovic wrote:
>
>
> Hi,
>
> I have the following problem.
> I am editting a file for which a ctags file has been generated. This
> file contains two tags, "tag1" and "tag2". With ":tag tag1" and ":tag
> tag2", I can jump to "tag1" and "tag2" respectively. Now suppose I would
> like to add both "tag1" and "tag2" to the tag stack. According to help,
> I can do ":tag /pattern" to search for a pattern, and indeed
> ":tag /tag." works as expected. However, I would like to search for
> "tag1" and "tag2" only and so I tried ":tag /tag1\|tag2". However,
> contrary to my expectations, this does not work!
>
> Am I doing something wrong?
>
> Regards,
> Micha
>
>
>      I tried it, read the error message, and found that
>
> :tag /tag1\\|tag2
>
> does the job.  I did not find any mention of this under
>
> :help :tag
> :help tag-regexp
>
> so maybe this is not documented.  (Maybe I should try upgrading.  I am still
> using 7.3.646.)

I think this is covered in ":help :bar".

'|' by itself would be a command separator. '\|' tells the
command-line parser that you want a real '|' in the command. But
you don't want just '|', you want '\|', so you need the first '\' to
be itself, then the '\|' to be replaced by '|' when the string is
given to the :tag command, which then sees '\|'.

Regards,
Gary

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

No comments: