mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.2531: Vim9: the :k command is obscure
Problem: Vim9: the :k command is obscure. Solution: Disallow using :k, can use :mark instead. (closes #7874)
This commit is contained in:
@@ -96,8 +96,8 @@ script and `:def` functions; details are below:
|
|||||||
def CallMe(count: number, message: string): bool
|
def CallMe(count: number, message: string): bool
|
||||||
- Call functions without `:call`: >
|
- Call functions without `:call`: >
|
||||||
writefile(['done'], 'file.txt')
|
writefile(['done'], 'file.txt')
|
||||||
- You cannot use `:xit`, `:t`, `:append`, `:change`, `:insert` or curly-braces
|
- You cannot use `:xit`, `:t`, `:k`, `:append`, `:change`, `:insert` or
|
||||||
names.
|
curly-braces names.
|
||||||
- A range before a command must be prefixed with a colon: >
|
- A range before a command must be prefixed with a colon: >
|
||||||
:%s/this/that
|
:%s/this/that
|
||||||
- Unless mentioned specifically, the highest |scriptversion| is used.
|
- Unless mentioned specifically, the highest |scriptversion| is used.
|
||||||
@@ -562,11 +562,12 @@ error. A number can be given with and without the []: >
|
|||||||
{'456': 'with', '123': 'without'}
|
{'456': 'with', '123': 'without'}
|
||||||
|
|
||||||
|
|
||||||
No :xit, :t, :append, :change or :insert ~
|
No :xit, :t, :k, :append, :change or :insert ~
|
||||||
|
|
||||||
These commands are too easily confused with local variable names.
|
These commands are too easily confused with local variable names.
|
||||||
Instead of `:x` or `:xit` you can use `:exit`.
|
Instead of `:x` or `:xit` you can use `:exit`.
|
||||||
Instead of `:t` you can use `:copy`.
|
Instead of `:t` you can use `:copy`.
|
||||||
|
Instead of `:k` you can use `:mark`.
|
||||||
|
|
||||||
|
|
||||||
Comparators ~
|
Comparators ~
|
||||||
|
@@ -741,7 +741,7 @@ EXCMD(CMD_jumps, "jumps", ex_jumps,
|
|||||||
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_k, "k", ex_mark,
|
EXCMD(CMD_k, "k", ex_mark,
|
||||||
EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
|
EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
|
||||||
ADDR_LINES),
|
ADDR_LINES),
|
||||||
EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier,
|
EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier,
|
||||||
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
|
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
|
||||||
|
@@ -3461,7 +3461,8 @@ find_ex_command(
|
|||||||
/*
|
/*
|
||||||
* Isolate the command and search for it in the command table.
|
* Isolate the command and search for it in the command table.
|
||||||
* Exceptions:
|
* Exceptions:
|
||||||
* - the 'k' command can directly be followed by any character.
|
* - The 'k' command can directly be followed by any character.
|
||||||
|
* But it is not used in Vim9 script.
|
||||||
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
|
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
|
||||||
* but :sre[wind] is another command, as are :scr[iptnames],
|
* but :sre[wind] is another command, as are :scr[iptnames],
|
||||||
* :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
|
* :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
|
||||||
@@ -8056,6 +8057,10 @@ ex_mark(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
|
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
if (not_in_vim9(eap) == FAIL)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
if (*eap->arg == NUL) // No argument?
|
if (*eap->arg == NUL) // No argument?
|
||||||
emsg(_(e_argreq));
|
emsg(_(e_argreq));
|
||||||
else if (eap->arg[1] != NUL) // more than one character?
|
else if (eap->arg[1] != NUL) // more than one character?
|
||||||
|
@@ -3491,6 +3491,31 @@ def Test_import_gone_when_sourced_twice()
|
|||||||
unlet g:guard
|
unlet g:guard
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_unsupported_commands()
|
||||||
|
var lines =<< trim END
|
||||||
|
ka
|
||||||
|
END
|
||||||
|
CheckDefAndScriptFailure(lines, 'E1100:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
t
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E1100:')
|
||||||
|
CheckScriptFailure(['vim9script'] + lines, 'E1100:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
x
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E1100:')
|
||||||
|
CheckScriptFailure(['vim9script'] + lines, 'E1100:')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
xit
|
||||||
|
END
|
||||||
|
CheckDefFailure(lines, 'E1100:')
|
||||||
|
CheckScriptFailure(['vim9script'] + lines, 'E1100:')
|
||||||
|
enddef
|
||||||
|
|
||||||
" Keep this last, it messes up highlighting.
|
" Keep this last, it messes up highlighting.
|
||||||
def Test_substitute_cmd()
|
def Test_substitute_cmd()
|
||||||
new
|
new
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2531,
|
||||||
/**/
|
/**/
|
||||||
2530,
|
2530,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -8520,6 +8520,7 @@ compile_def_function(
|
|||||||
case CMD_append:
|
case CMD_append:
|
||||||
case CMD_change:
|
case CMD_change:
|
||||||
case CMD_insert:
|
case CMD_insert:
|
||||||
|
case CMD_k:
|
||||||
case CMD_t:
|
case CMD_t:
|
||||||
case CMD_xit:
|
case CMD_xit:
|
||||||
not_in_vim9(&ea);
|
not_in_vim9(&ea);
|
||||||
|
@@ -95,6 +95,7 @@ not_in_vim9(exarg_T *eap)
|
|||||||
case CMD_append:
|
case CMD_append:
|
||||||
case CMD_change:
|
case CMD_change:
|
||||||
case CMD_insert:
|
case CMD_insert:
|
||||||
|
case CMD_k:
|
||||||
case CMD_t:
|
case CMD_t:
|
||||||
case CMD_xit:
|
case CMD_xit:
|
||||||
semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);
|
semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd);
|
||||||
|
Reference in New Issue
Block a user