forked from aniani/vim
Update runtime files.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
*editing.txt* For Vim version 8.2. Last change: 2020 Dec 19
|
||||
*editing.txt* For Vim version 8.2. Last change: 2021 Jan 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1014,7 +1014,7 @@ to write anyway add a '!' to the command.
|
||||
|
||||
*write-permissions*
|
||||
When writing a new file the permissions are read-write. For unix the mask is
|
||||
0666 with additionally umask applied. When writing a file that was read Vim
|
||||
0o666 with additionally umask applied. When writing a file that was read Vim
|
||||
will preserve the permissions, but clear the s-bit.
|
||||
|
||||
*write-readonly*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 8.2. Last change: 2020 Dec 21
|
||||
*options.txt* For Vim version 8.2. Last change: 2021 Jan 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -438,7 +438,7 @@ the system, mostly it is something like 256 or 1024 characters.
|
||||
CTRL-? CTRL-H
|
||||
not CTRL-? CTRL-?
|
||||
|
||||
(CTRL-? is 0177 octal, 0x7f hex)
|
||||
(CTRL-? is 0o177 octal, 0x7f hex)
|
||||
|
||||
If your delete key terminal code is wrong, but the
|
||||
code for backspace is alright, you can put this in
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*os_vms.txt* For Vim version 8.2. Last change: 2020 Dec 30
|
||||
*os_vms.txt* For Vim version 8.2. Last change: 2021 Jan 04
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL
|
||||
@@ -767,8 +767,10 @@ GNU_TOOLS.ZIP package downloadable from http://www.polarhome.com/vim/
|
||||
|
||||
Version 8.2
|
||||
- make all changes needed for clean compile build of v8.2 on VMS on all platforms
|
||||
- test on VSI OpenVMS platforms
|
||||
- added XPM support - Motif GUI with toolbar on all platforms
|
||||
- fix the call mkdir bug (vicente_polo@yahoo.es)
|
||||
- test on VSI OpenVMS Alpha and Itanium platforms
|
||||
- added LUA support
|
||||
- added XPM support - Motif GUI with toolbar on all platforms
|
||||
- XPM v3.4.11 libraries for IA64, AXP and VAX are added
|
||||
- start integrating the new test scripts
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*pattern.txt* For Vim version 8.2. Last change: 2020 Dec 25
|
||||
*pattern.txt* For Vim version 8.2. Last change: 2021 Jan 08
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1179,7 +1179,7 @@ x A single character, with no special meaning, matches itself
|
||||
\b <BS>
|
||||
\n line break, see above |/[\n]|
|
||||
\d123 decimal number of character
|
||||
\o40 octal number of character up to 0377
|
||||
\o40 octal number of character up to 0o377
|
||||
\x20 hexadecimal number of character up to 0xff
|
||||
\u20AC hex. number of multibyte character up to 0xffff
|
||||
\U1234 hex. number of multibyte character up to 0xffffffff
|
||||
@@ -1217,7 +1217,8 @@ x A single character, with no special meaning, matches itself
|
||||
\%d123 Matches the character specified with a decimal number. Must be
|
||||
followed by a non-digit.
|
||||
\%o40 Matches the character specified with an octal number up to 0377.
|
||||
Numbers below 040 must be followed by a non-octal digit or a non-digit.
|
||||
Numbers below 0o40 must be followed by a non-octal digit or a
|
||||
non-digit.
|
||||
\%x2a Matches the character specified with up to two hexadecimal characters.
|
||||
\%u20AC Matches the character specified with up to four hexadecimal
|
||||
characters.
|
||||
|
@@ -1783,6 +1783,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
09.2 usr_09.txt /*09.2*
|
||||
09.3 usr_09.txt /*09.3*
|
||||
09.4 usr_09.txt /*09.4*
|
||||
0o eval.txt /*0o*
|
||||
0x eval.txt /*0x*
|
||||
10.1 usr_10.txt /*10.1*
|
||||
10.2 usr_10.txt /*10.2*
|
||||
10.3 usr_10.txt /*10.3*
|
||||
@@ -1994,6 +1996,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
:AdaTagFile ft_ada.txt /*:AdaTagFile*
|
||||
:AdaTypes ft_ada.txt /*:AdaTypes*
|
||||
:Arguments terminal.txt /*:Arguments*
|
||||
:Asm terminal.txt /*:Asm*
|
||||
:Break terminal.txt /*:Break*
|
||||
:Cfilter quickfix.txt /*:Cfilter*
|
||||
:Clear terminal.txt /*:Clear*
|
||||
@@ -5756,6 +5759,7 @@ characterwise motion.txt /*characterwise*
|
||||
characterwise-register change.txt /*characterwise-register*
|
||||
characterwise-visual visual.txt /*characterwise-visual*
|
||||
charclass() eval.txt /*charclass()*
|
||||
charcol() eval.txt /*charcol()*
|
||||
charconvert_from-variable eval.txt /*charconvert_from-variable*
|
||||
charconvert_to-variable eval.txt /*charconvert_to-variable*
|
||||
charidx() eval.txt /*charidx()*
|
||||
@@ -6951,6 +6955,7 @@ getbufvar() eval.txt /*getbufvar()*
|
||||
getchangelist() eval.txt /*getchangelist()*
|
||||
getchar() eval.txt /*getchar()*
|
||||
getcharmod() eval.txt /*getcharmod()*
|
||||
getcharpos() eval.txt /*getcharpos()*
|
||||
getcharsearch() eval.txt /*getcharsearch()*
|
||||
getcmdline() eval.txt /*getcmdline()*
|
||||
getcmdpos() eval.txt /*getcmdpos()*
|
||||
@@ -6958,6 +6963,7 @@ getcmdtype() eval.txt /*getcmdtype()*
|
||||
getcmdwintype() eval.txt /*getcmdwintype()*
|
||||
getcompletion() eval.txt /*getcompletion()*
|
||||
getcurpos() eval.txt /*getcurpos()*
|
||||
getcursorcharpos() eval.txt /*getcursorcharpos()*
|
||||
getcwd() eval.txt /*getcwd()*
|
||||
getenv() eval.txt /*getenv()*
|
||||
getfontname() eval.txt /*getfontname()*
|
||||
@@ -8260,6 +8266,7 @@ notation intro.txt /*notation*
|
||||
notepad gui_w32.txt /*notepad*
|
||||
nr2char() eval.txt /*nr2char()*
|
||||
nroff.vim syntax.txt /*nroff.vim*
|
||||
null vim9.txt /*null*
|
||||
null-variable eval.txt /*null-variable*
|
||||
number_relativenumber options.txt /*number_relativenumber*
|
||||
numbered-function eval.txt /*numbered-function*
|
||||
@@ -8871,8 +8878,10 @@ set-spc-auto spell.txt /*set-spc-auto*
|
||||
setbufline() eval.txt /*setbufline()*
|
||||
setbufvar() eval.txt /*setbufvar()*
|
||||
setcellwidths() eval.txt /*setcellwidths()*
|
||||
setcharpos() eval.txt /*setcharpos()*
|
||||
setcharsearch() eval.txt /*setcharsearch()*
|
||||
setcmdpos() eval.txt /*setcmdpos()*
|
||||
setcursorcharpos() eval.txt /*setcursorcharpos()*
|
||||
setenv() eval.txt /*setenv()*
|
||||
setfperm() eval.txt /*setfperm()*
|
||||
setline() eval.txt /*setline()*
|
||||
@@ -9553,6 +9562,7 @@ termdebug-prompt terminal.txt /*termdebug-prompt*
|
||||
termdebug-starting terminal.txt /*termdebug-starting*
|
||||
termdebug-stepping terminal.txt /*termdebug-stepping*
|
||||
termdebug-variables terminal.txt /*termdebug-variables*
|
||||
termdebug_disasm_window terminal.txt /*termdebug_disasm_window*
|
||||
termdebug_map_K terminal.txt /*termdebug_map_K*
|
||||
termdebug_popup terminal.txt /*termdebug_popup*
|
||||
termdebug_shortcuts terminal.txt /*termdebug_shortcuts*
|
||||
@@ -10086,6 +10096,7 @@ vim9-reload vim9.txt /*vim9-reload*
|
||||
vim9-scopes vim9.txt /*vim9-scopes*
|
||||
vim9-script-intro usr_46.txt /*vim9-script-intro*
|
||||
vim9-types vim9.txt /*vim9-types*
|
||||
vim9-user-command vim9.txt /*vim9-user-command*
|
||||
vim9.txt vim9.txt /*vim9.txt*
|
||||
vim9script vim9.txt /*vim9script*
|
||||
vim: options.txt /*vim:*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*terminal.txt* For Vim version 8.2. Last change: 2020 Dec 28
|
||||
*terminal.txt* For Vim version 8.2. Last change: 2021 Jan 04
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1330,6 +1330,8 @@ Other commands ~
|
||||
*:Program* jump to the window with the running program
|
||||
*:Source* jump to the window with the source code, create it if there
|
||||
isn't one
|
||||
*:Asm* jump to the window with the disassembly, create it if there
|
||||
isn't one
|
||||
|
||||
|
||||
Prompt mode ~
|
||||
@@ -1352,6 +1354,12 @@ Prompt mode can be used even when the |+terminal| feature is present with: >
|
||||
The K key is normally mapped to :Evaluate. If you do not want this use: >
|
||||
let g:termdebug_map_K = 0
|
||||
|
||||
<
|
||||
*termdebug_disasm_window*
|
||||
If you want the Asm window shown by default, set this to 1. Setting to
|
||||
any value greater than 1 will set the Asm window height to that value: >
|
||||
let g:termdebug_disasm_window = 15
|
||||
<
|
||||
|
||||
Communication ~
|
||||
*termdebug-communication*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 8.2. Last change: 2021 Jan 02
|
||||
*todo.txt* For Vim version 8.2. Last change: 2021 Jan 11
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -38,18 +38,29 @@ browser use: https://github.com/vim/vim/issues/1234
|
||||
*known-bugs*
|
||||
-------------------- Known bugs and current work -----------------------
|
||||
|
||||
Reload: How to make sure type of script function hasn't changed?
|
||||
|
||||
Valgrind: test_vim9_cmd: uses uninitialized var
|
||||
no error for:
|
||||
echo extend([0], ['a', true])
|
||||
like it does for:
|
||||
echo extend([0], ['a'])
|
||||
At script level this does not give an error:
|
||||
echo map([0], (_, v) => [])
|
||||
Or:
|
||||
var l: list<number> = [0]
|
||||
echo map(l, (_, v) => [])
|
||||
|
||||
Vim9 - Make everything work:
|
||||
- Expand `=expr` in :next, :argedit, :argadd, :argdelete, :drop
|
||||
- Expand `=expr` in :vimgrep, :vimgrepadd, :lvimgrep, :lvimgrepadd
|
||||
- Expand `=expr` in :mkspell
|
||||
- Unlet with range: "unlet list[a : b]"
|
||||
- Implement "export {one, two three}".
|
||||
- Use "null" for v:null, like true and false? #7495
|
||||
- ISN_CHECKTYPE could use check_argtype()
|
||||
- Using a script variable inside a :def function doesn't work if the variable
|
||||
is inside a block, see Test_nested_function(). Should it work?
|
||||
- give error for variable name:
|
||||
let p = function('NoSuchFunc')
|
||||
- Make closures work better:
|
||||
- Create closure in a loop. Need to make a list of them.
|
||||
- If a :def function is called with a function reference, compile it to get
|
||||
the function type.
|
||||
def Filter(x: string, Cond: func(string): bool)
|
||||
@@ -63,25 +74,18 @@ Vim9 - Make everything work:
|
||||
statement
|
||||
statement
|
||||
}
|
||||
- implement { cmd } compiled
|
||||
- implement { cmd } at script level
|
||||
- Expand `=expr` in :next, :argedit, :argadd, :argdelete, :drop
|
||||
- Expand `=expr` in :vimgrep, :vimgrepadd, :lvimgrep, :lvimgrepadd
|
||||
- Expand `=expr` in :mkspell
|
||||
- Does this work already: can use func as reference:
|
||||
def SomeFunc() ...
|
||||
map(list, SomeFunc)
|
||||
- For builtin functions using tv_get_string*() use check_for_string() to be
|
||||
more strict about the argument type.
|
||||
- Possible memory leaks in test_vim9_func
|
||||
- Implement :lockvar and :unlockvar. How about local variables? Perhaps only
|
||||
allow this for global variables. Use :final or :const otherwise.
|
||||
- Allow function names that will be script-local to start with lower case
|
||||
letter? Or also require names with s: prefix to use upper case?
|
||||
Also apply this function references "var ref = SomeFunc"
|
||||
- Support passing v:none to use the default argument value. (#6504)
|
||||
- Make map() give an error if the resulting type of the first argument is
|
||||
wrong. Only works if the type is known? Is this slow (need to go over all
|
||||
items)?
|
||||
- Run the same tests in :def and Vim9 script, like in Test_expr7_not()
|
||||
- Check many more builtin function arguments at compile time.
|
||||
- make 0 == 'string' fail on the script level, like inside :def.
|
||||
@@ -105,57 +109,59 @@ Vim9 - Make everything work:
|
||||
- Implement "as Name" in "import Item as Name from ..."
|
||||
- Implement using imported items at script level from "import * as X" in
|
||||
eval_variable(). Should pass the ".xxx" that follows and return that.
|
||||
- Disallow unlet for local/script/imported vars
|
||||
- Make "++nr" work. "++g:count" doesn't work, thinks it is a range.
|
||||
- Make closures work:
|
||||
- Create closure in a loop. Need to make a list of them.
|
||||
- nested closure only uses one context, not all (#7150)
|
||||
- Reload: How to make sure type of script function hasn't changed?
|
||||
- expandcmd() with `=expr` in filename uses legacy expression.
|
||||
- eval_expr() in ex_cexpr()
|
||||
- eval_expr() call in dbg_parsearg() and debuggy_find()
|
||||
Improve error checking:
|
||||
- "echo Func()" is an error if Func() does not return anything.
|
||||
Before launch:
|
||||
- compile "skip" argument of searchpair()
|
||||
- compile "expr" and "call" expression of a channel in channel_exe_cmd()?
|
||||
- give an error for "echo Func()" if Func() does not return anything.
|
||||
|
||||
Once Vim9 is stable:
|
||||
- Change the help to prefer Vim9 syntax where appropriate
|
||||
- Use Vim9 for runtime files.
|
||||
PR #7497 for autoload/ccomplete.vim
|
||||
- Add all the error numbers in a good place in documentation.
|
||||
- In the generic eval docs, point out the Vim9 syntax where it differs.
|
||||
Also:
|
||||
- For range: make table of first ASCII character with flag to quickly check if
|
||||
it can be a Vim9 command. E.g. "+" can, but "." can't.
|
||||
|
||||
Also for Vim9:
|
||||
- better implementation for partial and tests for that.
|
||||
- Make "g:imported = Export.exported" work in Vim9 script.
|
||||
- Make Foo.Bar() work to call the dict function. (#5676)
|
||||
- Error in any command in "vim9script" aborts sourcing.
|
||||
- Find a way to test expressions in legacy and Vim9 script without duplication
|
||||
- Test each level of expressions properly, with type checking
|
||||
- Test try/catch and throw better, also nested.
|
||||
Test return inside try/finally jumps to finally and then returns.
|
||||
Test that return inside try/finally jumps to finally and then returns.
|
||||
- Test that a function defined inside a :def function is local to that
|
||||
function, g: functions can be defined and script-local functions cannot be
|
||||
defined.
|
||||
- implement :type
|
||||
- import type declaration?
|
||||
- compile options that are an expression, e.g. "expr:" in 'spellsuggest',
|
||||
'foldexpr', 'foldtext', 'printexpr', 'diffexpr', 'patchexpr', 'charconvert',
|
||||
'balloonexpr', 'includeexpr', 'indentexpr', 'formatexpr'.
|
||||
Give an error if compilation fails. (#7625)
|
||||
Use the location where the option was set for deciding whether it's to be
|
||||
evaluated in Vim9 script context.
|
||||
- implement :type; import type declaration.
|
||||
- implement enum; import enum.
|
||||
- Future work: See |vim9-classes|
|
||||
- implement enum
|
||||
- Make accessing varargs faster: arg[expr]
|
||||
EVAL expr
|
||||
LOADVARARG (varargs idx)
|
||||
Define the keywords and commands to make sure it will be backwards
|
||||
compatible.
|
||||
- Make debugging work - at least per function. Need to recompile a function
|
||||
to step through it line-by-line? Evaluate the stack and variables on the
|
||||
stack?
|
||||
- Make profiling work - Add ISN_PROFILE instructions after every line?
|
||||
- List commands when 'verbose' is set or :verbose is used.
|
||||
Once Vim9 is stable:
|
||||
- Change the help to prefer Vim9 syntax where appropriate
|
||||
- Use Vim9 for runtime files.
|
||||
PR #7497 for autoload/ccomplete.vim
|
||||
Further improvements:
|
||||
- compile options that are an expression, e.g. "expr:" in 'spellsuggest',
|
||||
'foldexpr', 'foldtext', 'printexpr', 'diffexpr', 'patchexpr', 'charconvert',
|
||||
'balloonexpr', 'includeexpr', 'indentexpr', 'formatexpr'.
|
||||
|
||||
Further Vim9 improvements, possibly after launch:
|
||||
- For range: make table of first ASCII character with flag to quickly check if
|
||||
it can be a Vim9 command. E.g. "+" can, but "." can't.
|
||||
- compile get_lambda_tv() in popup_add_timeout()
|
||||
- inline call to map() and filter()
|
||||
- compile "skip" argument of searchpair()
|
||||
- compile "expr" and "call" expression of a channel in channel_exe_cmd()?
|
||||
- Make accessing varargs faster: arg[expr]
|
||||
EVAL expr
|
||||
LOADVARARG (varargs idx)
|
||||
|
||||
|
||||
Popup windows:
|
||||
- Add a flag to make a popup window focusable?
|
||||
@@ -308,6 +314,18 @@ Any way to convert "$" back by using a special value? (#6901)
|
||||
Can we detect true color support? https://gist.github.com/XVilka/8346728
|
||||
Try setting a color then request the current color, like using t_u7.
|
||||
|
||||
Regexp to search for duplicate lines does not work correctly:
|
||||
/\(^.*\n\)\1 (Chris Morgan, #6239)
|
||||
|
||||
Changing a capturing group to non-capturing changes the result: #7607
|
||||
:echo matchstr('aaa bbb', '\(.\{-1,}\>\)\|.*')
|
||||
aaa
|
||||
:echo matchstr('aaa bbb', '\%(.\{-1,}\>\)\|.*')
|
||||
aaa bbb
|
||||
Should also work without any group:
|
||||
:echo matchstr('aaa bbb', '.\{-1,}\>\|.*')
|
||||
aaa bbb (should be aaa)
|
||||
|
||||
Check out PR #543 (Roland Puntaier).
|
||||
Patch for multibyte characters in langmap and applying a mapping on them.
|
||||
(Christian Brabandt, 2015 Jun 12, update July 25)
|
||||
@@ -393,9 +411,6 @@ corruption. (#6631)
|
||||
When 'lazyredraw' is set sometimes the title is not updated.
|
||||
(Jason Franklin, 2020 Feb 3) Looks like a race condition.
|
||||
|
||||
Regexp to search for duplicate lines does not work correctly:
|
||||
/\(^.*\n\)\1 (Chris Morgan, #6239)
|
||||
|
||||
With bash ":make" does not set v:shell_error. Possible solution: set
|
||||
'shellpipe' to "2>&1| tee %s; exit ${PIPESTATUS[0]}" #5994
|
||||
|
||||
@@ -1152,7 +1167,7 @@ Overlong utf-8 sequence is displayed wrong. (Harm te Hennepe, 2017 Sep 14,
|
||||
#2089) Patch with possible solution by Björn Linse.
|
||||
|
||||
The change list index is local to a buffer, but it doesn't make sense using it
|
||||
for another buffer. (lacygolil) Copy w_changelistidx to wininfo_S and back.
|
||||
for another buffer. (lacygoill) Copy w_changelistidx to wininfo_S and back.
|
||||
|
||||
X11: Putting more than about 262040 characters of text on the clipboard and
|
||||
pasting it in another Vim doesn't work. (Dominique Pelle, 2008 Aug 21-23)
|
||||
@@ -5474,7 +5489,7 @@ Mappings and Abbreviations:
|
||||
not the <Space>.
|
||||
8 Give a warning when using CTRL-C in the lhs of a mapping. It will never
|
||||
(?) work.
|
||||
7 Add <0x8f> (hex), <033> (octal) and <123> (decimal) to <> notation?
|
||||
7 Add <0x8f> (hex), <0o33> (octal) and <123> (decimal) to <> notation?
|
||||
7 When someone tries to unmap with a trailing space, and it fails, try
|
||||
unmapping without the trailing space. Helps for ":unmap xx | unmap yy".
|
||||
6 Context-sensitive abbreviations: Specify syntax group(s) in which the
|
||||
|
@@ -50,7 +50,7 @@ which moves to the previous end of a word:
|
||||
|
||||
This is a line with example text ~
|
||||
<----<----x---->------------>
|
||||
2ge ge e we
|
||||
2ge ge e 2e
|
||||
|
||||
If you are at the last word of a line, the "w" command will take you to the
|
||||
first word in the next line. Thus you can use this to move through a
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*usr_41.txt* For Vim version 8.2. Last change: 2020 Dec 19
|
||||
*usr_41.txt* For Vim version 8.2. Last change: 2021 Jan 08
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -122,14 +122,14 @@ starts with a zero. "017" is decimal 15. A binary number starts with "0b" or
|
||||
decimal number, it will be interpreted as an octal number!
|
||||
The ":echo" command always prints decimal numbers. Example: >
|
||||
|
||||
:echo 0x7f 036
|
||||
:echo 0x7f 0o36
|
||||
< 127 30 ~
|
||||
|
||||
A number is made negative with a minus sign. This also works for hexadecimal,
|
||||
octal and binary numbers. A minus sign is also used for subtraction. Compare
|
||||
this with the previous example: >
|
||||
|
||||
:echo 0x7f -036
|
||||
:echo 0x7f -0o36
|
||||
< 97 ~
|
||||
|
||||
White space in an expression is ignored. However, it's recommended to use it
|
||||
@@ -137,7 +137,7 @@ for separating items, to make the expression easier to read. For example, to
|
||||
avoid the confusion with a negative number above, put a space between the
|
||||
minus sign and the following number: >
|
||||
|
||||
:echo 0x7f - 036
|
||||
:echo 0x7f - 0o36
|
||||
|
||||
==============================================================================
|
||||
*41.2* Variables
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 03
|
||||
*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 10
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -52,8 +52,9 @@ The Vim9 script syntax and semantics are used in:
|
||||
- a script file where the first command is `vim9script`
|
||||
- an autocommand defined in the context of the above
|
||||
|
||||
When using `:function` in a Vim9 script file the legacy syntax is used.
|
||||
However, this can be confusing and is therefore discouraged.
|
||||
When using `:function` in a Vim9 script file the legacy syntax is used, with
|
||||
the highest |scriptversion|. However, this can be confusing and is therefore
|
||||
discouraged.
|
||||
|
||||
Vim9 script and legacy Vim script can be mixed. There is no requirement to
|
||||
rewrite old scripts, they keep working as before. You may want to use a few
|
||||
@@ -70,28 +71,29 @@ Overview ~
|
||||
Brief summary of the differences you will most often encounter when using Vim9
|
||||
script and `:def` functions; details are below:
|
||||
- Comments start with #, not ": >
|
||||
echo "hello" # comment
|
||||
echo "hello" # comment
|
||||
- Using a backslash for line continuation is hardly ever needed: >
|
||||
echo "hello "
|
||||
echo "hello "
|
||||
.. yourName
|
||||
.. ", how are you?"
|
||||
- White space is required in many places.
|
||||
- Assign values without `:let`, declare variables with `:var`: >
|
||||
var count = 0
|
||||
var count = 0
|
||||
count += 3
|
||||
- Constants can be declared with `:final` and `:const`: >
|
||||
final matches = [] # add matches
|
||||
final matches = [] # add matches
|
||||
const names = ['Betty', 'Peter'] # cannot be changed
|
||||
- `:final` cannot be used as an abbreviation of `:finally`.
|
||||
- Variables and functions are script-local by default.
|
||||
- Functions are declared with argument types and return type: >
|
||||
def CallMe(count: number, message: string): bool
|
||||
- Call functions without `:call`: >
|
||||
writefile(['done'], 'file.txt')
|
||||
writefile(['done'], 'file.txt')
|
||||
- You cannot use `:xit`, `:t`, `:append`, `:change`, `:insert` or curly-braces
|
||||
names.
|
||||
- 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.
|
||||
|
||||
|
||||
Comments starting with # ~
|
||||
@@ -315,7 +317,7 @@ The constant only applies to the value itself, not what it refers to. >
|
||||
NAMES[0] = ["Jack"] # Error!
|
||||
NAMES[0][0] = "Jack" # Error!
|
||||
NAMES[1] = ["Emma"] # Error!
|
||||
Names[1][0] = "Emma" # OK, now females[0] == "Emma"
|
||||
NAMES[1][0] = "Emma" # OK, now females[0] == "Emma"
|
||||
|
||||
< *E1092*
|
||||
Declaring more than one variable at a time, using the unpack notation, is
|
||||
@@ -432,7 +434,7 @@ possible just before or after the operator. For example: >
|
||||
.. middle
|
||||
.. end
|
||||
var total = start +
|
||||
end -
|
||||
end -
|
||||
correction
|
||||
var result = positive
|
||||
? PosFunc(arg)
|
||||
@@ -629,9 +631,9 @@ one: >
|
||||
|
||||
When using "!" for inverting, there is no error for using any type and the
|
||||
result is a boolean. "!!" can be used to turn any value into boolean: >
|
||||
!'yes' == false
|
||||
!'yes' == false
|
||||
!![] == false
|
||||
!![1, 2, 3] == true
|
||||
!![1, 2, 3] == true
|
||||
|
||||
When using "`.."` for string concatenation arguments of simple types are
|
||||
always converted to string: >
|
||||
@@ -651,6 +653,14 @@ byte indexes. Example: >
|
||||
echo 'bár'[1]
|
||||
In legacy script this results in the character 0xc3 (an illegal byte), in Vim9
|
||||
script this results in the string 'á'.
|
||||
A negative index is counting from the end, "[-1]" is the last character.
|
||||
If the index is out of range then an empty string results.
|
||||
|
||||
In legacy script "++var" and "--var" would be silently accepted and have no
|
||||
effect. This is an error in Vim9 script.
|
||||
|
||||
Numbers starting with zero are not considered to be octal, only numbers
|
||||
starting with "0o" are octal: "0o744". |scriptversion-4|
|
||||
|
||||
|
||||
What to watch out for ~
|
||||
@@ -689,7 +699,7 @@ Vim9 functions are compiled as a whole: >
|
||||
if !has('feature')
|
||||
return
|
||||
endif
|
||||
use-feature # May give compilation error
|
||||
use-feature # May give a compilation error
|
||||
enddef
|
||||
For a workaround, split it in two functions: >
|
||||
func Maybe()
|
||||
@@ -709,6 +719,25 @@ evaluates to false: >
|
||||
use-feature
|
||||
endif
|
||||
enddef
|
||||
< *vim9-user-command*
|
||||
Another side effect of compiling a function is that the precense of a user
|
||||
command is checked at compile time. If the user command is defined later an
|
||||
error will result. This works: >
|
||||
command -nargs=1 MyCommand echom <q-args>
|
||||
def Works()
|
||||
MyCommand 123
|
||||
enddef
|
||||
This will give an error for "MyCommand" not being defined: >
|
||||
def Works()
|
||||
command -nargs=1 MyCommand echom <q-args>
|
||||
MyCommand 123
|
||||
enddef
|
||||
A workaround is to invoke the command indirectly with `:execute`: >
|
||||
def Works()
|
||||
command -nargs=1 MyCommand echom <q-args>
|
||||
execute 'MyCommand 123'
|
||||
enddef
|
||||
|
||||
Note that for unrecognized commands there is no check for "|" and a following
|
||||
command. This will give an error for missing `endif`: >
|
||||
def Maybe()
|
||||
@@ -946,6 +975,12 @@ an error, thus breaking backwards compatibility. For example:
|
||||
- Using a string value when setting a number options.
|
||||
- Using a number where a string is expected. *E1024*
|
||||
|
||||
One consequence is that the item type of a list or dict given to map() must
|
||||
not change. This will give an error in compiled code: >
|
||||
map([1, 2, 3], (i, v) => 'item ' .. i)
|
||||
E1012: Type mismatch; expected list<number> but got list<string>
|
||||
Instead use |mapnew()|.
|
||||
|
||||
==============================================================================
|
||||
|
||||
5. Namespace, Import and Export
|
||||
@@ -1055,14 +1090,14 @@ actually needed. A recommended mechanism:
|
||||
|
||||
1. In the plugin define user commands, functions and/or mappings that refer to
|
||||
an autoload script. >
|
||||
command -nargs=1 SearchForStuff call searchfor#Stuff(<f-args>)
|
||||
command -nargs=1 SearchForStuff call searchfor#Stuff(<f-args>)
|
||||
|
||||
< This goes in .../plugin/anyname.vim. "anyname.vim" can be freely chosen.
|
||||
|
||||
2. In the autoload script do the actual work. You can import items from
|
||||
other files to split up functionality in appropriate pieces. >
|
||||
vim9script
|
||||
import FilterFunc from "../import/someother.vim"
|
||||
import FilterFunc from "../import/someother.vim"
|
||||
def searchfor#Stuff(arg: string)
|
||||
var filtered = FilterFunc(arg)
|
||||
...
|
||||
|
Reference in New Issue
Block a user