Tuesday, January 20, 2015

RE: Should vimgrep always use "/" to enclose your search patterns?

Bao Niu wrote:
> in Vim is enclosing your search pattern with "/" recommended?
> The documentation says it is optional. If it's optional then
> why not just forget it?

I would be too nervous to follow Tim's advice, but it seems to
work. Are you aware of the general rule that applies to commands
like :s (substitute)?

An example to replace "hello" with "goodbye":

:%s/hello/goodbye/g

Suppose you need to replace something with slashes in it.
The following attempt to replace "a/b" will NOT WORK:

:%s/a/b/goodbye/g

However, the following will work:

:%s.a/b.goodbye.g

These tips are worth careful study:
http://vim.wikia.com/wiki/Searching
http://vim.wikia.com/wiki/Search_and_replace

John


--
--
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/d/optout.

No comments: