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)
This commit is contained in:
Bram Moolenaar
2021-10-13 15:04:34 +01:00
parent fff10d9a76
commit 7b82926892
8 changed files with 111 additions and 1 deletions

View File

@ -942,9 +942,22 @@ Ex command ranges need to be prefixed with a colon. >
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()