When there are two counts, as in "3d2w", they are multiplied,
just like what happens in the command, "d6w" for the example.
Also used for evaluating the 'formatexpr' option.
- "count" also works, for backwards compatibility.
+ "count" also works, for backwards compatibility, unless
+ |scriptversion| is 3 or higher.
*v:count1* *count1-variable*
v:count1 Just like "v:count", but defaults to one when no count is
:silent! next
:if v:errmsg != ""
: ... handle error
-< "errmsg" also works, for backwards compatibility.
+< "errmsg" also works, for backwards compatibility, unless
+ |scriptversion| is 3 or higher.
*v:errors* *errors-variable* *assert-return*
v:errors Errors found by assert functions, such as |assert_true()|.
:if v:shell_error
: echo 'could not rename "foo" to "bar"!'
:endif
-< "shell_error" also works, for backwards compatibility.
+< "shell_error" also works, for backwards compatibility, unless
+ |scriptversion| is 3 or higher.
*v:statusmsg* *statusmsg-variable*
v:statusmsg Last given status message. It's allowed to set this variable.
v:this_session Full filename of the last loaded or saved session file. See
|:mksession|. It is allowed to set this variable. When no
session file has been saved, this variable is empty.
- "this_session" also works, for backwards compatibility.
+ "this_session" also works, for backwards compatibility, unless
+ |scriptversion| is 3 or higher
*v:throwpoint* *throwpoint-variable*
v:throwpoint The point where the exception most recently caught and not
v:version Version number of Vim: Major version number times 100 plus
minor version number. Version 5.0 is 500. Version 5.1 (5.01)
is 501. Read-only. "version" also works, for backwards
- compatibility.
+ compatibility, unless |scriptversion| is 3 or higher.
Use |has()| to check if a certain patch was included, e.g.: >
if has("patch-7.4.123")
< Note that patch numbers are specific to the version, thus both
return NULL;
*varname = name;
- /* "version" is "v:version" in all scopes */
- hi = hash_find(&compat_hashtab, name);
- if (!HASHITEM_EMPTY(hi))
- return &compat_hashtab;
+ // "version" is "v:version" in all scopes if scriptversion < 3.
+ // Same for a few other variables marked with VV_COMPAT.
+ if (current_sctx.sc_version < 3)
+ {
+ hi = hash_find(&compat_hashtab, name);
+ if (!HASHITEM_EMPTY(hi))
+ return &compat_hashtab;
+ }
ht = get_funccal_local_ht();
if (ht == NULL)
endif
endfunc
+scriptversion 3
+func Test_vvar_scriptversion3()
+ call assert_fails('echo version', 'E121:')
+ call assert_false(exists('version'))
+ let version = 1
+ call assert_equal(1, version)
+endfunc
+
+scriptversion 2
+func Test_vvar_scriptversion2()
+ call assert_true(exists('version'))
+ echo version
+ call assert_fails('let version = 1', 'E46:')
+ call assert_equal(v:version, version)
+endfunc
+
func Test_scriptversion()
call writefile(['scriptversion 9'], 'Xversionscript')
call assert_fails('source Xversionscript', 'E999:')