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/src/ex_docmd.c b/src/ex_docmd.c
index 08a4830..072effd 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3600,6 +3600,15 @@
}
}
+ // "g:", "s:" and "l:" are always assumed to be a variable, thus start
+ // an expression. A global/substitute/list command needs to use a
+ // longer name.
+ if (vim_strchr((char_u *)"gsl", *p) != NULL && p[1] == ':')
+ {
+ eap->cmdidx = CMD_eval;
+ return eap->cmd;
+ }
+
// If it is an ID it might be a variable with an operator on the next
// line, if the variable exists it can't be an Ex command.
if (p > eap->cmd && ends_excmd(*skipwhite(p))