Monday, May 1, 2023

Small documentation tweak for :g delimiters

Shortly after the help for :v it reads

Instead of the '/' which surrounds the {pattern}, you can use any
other single byte character, but not an alphabetic character,
'\', '"' or '|'. This is useful if you want to include a '/' in
the search pattern or replacement string.

This makes it sounds like "!" should be a viable delimiter (as it
it is for a :s command per `:help pattern-delimiter`). However,
it ends up turning a :g command into a :v command.

So in addition to excluding backslash, double-quote, and bar, I'd
recommend adding "!" to the list here.

-tim

discovered by unthinkingly doing a

:g!/path/

and getting all lines that didn't contain "path" rather than all
lines that did contain "/path/". Using an alternate delimiter like

:g@/path/

worked as expected. And I often use "!" as my pattern-delimiter
in substitute commands when the pattern contains "/" characters

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ZFAYFQnS5iT/YvRo%40thechases.com.

No comments:

Post a Comment