Small documentation tweak for :g delimiters

5 views
Skip to first unread message

Tim Chase

unread,
May 1, 2023, 3:50:54 PM5/1/23
to Vim Users
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

Bram Moolenaar

unread,
May 1, 2023, 5:37:32 PM5/1/23
to vim...@googlegroups.com, Tim Chase
Thanks for the suggestion. I first thought this was only for ":global",
but using it with ":vglobal" gives an error "E477: No ! allowed".
Thus it can indeed be added to the list.

--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Owajigbanam Ogbuluijah

unread,
May 1, 2023, 5:38:11 PM5/1/23
to vim...@googlegroups.com
If you check the documentation for help :v, you'd see it's marked as the same 

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

Tim Chase

unread,
May 1, 2023, 6:49:45 PM5/1/23
to vim...@googlegroups.com
On 2023-05-01 21:37, Owajigbanam Ogbuluijah wrote:
> If you check the documentation for *help :v*, you'd see it's
> marked as the same

Yes, `:g!` and `:v` are the same. However, both can take alternate
delimiters (other than "/"). The documentation states that the
alternate delimter cannot be a backslash, a double-quote, or a bar.
But my initial email notes that "!" should be in included in that
list of prohibited characters (as Bram confirms) because it's viewed
as a negation to :g and is invalid for :v

-tim





Reply all
Reply to author
Forward
0 new messages