patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Problem: Vim9: using g:pat:cmd is confusing.
Solution: Do not recognize g: as the :global command. Also for s:pat:repl.
(closes #8982)
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index b6feebf..b661097 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -942,9 +942,22 @@
Some Ex commands can be confused with assignments in Vim9 script: >
g:name = value # assignment
- g:pattern:cmd # invalid command - ERROR
:g:pattern:cmd # :global command
+To avoid confusion between a `:global` or `:substitute` command and an
+expression or assignment, a few separators cannot be used when these commands
+are abbreviated to a single character: ':', '-' and '.'. >
+ g:pattern:cmd # invalid command - ERROR
+ s:pattern:repl # invalid command - ERROR
+ g-pattern-cmd # invalid command - ERROR
+ s-pattern-repl # invalid command - ERROR
+ g.pattern.cmd # invalid command - ERROR
+ s.pattern.repl # invalid command - ERROR
+
+Also, there cannot be a space between the command and the separator: >
+ g /pattern/cmd # invalid command - ERROR
+ s /pattern/repl # invalid command - ERROR
+
Functions defined with `:def` compile the whole function. Legacy functions
can bail out, and the following lines are not parsed: >
func Maybe()