1
0
forked from aniani/vim

Update runtime files.

This commit is contained in:
Bram Moolenaar
2022-05-21 13:08:16 +01:00
parent 0d534d9cf2
commit 2d8ed0203a
23 changed files with 8836 additions and 4734 deletions

View File

@@ -1401,7 +1401,7 @@ changenr() *changenr()*
one less than the number of the undone change.
char2nr({string} [, {utf8}]) *char2nr()*
Return number value of the first char in {string}.
Return Number value of the first char in {string}.
Examples: >
char2nr(" ") returns 32
char2nr("ABC") returns 65
@@ -1712,13 +1712,13 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
An example: >
let choice = confirm("What do you want?",
\ "&Apples\n&Oranges\n&Bananas", 2)
\ "&Apples\n&Oranges\n&Bananas", 2)
if choice == 0
echo "make up your mind!"
echo "make up your mind!"
elseif choice == 3
echo "tasteful"
echo "tasteful"
else
echo "I prefer bananas myself."
echo "I prefer bananas myself."
endif
< In a GUI dialog, buttons are used. The layout of the buttons
depends on the 'v' flag in 'guioptions'. If it is included,
@@ -2306,8 +2306,8 @@ exists({expr}) The result is a Number, which is |TRUE| if {expr} is defined,
< There must be no space between the symbol (&/$/*/#) and the
name.
There must be no extra characters after the name, although in
a few cases this is ignored. That may become more strict in
the future, thus don't count on it!
a few cases this is ignored. That may become stricter in the
future, thus don't count on it!
Working example: >
exists(":make")
< NOT working example: >
@@ -3219,7 +3219,7 @@ getchar([expr]) *getchar()*
Without [expr] and when [expr] is 0 a whole character or
special key is returned. If it is a single character, the
result is a number. Use nr2char() to convert it to a String.
result is a Number. Use |nr2char()| to convert it to a String.
Otherwise a String is returned with the encoded character.
For a special key it's a String with a sequence of bytes
starting with 0x80 (decimal: 128). This is the same value as
@@ -5468,7 +5468,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
"sid" The script local ID, used for <sid> mappings
(|<SID>|).
"scriptversion" The version of the script. 999999 for
|Vim9| script.
|Vim9| script.
"lnum" The line number in "sid", zero if unknown.
"nowait" Do not wait for other, longer mappings.
(|:map-<nowait>|).
@@ -5573,7 +5573,7 @@ mapset({dict})
Restore a mapping from a dictionary, possibly returned by
|maparg()| or |maplist()|. A buffer mapping, when dict.buffer
is true, is set on the current buffer; it is up to the caller
to insure that the intended buffer is the current buffer. This
to ensure that the intended buffer is the current buffer. This
feature allows copying mappings from one buffer to another.
The dict.mode value may restore a single mapping that covers
more than one mode, like with mode values of '!', ' ', 'nox',
@@ -8324,7 +8324,7 @@ sort({list} [, {how} [, {dict}]]) *sort()* *E702*
If you want a list to remain unmodified make a copy first: >
:let sortedlist = sort(copy(mylist))
< When {how} is omitted or is an string, then sort() uses the
< When {how} is omitted or is a string, then sort() uses the
string representation of each item to sort on. Numbers sort
after Strings, |Lists| after Numbers. For sorting text in the
current buffer use |:sort|.
@@ -8779,9 +8779,11 @@ strftime({format} [, {time}]) *strftime()*
GetFormat()->strftime()
strgetchar({str}, {index}) *strgetchar()*
Get character {index} from {str}. This uses a character
index, not a byte index. Composing characters are considered
separate characters here.
Get a Number corresponding to the character at {index} in
{str}. This uses a zero-based character index, not a byte
index. Composing characters are considered separate
characters here. Use |nr2char()| to convert the Number to a
String.
Also see |strcharpart()| and |strchars()|.
Can also be used as a |method|: >

View File

@@ -1,4 +1,4 @@
*map.txt* For Vim version 8.2. Last change: 2022 May 09
*map.txt* For Vim version 8.2. Last change: 2022 May 16
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -701,6 +701,7 @@ not to be matched with any key sequence. This is useful in plugins
*<MouseMove>*
The special key name "<MouseMove>" can be used to handle mouse movement. It
needs to be enabled with 'mousemoveevent'. Currently only works in the GUI.
The |getmousepos()| function can be used to obtain the mouse position.
*<Char>* *<Char->*
To map a character by its decimal, octal or hexadecimal number the <Char>

View File

@@ -1,4 +1,4 @@
*syntax.txt* For Vim version 8.2. Last change: 2022 May 06
*syntax.txt* For Vim version 8.2. Last change: 2022 May 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -32,13 +32,14 @@ In the User Manual:
10. Including syntax files |:syn-include|
11. Synchronizing |:syn-sync|
12. Listing syntax items |:syntax|
13. Highlight command |:highlight|
14. Linking groups |:highlight-link|
15. Cleaning up |:syn-clear|
16. Highlighting tags |tag-highlight|
17. Window-local syntax |:ownsyntax|
18. Color xterms |xterm-color|
19. When syntax is slow |:syntime|
13. Colorschemes |color-schemes|
14. Highlight command |:highlight|
15. Linking groups |:highlight-link|
16. Cleaning up |:syn-clear|
17. Highlighting tags |tag-highlight|
18. Window-local syntax |:ownsyntax|
19. Color xterms |xterm-color|
20. When syntax is slow |:syntime|
{Vi does not have any of these commands}
@@ -1511,7 +1512,7 @@ modes Conditional, Number, Statement, Comment, PreProc, Type, and String,
following the language specifications in 'Symbolic Manipulation with FORM' by
J.A.M. Vermaseren, CAN, Netherlands, 1991.
If you want include your own changes to the default colors, you have to
If you want to include your own changes to the default colors, you have to
redefine the following syntax groups:
- formConditional
@@ -4845,20 +4846,14 @@ Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
is mostly used, because it looks better.
==============================================================================
13. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
There are three types of highlight groups:
- The ones used for specific languages. For these the name starts with the
name of the language. Many of these don't have any attributes, but are
linked to a group of the second type.
- The ones used for all syntax languages.
- The ones used for the 'highlight' option.
*hitest.vim*
You can see all the groups currently active with this command: >
:so $VIMRUNTIME/syntax/hitest.vim
This will open a new window containing all highlight group names, displayed
in their own color.
13. Colorschemes *color-schemes*
In the next section you can find information about indivisual highlight groups
and how to specify colors for them. Most likely you want to just select a set
of colors by using the `:colorscheme` command, for example: >
colorscheme pablo
<
*:colo* *:colorscheme* *E185*
:colo[rscheme] Output the name of the currently active color scheme.
This is basically the same as >
@@ -4876,30 +4871,62 @@ in their own color.
Doesn't work recursively, thus you can't use
":colorscheme" in a color scheme script.
You have two options for customizing a color scheme.
For changing the appearance of specific colors, you
can redefine a color name before loading the scheme.
The desert scheme uses the khaki color for the cursor.
To use a darker variation of the same color: >
You have two options for customizing a color scheme. For changing the
appearance of specific colors, you can redefine a color name before loading
the scheme. The desert scheme uses the khaki color for the cursor. To use a
darker variation of the same color: >
let v:colornames['khaki'] = '#bdb76b'
colorscheme desert
let v:colornames['khaki'] = '#bdb76b'
colorscheme desert
<
For further customization, such as changing
|:highlight-link| associations, use another name, e.g.
"~/.vim/colors/mine.vim", and use `:runtime` to load
the original color scheme: >
runtime colors/evening.vim
hi Statement ctermfg=Blue guifg=Blue
For further customization, such as changing |:highlight-link| associations,
use another name, e.g. "~/.vim/colors/mine.vim", and use `:runtime` to load
the original color scheme: >
runtime colors/evening.vim
hi Statement ctermfg=Blue guifg=Blue
< Before the color scheme will be loaded all default
color list scripts (`colors/lists/default.vim`) will
be executed and then the |ColorSchemePre| autocommand
event is triggered. After the color scheme has been
loaded the |ColorScheme| autocommand event is
triggered.
For info about writing a color scheme file: >
:edit $VIMRUNTIME/colors/README.txt
Before the color scheme will be loaded all default color list scripts
(`colors/lists/default.vim`) will be executed and then the |ColorSchemePre|
autocommand event is triggered. After the color scheme has been loaded the
|ColorScheme| autocommand event is triggered.
If a color scheme is almost right, you can add modifications on top of it by
using the |ColorScheme| autocommand. For example, to remove the background
color (can make it transparent in some terminals): >
augroup my_colorschemes
au!
au Colorscheme pablo hi Normal ctermbg=NONE
augroup END
If you make a lot of changes it might be better to copy the distributed
colorscheme to your home directory and change it: >
:!cp $VIMRUNTIME/colors/pablo.vim ~/.vim/colors
:edit ~/.vim/colors/pablo.vim
With Vim 9.0 the collection of color schemes was updated and made work in many
different terminals. One change was to often define the Normal highlight
group to make sure the colors work well. In case you prefer the old version,
you can find them here:
https://github.com/vim/colorschemes/blob/master/legacy_colors/
For info about writing a color scheme file: >
:edit $VIMRUNTIME/colors/README.txt
==============================================================================
14. Highlight command *:highlight* *:hi* *E28* *E411* *E415*
There are three types of highlight groups:
- The ones used for specific languages. For these the name starts with the
name of the language. Many of these don't have any attributes, but are
linked to a group of the second type.
- The ones used for all syntax languages.
- The ones used for the 'highlight' option.
*hitest.vim*
You can see all the groups currently active with this command: >
:so $VIMRUNTIME/syntax/hitest.vim
This will open a new window containing all highlight group names, displayed
in their own color.
:hi[ghlight] List all the current highlight groups that have
attributes set.
@@ -5206,7 +5233,7 @@ guisp={color-name} *highlight-guisp*
All values are hexadecimal, range from "00" to "ff". Examples: >
:highlight Comment guifg=#11f0c3 guibg=#ff00ff
<
If you are authoring a color scheme and use the same hexademical value
If you are authoring a color scheme and use the same hexadecimal value
repeatedly, you can define a name for it in |v:colornames|. For
example: >
@@ -5416,7 +5443,7 @@ Tooltip Current font, background and foreground of the tooltips.
set.
==============================================================================
14. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
15. Linking groups *:hi-link* *:highlight-link* *E412* *E413*
When you want to use the same highlighting for several syntax groups, you
can do this more easily by linking the groups into one common highlight
@@ -5460,7 +5487,7 @@ another color scheme, put a command like this in the
highlight! default link cComment Question
==============================================================================
15. Cleaning up *:syn-clear* *E391*
16. Cleaning up *:syn-clear* *E391*
If you want to clear the syntax stuff for the current buffer, you can use this
command: >
@@ -5552,7 +5579,7 @@ syntax/syncolor.vim files are loaded:
them.
==============================================================================
16. Highlighting tags *tag-highlight*
17. Highlighting tags *tag-highlight*
If you want to highlight all the tags in your file, you can use the following
mappings.
@@ -5588,7 +5615,7 @@ And put these lines in your .vimrc: >
autocmd BufRead,BufNewFile *.[ch] endif
==============================================================================
17. Window-local syntax *:ownsyntax*
18. Window-local syntax *:ownsyntax*
Normally all windows on a buffer share the same syntax settings. It is
possible, however, to set a particular window on a file to have its own
@@ -5618,7 +5645,7 @@ is loaded into that window or the file is reloaded.
When splitting the window, the new window will use the original syntax.
==============================================================================
18. Color xterms *xterm-color* *color-xterm*
19. Color xterms *xterm-color* *color-xterm*
Most color xterms have only eight colors. If you don't get colors with the
default setup, it should work with these lines in your .vimrc: >
@@ -5762,7 +5789,7 @@ that Setup / Font / Enable Bold is NOT enabled.
==============================================================================
19. When syntax is slow *:syntime*
20. When syntax is slow *:syntime*
This is aimed at authors of a syntax file.

View File

@@ -4267,6 +4267,7 @@ E1274 cmdline.txt /*E1274*
E1276 builtin.txt /*E1276*
E1278 eval.txt /*E1278*
E128 eval.txt /*E128*
E1281 pattern.txt /*E1281*
E129 eval.txt /*E129*
E13 message.txt /*E13*
E131 eval.txt /*E131*
@@ -5778,6 +5779,7 @@ autocmd-events autocmd.txt /*autocmd-events*
autocmd-events-abc autocmd.txt /*autocmd-events-abc*
autocmd-execute autocmd.txt /*autocmd-execute*
autocmd-expand autocmd.txt /*autocmd-expand*
autocmd-functions usr_41.txt /*autocmd-functions*
autocmd-groups autocmd.txt /*autocmd-groups*
autocmd-intro autocmd.txt /*autocmd-intro*
autocmd-list autocmd.txt /*autocmd-list*
@@ -5789,6 +5791,9 @@ autocmd-remove autocmd.txt /*autocmd-remove*
autocmd-searchpat autocmd.txt /*autocmd-searchpat*
autocmd-use autocmd.txt /*autocmd-use*
autocmd.txt autocmd.txt /*autocmd.txt*
autocmd_add() builtin.txt /*autocmd_add()*
autocmd_delete() builtin.txt /*autocmd_delete()*
autocmd_get() builtin.txt /*autocmd_get()*
autocmds-kept version5.txt /*autocmds-kept*
autocommand autocmd.txt /*autocommand*
autocommand-events autocmd.txt /*autocommand-events*
@@ -6189,6 +6194,7 @@ col() builtin.txt /*col()*
coldfusion.vim syntax.txt /*coldfusion.vim*
collapse tips.txt /*collapse*
collate-variable eval.txt /*collate-variable*
color-schemes syntax.txt /*color-schemes*
color-xterm syntax.txt /*color-xterm*
coloring syntax.txt /*coloring*
colortest.vim syntax.txt /*colortest.vim*

View File

@@ -1,4 +1,4 @@
*testing.txt* For Vim version 8.2. Last change: 2022 Apr 03
*testing.txt* For Vim version 8.2. Last change: 2022 May 16
VIM REFERENCE MANUAL by Bram Moolenaar

View File

@@ -1,4 +1,4 @@
*todo.txt* For Vim version 8.2. Last change: 2022 May 14
*todo.txt* For Vim version 8.2. Last change: 2022 May 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -38,6 +38,9 @@ browser use: https://github.com/vim/vim/issues/1234
*known-bugs*
-------------------- Known bugs and current work -----------------------
Make :defcompile accept a function argument, like :disassemble
Useful for global functions.
Once Vim9 is stable:
- Use Vim9 for more runtime files.
- Check code coverage, add more tests if needed.
@@ -50,9 +53,10 @@ Once Vim9 is stable:
Graduate FEAT_CINDENT and FEAT_SMARTINDENT ?
Update the user manual:
- Move most of usr_52.txt into usr_41.txt
- Make usr_41.txt only about basic script writing
- Update usr_41.txt for Vim9 script
- Fill usr_50.txt as an "advanced section" of usr_41.txt
Add links from usr_41 to usr_50.
- Make usr_51.txt use Vim9 script. Still need usr_52.txt?
Further Vim9 improvements, possibly after launch:
@@ -130,14 +134,13 @@ Text properties:
where property fits in.
Or Should we let the textprop highlight overrule other (e.g. diff) highlight
if the priority is above a certain value? (#7392)
Combining text property with 'cursorline' does not always work (Billie
Cleek, #5533)
- "C" works OK. "dd" fails to delete text property in a buffer with a single
line.
- Add text property that shifts text to make room for annotation (e.g.
variable type). Like the opposite of conceal. Requires fixing the cursor
positioning and mouse clicks as with conceal mode.
- Auto-indenting may cause highlighting to shift. (#7719)
- Combining text property with 'cursorline' does not always work (Billie
Cleek, #5533)
- See remarks at top of src/textprop.c
'incsearch' with :s:
@@ -659,9 +662,6 @@ that Vim doesn't find the edited file in the buffer list, causing the
ATTENTION message? (Tony Mechelynck, 2008 Dec 1)
Also: swap files are in ~/tmp/ One has relative file name ".mozilla/...".
'foldcolumn' in modeline applied to wrong window when using a session. (Teemu
Likonen, March 19)
When using a timer callback vgetc_busy is reset, allowing for using input().
But in a channel callback this does not happen. We need to do something
similar to check_due_timer(). Also see #3809.
@@ -886,9 +886,6 @@ word is re-added to it. (Matej Cepl, 2018 Feb 6)
Fold at end of the buffer behaves inconsistently. (James McCoy, 2017 Oct 9)
With foldmethod=syntax and nofoldenable comment highlighting isn't removed.
(Marcin Szewczyk, 2017 Apr 26)
Using 'wildignore' also applies to literally entered file name. Also with
:drop (remote commands).
@@ -1002,8 +999,6 @@ After using :noautocmd CursorMoved may still trigger. (Andy Stewart, 2017 Sep
When bracketed paste is used, pasting at the ":append" prompt does not get the
line breaks. (Ken Takata, 2017 Aug 22)
The ":move" command does not honor closed folds. (Ryan Lue, #2351)
Cannot copy modeless selection when cursor is inside it. (lkintact, #2300)
Test_writefile_fails_conversion failure on Solaris because if different iconv
@@ -1534,11 +1529,6 @@ was already defined.
Patch for ordered dict. (Ozaki Kiichi, 2015 May 7)
Patch to make closed folds line up. (Charles Campbell, 2014 Sep 12)
Remark from Roland Eggner: does it cause crashes? (2014 Dec 12)
Updated patch by Roland Eggner, Dec 16
Updated patch from Charles, 2016 Jul 2
Patch for building a 32bit Vim with 64bit MingW compiler.
(Michael Soyka, 2014 Oct 15)
@@ -1714,8 +1704,6 @@ Patch to support 'u' in interactive substitute. (Christian Brabandt, 2012 Sep
Dialog is too big on Linux too. (David Fishburn, 2013 Sep 2)
Patch to make fold updates much faster. (Christian Brabandt, 2012 Dec)
- Add regex for 'paragraphs' and 'sections': 'parare' and 'sectre'. Combine
the two into a regex for searching. (Ned Konz)
Patch by Christian Brabandt, 2013 Apr 20, unfinished.
@@ -1779,10 +1767,6 @@ URXVT:
- Use urxvt mouse support also in xterm. Explanations:
http://www.midnight-commander.org/ticket/2662
Patch to have the fold and sign column and at the last line of the buffer.
(Marco Hinz, 2014 Sep 25)
Alternate suggestion: let all columns continue, also the number column.
Patch to add tests for if_xcmdsrv.c., Jul 8, need some more work. (Brian Burns)
New tests Jul 13. Update Jul 17. Discussion Jul 18.
@@ -1983,9 +1967,6 @@ the command line. (Ingo Karkat, 2011 Jan 25)
Since patch 7.2.46 Yankring plugin has become very slow, eventually make Vim
crash? (Raiwil, 2010 Nov 17)
Patch to add FoldedLineNr highlighting: different highlighting for the line
number of a closed fold. (eXerigumo Clanjor, 2013 Jul 15)
Regexp engine performance:
- Profiling:
./vim -u NONE -s ~/vim/test/ruby.vim
@@ -2097,9 +2078,6 @@ like it has ":keepjumps" before it.
Coverity: Check if there are new reported defects:
https://scan.coverity.com/projects/241
Patch to use 'foldnestmax' also for "marker" foldmethod. (Arnaud Lacombe, 2011
Jan 7)
Problem with editing file in binary mode. (Ingo Krabbe, 2009 Oct 8)
Display error when 'tabline' that includes a file name with double-width
@@ -2112,9 +2090,6 @@ Using ']' as the end of a range in a pattern requires double escaping:
Syntax priority problem. (Charles Campbell, 2011 Sep 15)
When completion inserts the first match, it may trigger the line to be folded.
Disable updating folds while completion is active? (Peter Odding, 2010 Jun 9)
For running gvim on a USB stick: avoid the OLE registration. Use a command
line argument -noregister.
@@ -2189,10 +2164,6 @@ Don't load macmap.vim on startup, turn it into a plugin. (Ron Aaron,
Add "no_hlsearch" to winsaveview().
When 'foldmethod' is "indent", adding an empty line below a fold and then
indented text, creates a new fold instead of joining it with the previous one.
(Evan Laforge, 2009 Oct 17)
Bug: When reloading a buffer changed outside of Vim, BufRead autocommands
are applied to the wrong buffer/window. (Ben Fritz, 2009 Apr 2, May 11)
Ignore window options when not in the right window?
@@ -2412,8 +2383,6 @@ Problem with 'ts' set to 9 and 'showbreak' to ">>>". (Matthew Winn, 2007 Oct
":tab help" always opens a new tab, while ":help" re-uses an existing window.
Would be more consistent when an existing tab is re-used. (Tony Mechelynck)
Add ":nofold". Range will apply without expanding to closed fold.
Using Aap to build Vim: add remarks about how to set personal preferences.
Example on http://www.calmar.ws/tmp/aap.html
@@ -3809,6 +3778,30 @@ Diff mode:
Folding:
(commands still available: zI zJ zK zp zP zq zQ zV zy zY;
secondary: zB zS zT zZ, z=)
- Patch to make closed folds line up. (Charles Campbell, 2014 Sep 12)
Remark from Roland Eggner: does it cause crashes? (2014 Dec 12)
Updated patch by Roland Eggner, Dec 16
Updated patch from Charles, 2016 Jul 2
- Patch to make fold updates much faster. (Christian Brabandt, 2012 Dec)
- Patch to have the fold and sign column and at the last line of the buffer.
(Marco Hinz, 2014 Sep 25)
Alternate suggestion: let all columns continue, also the number column.
- Patch to add FoldedLineNr highlighting: different highlighting for the
line number of a closed fold. (eXerigumo Clanjor, 2013 Jul 15)
- Patch to use 'foldnestmax' also for "marker" foldmethod. (Arnaud Lacombe,
2011 Jan 7)
- 'foldcolumn' in modeline applied to wrong window when using a session.
(Teemu Likonen, March 19)
- With foldmethod=syntax and nofoldenable comment highlighting isn't
removed. (Marcin Szewczyk, 2017 Apr 26)
- The ":move" command does not honor closed folds. (Ryan Lue, #2351)
- When completion inserts the first match, it may trigger the line to be
folded. Disable updating folds while completion is active? (Peter Odding,
2010 Jun 9)
- When 'foldmethod' is "indent", adding an empty line below a fold and then
indented text, creates a new fold instead of joining it with the previous
one. (Evan Laforge, 2009 Oct 17)
- Add ":nofold". Range will apply without expanding to closed fold.
8 Vertical folds: looks like vertically split windows, but the cursor moves
through the vertical separator, separator moves when scrolling.
8 Add "z/" and "z?" for searching in not folded text only. Or use a regexp

View File

@@ -1,4 +1,4 @@
*usr_41.txt* For Vim version 8.2. Last change: 2022 May 13
*usr_41.txt* For Vim version 8.2. Last change: 2022 May 21
VIM USER MANUAL - by Bram Moolenaar
@@ -1923,6 +1923,8 @@ are script-local.
If you split your plugin into parts, you can use `import` and `export` to
share items between those parts. See `:export` for the details.
More information about writing plugins is in |usr_51.txt|.
==============================================================================
Next chapter: |usr_42.txt| Add new menus

View File

@@ -1,4 +1,4 @@
*usr_51.txt* For Vim version 8.2. Last change: 2022 May 13
*usr_51.txt* For Vim version 8.2. Last change: 2022 May 14
VIM USER MANUAL - by Bram Moolenaar
@@ -197,8 +197,8 @@ would need to prefix the name with "s:".
We will define a function that adds a new typing correction: >
30 def Add(from: string, correct: bool)
31 var to = input("type the correction for " .. from .. ": ")
32 exe ":iabbrev " .. from .. " " .. to
31 var to = input($"type the correction for {from}: ")
32 exe $":iabbrev {from} {to}"
..
36 enddef

View File

@@ -1,4 +1,4 @@
*usr_52.txt* For Vim version 8.2. Last change: 2022 May 13
*usr_52.txt* For Vim version 8.2. Last change: 2022 May 16
VIM USER MANUAL - by Bram Moolenaar
@@ -110,10 +110,10 @@ Although it's shorter to do: >
==============================================================================
*52.3* Functions and types
Legacy Vim script does have type checking, but this happens at runtime, when
the code is executed. And it's permissive, often a computation gives an
unexpected value instead of reporting an error. Thus you can define a
function and think it's fine, but see a problem only later when it is called: >
Legacy Vim script only checks types at runtime, when the code is executed.
And it's permissive, often a computation gives an unexpected value instead of
reporting an error. Thus you can define a function and think it's fine, but
see a problem only later when it is called: >
let s:collected = ''
func ExtendAndReturn(add)
let s:collected += a:add
@@ -133,12 +133,16 @@ the argument is used without the "a:" prefix: >
s:collected += add
return s:collected
enddef
defcompile
disassemble ExtendAndReturn
Here we use `:defcompile` to do the compilation right away, without it the
Here we use `:disassemble` to do the compilation right away, without it the
compilation would happen when the function is called. Vim will tell you what
you did wrong: >
E1013: type mismatch, expected number but got string
E1051: Wrong argument type for +
Side note: here the context is legacy script, when using Vim9 script you would
put `:defcompile` at the end of the script to check for errors in the
functions defined in it.
Vim9 script is strict, it uses the "+" operator only for numbers and floats.
For string concatenation ".." must be used. This avoids mistakes and avoids