mirror of
https://github.com/vim/vim.git
synced 2025-10-14 07:04:10 -04:00
Update runtime files.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
*eval.txt* For Vim version 8.2. Last change: 2020 aug 30
|
||||
*eval.txt* For Vim version 8.2. Last change: 2020 Sep 06
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -120,8 +120,9 @@ base, use |str2nr()|.
|
||||
|
||||
*TRUE* *FALSE* *Boolean*
|
||||
For boolean operators Numbers are used. Zero is FALSE, non-zero is TRUE.
|
||||
You can also use |v:false| and |v:true|. When TRUE is returned from a
|
||||
function it is the Number one, FALSE is the number zero.
|
||||
You can also use |v:false| and |v:true|. In Vim9 script |false| and |true|.
|
||||
When TRUE is returned from a function it is the Number one, FALSE is the
|
||||
number zero.
|
||||
|
||||
Note that in the command: >
|
||||
:if "foo"
|
||||
@@ -2360,7 +2361,7 @@ assert_equalfile({fname-one}, {fname-two} [, {msg}])
|
||||
Number assert file contents are equal
|
||||
assert_exception({error} [, {msg}])
|
||||
Number assert {error} is in v:exception
|
||||
assert_fails({cmd} [, {error} [, {msg} [, {lnum}]]])
|
||||
assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
|
||||
Number assert {cmd} fails
|
||||
assert_false({actual} [, {msg}])
|
||||
Number assert {actual} is false
|
||||
@@ -3362,7 +3363,7 @@ bufnr([{expr} [, {create}]])
|
||||
above.
|
||||
|
||||
If the buffer doesn't exist, -1 is returned. Or, if the
|
||||
{create} argument is present and not zero, a new, unlisted,
|
||||
{create} argument is present and TRUE, a new, unlisted,
|
||||
buffer is created and its number is returned. Example: >
|
||||
let newbuf = bufnr('Scratch001', 1)
|
||||
< Using an empty name uses the current buffer. To create a new
|
||||
@@ -3513,7 +3514,7 @@ char2nr({expr} [, {utf8}]) *char2nr()*
|
||||
Example for "utf-8": >
|
||||
char2nr("á") returns 225
|
||||
char2nr("á"[0]) returns 195
|
||||
< With {utf8} set to 1, always treat as utf-8 characters.
|
||||
< With {utf8} set to TRUE, always treat as utf-8 characters.
|
||||
A combining character is a separate character.
|
||||
|nr2char()| does the opposite.
|
||||
To turn a string into a list of character numbers: >
|
||||
@@ -7608,7 +7609,7 @@ perleval({expr}) *perleval()*
|
||||
< {only available when compiled with the |+perl| feature}
|
||||
|
||||
|
||||
popup_ functions are documented here: |popup-functions|.
|
||||
popup_ functions are documented here: |popup-functions|
|
||||
|
||||
|
||||
pow({x}, {y}) *pow()*
|
||||
@@ -11040,7 +11041,8 @@ win_screenpos({nr}) *win_screenpos()*
|
||||
Return the screen position of window {nr} as a list with two
|
||||
numbers: [row, col]. The first window always has position
|
||||
[1, 1], unless there is a tabline, then it is [2, 1].
|
||||
{nr} can be the window number or the |window-ID|.
|
||||
{nr} can be the window number or the |window-ID|. Use zero
|
||||
for the current window.
|
||||
Return [0, 0] if the window cannot be found in the current
|
||||
tabpage.
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*map.txt* For Vim version 8.2. Last change: 2020 Aug 30
|
||||
*map.txt* For Vim version 8.2. Last change: 2020 Sep 06
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -195,7 +195,7 @@ Note that this works when the <nowait> mapping fully matches and is found
|
||||
before any partial matches. This works when:
|
||||
- There is only one matching buffer-local mapping, since these are always
|
||||
found before global mappings.
|
||||
- There is another buffer-local mapping that partly matches, but it is was
|
||||
- There is another buffer-local mapping that partly matches, but it is
|
||||
defined earlier (last defined mapping is found first).
|
||||
|
||||
*:map-<silent>* *:map-silent*
|
||||
@@ -289,15 +289,8 @@ Here is an example that inserts a list number that increases: >
|
||||
CTRL-L inserts the next number, CTRL-R resets the count. CTRL-R returns an
|
||||
empty string, so that nothing is inserted.
|
||||
|
||||
Note that there are some tricks to make special keys work and escape CSI bytes
|
||||
in the text. The |:map| command also does this, thus you must avoid that it
|
||||
is done twice. This does not work: >
|
||||
:imap <expr> <F3> "<Char-0x611B>"
|
||||
Because the <Char- sequence is escaped for being a |:imap| argument and then
|
||||
again for using <expr>. This does work: >
|
||||
:imap <expr> <F3> "\u611B"
|
||||
Using 0x80 as a single byte before other text does not work, it will be seen
|
||||
as a special key.
|
||||
Note that using 0x80 as a single byte before other text does not work, it will
|
||||
be seen as a special key.
|
||||
|
||||
|
||||
1.3 MAPPING AND MODES *:map-modes*
|
||||
@@ -881,35 +874,47 @@ g@{motion} Call the function set by the 'operatorfunc' option.
|
||||
|
||||
Here is an example that counts the number of spaces with <F4>: >
|
||||
|
||||
nmap <silent> <F4> :set opfunc=CountSpaces<CR>g@
|
||||
vmap <silent> <F4> :<C-U>call CountSpaces(visualmode(), 1)<CR>
|
||||
nnoremap <expr> <F4> CountSpaces()
|
||||
xnoremap <expr> <F4> CountSpaces()
|
||||
" doubling <F4> works on a line
|
||||
nnoremap <expr> <F4><F4> CountSpaces() .. '_'
|
||||
|
||||
function CountSpaces(type = '') abort
|
||||
if a:type == ''
|
||||
set opfunc=CountSpaces
|
||||
return 'g@'
|
||||
endif
|
||||
|
||||
function! CountSpaces(type, ...)
|
||||
let sel_save = &selection
|
||||
let &selection = "inclusive"
|
||||
let reg_save = @@
|
||||
let reg_save = getreginfo('"')
|
||||
let cb_save = &clipboard
|
||||
let visual_marks_save = [getpos("'<"), getpos("'>")]
|
||||
|
||||
if a:0 " Invoked from Visual mode, use gv command.
|
||||
silent exe "normal! gvy"
|
||||
elseif a:type == 'line'
|
||||
silent exe "normal! '[V']y"
|
||||
else
|
||||
silent exe "normal! `[v`]y"
|
||||
endif
|
||||
|
||||
echomsg strlen(substitute(@@, '[^ ]', '', 'g'))
|
||||
|
||||
let &selection = sel_save
|
||||
let @@ = reg_save
|
||||
try
|
||||
set clipboard= selection=inclusive
|
||||
let commands = #{line: "'[V']y", char: "`[v`]y", block: "`[\<c-v>`]y"}
|
||||
silent exe 'noautocmd keepjumps normal! ' .. get(commands, a:type, '')
|
||||
echom getreg('"')->count(' ')
|
||||
finally
|
||||
call setreg('"', reg_save)
|
||||
call setpos("'<", visual_marks_save[0])
|
||||
call setpos("'>", visual_marks_save[1])
|
||||
let &clipboard = cb_save
|
||||
let &selection = sel_save
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
An <expr> mapping is used to be able to fetch any prefixed count and register.
|
||||
This also avoids using a command line, which would trigger CmdlineEnter and
|
||||
CmdlineLeave autocommands.
|
||||
|
||||
Note that the 'selection' option is temporarily set to "inclusive" to be able
|
||||
to yank exactly the right text by using Visual mode from the '[ to the ']
|
||||
mark.
|
||||
|
||||
Also note that there is a separate mapping for Visual mode. It removes the
|
||||
"'<,'>" range that ":" inserts in Visual mode and invokes the function with
|
||||
visualmode() and an extra argument.
|
||||
Also note that the 'clipboard' option is temporarily emptied to avoid
|
||||
clobbering the `"*` or `"+` registers, if its value contains the item `unnamed`
|
||||
or `unnamedplus`.
|
||||
|
||||
==============================================================================
|
||||
2. Abbreviations *abbreviations* *Abbreviations*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*message.txt* For Vim version 8.2. Last change: 2020 Aug 20
|
||||
*message.txt* For Vim version 8.2. Last change: 2020 Sep 07
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -75,7 +75,7 @@ See `:messages` above.
|
||||
|
||||
|
||||
LIST OF MESSAGES
|
||||
*E222* *E228* *E232* *E256* *E293* *E298* *E304* *E317*
|
||||
*E222* *E228* *E232* *E293* *E298* *E304* *E317*
|
||||
*E318* *E356* *E438* *E439* *E440* *E316* *E320* *E322*
|
||||
*E323* *E341* *E473* *E570* *E685* *E292* >
|
||||
Add to read buffer
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 8.2. Last change: 2020 Aug 28
|
||||
*options.txt* For Vim version 8.2. Last change: 2020 Sep 06
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -701,6 +701,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
"double": Use twice the width of ASCII characters.
|
||||
*E834* *E835*
|
||||
The value "double" cannot be used if 'listchars' or 'fillchars'
|
||||
contains a character that would be double width.
|
||||
|
||||
The values are overruled for characters specified with
|
||||
|setcellwidths()|.
|
||||
@@ -6563,7 +6564,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
For the Amiga the default is ">". For MS-Windows the default is
|
||||
">%s 2>&1". The output is directly saved in a file and not echoed to
|
||||
the screen.
|
||||
For Unix the default it "| tee". The stdout of the compiler is saved
|
||||
For Unix the default is "| tee". The stdout of the compiler is saved
|
||||
in a file and echoed to the screen. If the 'shell' option is "csh" or
|
||||
"tcsh" after initializations, the default becomes "|& tee". If the
|
||||
'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
|
||||
@@ -7807,8 +7808,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
*'termwinsize'* *'tws'*
|
||||
'termwinsize' 'tws' string (default "")
|
||||
local to window
|
||||
Size of the |terminal| window. Format: {rows}x{columns} or
|
||||
{rows}*{columns}.
|
||||
Size used when opening the |terminal| window. Format:
|
||||
{rows}x{columns} or {rows}*{columns}.
|
||||
- When empty the terminal gets the size from the window.
|
||||
- When set with a "x" (e.g., "24x80") the terminal size is not
|
||||
adjusted to the window size. If the window is smaller only the
|
||||
@@ -7819,6 +7820,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
- When rows is zero then use the height of the window.
|
||||
- When columns is zero then use the width of the window.
|
||||
- Using "0x0" or "0*0" is the same as empty.
|
||||
- Can be overruled in the |term_start()| options with "term_rows" and
|
||||
"term_cols".
|
||||
|
||||
Examples:
|
||||
"30x0" uses 30 rows and the current window width.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*pattern.txt* For Vim version 8.2. Last change: 2020 Aug 15
|
||||
*pattern.txt* For Vim version 8.2. Last change: 2020 Sep 01
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -797,11 +797,12 @@ An ordinary atom can be:
|
||||
^beep( the start of the C function "beep" (probably).
|
||||
|
||||
*/\^*
|
||||
\^ Matches literal '^'. Can be used at any position in the pattern.
|
||||
\^ Matches literal '^'. Can be used at any position in the pattern, but
|
||||
not inside [].
|
||||
|
||||
*/\_^*
|
||||
\_^ Matches start-of-line. |/zero-width| Can be used at any position in
|
||||
the pattern.
|
||||
the pattern, but not inside [].
|
||||
Example matches ~
|
||||
\_s*\_^foo white space and blank lines and then "foo" at
|
||||
start-of-line
|
||||
@@ -812,12 +813,13 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
|
||||
|/zero-width|
|
||||
|
||||
*/\$*
|
||||
\$ Matches literal '$'. Can be used at any position in the pattern.
|
||||
\$ Matches literal '$'. Can be used at any position in the pattern, but
|
||||
not inside [].
|
||||
|
||||
*/\_$*
|
||||
\_$ Matches end-of-line. |/zero-width| Can be used at any position in the
|
||||
pattern. Note that "a\_$b" never matches, since "b" cannot match an
|
||||
end-of-line. Use "a\nb" instead |/\n|.
|
||||
pattern, but not inside []. Note that "a\_$b" never matches, since
|
||||
"b" cannot match an end-of-line. Use "a\nb" instead |/\n|.
|
||||
Example matches ~
|
||||
foo\_$\_s* "foo" at end-of-line and following white space and
|
||||
blank lines
|
||||
@@ -840,8 +842,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
|
||||
|/zero-width|
|
||||
|
||||
*/\zs*
|
||||
\zs Matches at any position, and sets the start of the match there: The
|
||||
next char is the first char of the whole match. |/zero-width|
|
||||
\zs Matches at any position, but not inside [], and sets the start of the
|
||||
match there: The next char is the first char of the whole match.
|
||||
|/zero-width|
|
||||
Example: >
|
||||
/^\s*\zsif
|
||||
< matches an "if" at the start of a line, ignoring white space.
|
||||
@@ -852,8 +855,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
|
||||
This cannot be followed by a multi. *E888*
|
||||
{not available when compiled without the |+syntax| feature}
|
||||
*/\ze*
|
||||
\ze Matches at any position, and sets the end of the match there: The
|
||||
previous char is the last char of the whole match. |/zero-width|
|
||||
\ze Matches at any position, but not inside [], and sets the end of the
|
||||
match there: The previous char is the last char of the whole match.
|
||||
|/zero-width|
|
||||
Can be used multiple times, the last one encountered in a matching
|
||||
branch is used.
|
||||
Example: "end\ze\(if\|for\)" matches the "end" in "endif" and
|
||||
|
@@ -4071,7 +4071,6 @@ E252 options.txt /*E252*
|
||||
E253 mbyte.txt /*E253*
|
||||
E254 message.txt /*E254*
|
||||
E255 sign.txt /*E255*
|
||||
E256 message.txt /*E256*
|
||||
E257 if_cscop.txt /*E257*
|
||||
E258 remote.txt /*E258*
|
||||
E259 if_cscop.txt /*E259*
|
||||
@@ -6323,6 +6322,7 @@ extend() eval.txt /*extend()*
|
||||
extension-removal cmdline.txt /*extension-removal*
|
||||
extensions-improvements todo.txt /*extensions-improvements*
|
||||
f motion.txt /*f*
|
||||
false vim9.txt /*false*
|
||||
false-variable eval.txt /*false-variable*
|
||||
faq intro.txt /*faq*
|
||||
farsi farsi.txt /*farsi*
|
||||
@@ -8485,6 +8485,7 @@ progname-variable eval.txt /*progname-variable*
|
||||
progpath-variable eval.txt /*progpath-variable*
|
||||
progress.vim syntax.txt /*progress.vim*
|
||||
prompt-buffer channel.txt /*prompt-buffer*
|
||||
prompt_getprompt() eval.txt /*prompt_getprompt()*
|
||||
prompt_setcallback() eval.txt /*prompt_setcallback()*
|
||||
prompt_setinterrupt() eval.txt /*prompt_setinterrupt()*
|
||||
prompt_setprompt() eval.txt /*prompt_setprompt()*
|
||||
@@ -9644,6 +9645,7 @@ toupper() eval.txt /*toupper()*
|
||||
tr() eval.txt /*tr()*
|
||||
trim() eval.txt /*trim()*
|
||||
trojan-horse starting.txt /*trojan-horse*
|
||||
true vim9.txt /*true*
|
||||
true-variable eval.txt /*true-variable*
|
||||
trunc() eval.txt /*trunc()*
|
||||
try-conditionals eval.txt /*try-conditionals*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*terminal.txt* For Vim version 8.2. Last change: 2020 Jun 06
|
||||
*terminal.txt* For Vim version 8.2. Last change: 2020 Sep 04
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -476,9 +476,11 @@ term_dumpdiff({filename}, {filename} [, {options}])
|
||||
"term_name" name to use for the buffer name, instead
|
||||
of the first file name.
|
||||
"term_rows" vertical size to use for the terminal,
|
||||
instead of using 'termwinsize'
|
||||
instead of using 'termwinsize', but
|
||||
respecting the minimal size
|
||||
"term_cols" horizontal size to use for the terminal,
|
||||
instead of using 'termwinsize'
|
||||
instead of using 'termwinsize', but
|
||||
respecting the minimal size
|
||||
"vertical" split the window vertically
|
||||
"curwin" use the current window, do not split the
|
||||
window; fails if the current buffer
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*testing.txt* For Vim version 8.2. Last change: 2020 Aug 17
|
||||
*testing.txt* For Vim version 8.2. Last change: 2020 Sep 06
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 8.2. Last change: 2020 Aug 29
|
||||
*todo.txt* For Vim version 8.2. Last change: 2020 Sep 07
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -41,15 +41,45 @@ browser use: https://github.com/vim/vim/issues/1234
|
||||
Why does Test_invalid_sid() not work in the GUI?
|
||||
|
||||
Making everything work:
|
||||
- Check :const works the same as in legacy script.
|
||||
- Should :const work the same as in legacy script?
|
||||
Or should it work like in Typescript: only the variable is fixed, not the
|
||||
value itself.
|
||||
Then use ":const!" to also fix/lock the value?
|
||||
Typescript uses "as const", which is weird.
|
||||
Alternative: const var = <const>value
|
||||
looks quite strange quite verbose
|
||||
But can be used in several places:
|
||||
SomeFunc(<const>[1, 2, 3])
|
||||
In Vim this basically means "lock this value".
|
||||
How about:
|
||||
SomeFunc(<const>[[1], [2], [3]]) # are sub-lists immutable?
|
||||
SomeFunc(<const>myList) # is myList mutable afterwards?
|
||||
|
||||
- Run the same tests in :def and Vim9 script, like in Test_expr7_not()
|
||||
- :put with a "=" register argument doesn't work, need to find the expression
|
||||
and compile it. (#6397)
|
||||
- At the Vim9 script level, keep script variables local to the block they are
|
||||
declared in? Need to remember what variables were declared and delete them
|
||||
when leaving the block.
|
||||
- Implement { } block at the script level.
|
||||
- Use the line number argument with assert_fails() in many more tests.
|
||||
declared in, like in Javascript (using :let).
|
||||
-> Need to remember what variables were declared and delete them when
|
||||
leaving the block.
|
||||
-> if a function is defined it may need to keep the block-locals
|
||||
Then Implement { } block at the script level.
|
||||
- Recognize call to assert_fails() and execute it in the function context?
|
||||
Won't work if the command itself fails, not an expression failure:
|
||||
assert_fails("unknown", "E99:")
|
||||
Use try/catch is complicated:
|
||||
let did_catch = false
|
||||
try
|
||||
unknown
|
||||
catch
|
||||
assert_caught('E99:')
|
||||
did_catch = true
|
||||
endtry
|
||||
assert_true('did_catch')
|
||||
Add a new command,
|
||||
assertfail
|
||||
unknown
|
||||
endassertfail E99:.*unknown
|
||||
- In autocmd: use legacy syntax, not whatever the current script uses?
|
||||
- need to check type when a declaration specifies a type: #6507
|
||||
let nr: number = 'asdf'
|
||||
@@ -181,10 +211,8 @@ Text properties:
|
||||
- :goto does not go to the right place when text properties are present.
|
||||
(#5930)
|
||||
- "cc" does not call inserted_bytes(). (Axel Forsman, #5763)
|
||||
- Get E685 with a sequence of commands. (#5674)
|
||||
- Combining text property with 'cursorline' does not always work (Billie
|
||||
Cleek, #5533)
|
||||
- Text properties spanning more than one line. #5683
|
||||
- See remarks at top of src/textprop.c
|
||||
|
||||
'incsearch' with :s:
|
||||
@@ -263,7 +291,8 @@ Terminal emulator window:
|
||||
|
||||
Error numbers available: E653
|
||||
|
||||
Remove "MacOS X installation"? $APPDIR is no longer set.
|
||||
Patch to implement the vimtutor with a plugin: #6414
|
||||
Was originally writtten by Felipe Morales.
|
||||
|
||||
Remove SPACE_IN_FILENAME ? It is only used for completion.
|
||||
|
||||
@@ -372,9 +401,6 @@ When changing the crypt key the buffer should be considered modified.
|
||||
Like when changing 'fileformat'. Save the old key in save_file_ff().
|
||||
(Ninu-Ciprian Marginean)
|
||||
|
||||
Patch to implement the vimtutor with a plugin: #6414
|
||||
Was originally writtten by Felipe Morales.
|
||||
|
||||
Strange sequence of BufWipeout and BufNew events while doing omni-complete.
|
||||
(Paul Jolly, #5656)
|
||||
Get BufDelete without preceding BufNew. (Paul Jolly, #5694)
|
||||
@@ -397,6 +423,7 @@ Undo puts cursor in wrong line after "cG<Esc>" undo.
|
||||
Implement completion for "breakadd". Should expand the second argument, e.g.
|
||||
"func", and then function names after ":breakadd func". Including
|
||||
script-local functions.
|
||||
Also for ":profile".
|
||||
|
||||
:unmap <c-n> gives error but does remove the mapping. (Antony Scriven, 2019
|
||||
Dec 19)
|
||||
@@ -1222,8 +1249,6 @@ Suggestion to improve pt-br spell checking. (Marcelo D Montu, 2016 Dec 15,
|
||||
|
||||
Error in test_startup_utf8 on Solaris. (Danek Duvall, 2016 Aug 17)
|
||||
|
||||
Completion for :!cmd shows each match twice. #1435
|
||||
|
||||
GTK: When adding a timer from 'balloonexpr' it won't fire, because
|
||||
g_main_context_iteration() doesn't return. Need to trigger an event when the
|
||||
timer expires.
|
||||
@@ -1422,9 +1447,6 @@ Undo message is not always properly displayed. Patch by Ken Takata, 2013 oct
|
||||
3. Doesn't work properly according to Yukihiro Nakadaira.
|
||||
Also see #1635.
|
||||
|
||||
When 'keywordprg' starts with ":" the argument is still escaped as a shell
|
||||
command argument. (Romain Lafourcade, 2016 Oct 16, #1175)
|
||||
|
||||
Idea from Sven: record sequence of keys. Useful to show others what they are
|
||||
doing (look over the shoulder), and also to see what happened.
|
||||
Probably list of keystrokes, with some annotations for mode changes.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*usr_03.txt* For Vim version 8.2. Last change: 2020 Feb 29
|
||||
*usr_03.txt* For Vim version 8.2. Last change: 2020 Sep 03
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -30,10 +30,11 @@ Table of contents: |usr_toc.txt|
|
||||
|
||||
To move the cursor forward one word, use the "w" command. Like most Vim
|
||||
commands, you can use a numeric prefix to move past multiple words. For
|
||||
example, "3w" moves three words. This figure shows how it works:
|
||||
example, "3w" moves three words. This figure shows how it works (starting at
|
||||
the position marked with "x"):
|
||||
|
||||
This is a line with example text ~
|
||||
--->-->->----------------->
|
||||
x-->-->->----------------->
|
||||
w w w 3w
|
||||
|
||||
Notice that "w" moves to the start of the next word if it already is at the
|
||||
@@ -41,15 +42,15 @@ start of a word.
|
||||
The "b" command moves backward to the start of the previous word:
|
||||
|
||||
This is a line with example text ~
|
||||
<----<--<-<---------<---
|
||||
<----<--<-<---------<--x
|
||||
b b b 2b b
|
||||
|
||||
There is also the "e" command that moves to the next end of a word and "ge",
|
||||
which moves to the previous end of a word:
|
||||
|
||||
This is a line with example text ~
|
||||
<- <--- -----> ---->
|
||||
ge ge e e
|
||||
<----<----x---->------------>
|
||||
2ge ge e we
|
||||
|
||||
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
|
||||
@@ -82,12 +83,12 @@ an <End> key it will do the same thing.
|
||||
|
||||
The "^" command moves to the first non-blank character of the line. The "0"
|
||||
command (zero) moves to the very first character of the line, and the <Home>
|
||||
key does the same thing. In a picture:
|
||||
key does the same thing. In a picture ("." indicates a space):
|
||||
|
||||
^
|
||||
<------------
|
||||
<-----------x
|
||||
.....This is a line with example text ~
|
||||
<----------------- --------------->
|
||||
<----------------x x-------------->
|
||||
0 $
|
||||
|
||||
(the "....." indicates blanks here)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*usr_40.txt* For Vim version 8.2. Last change: 2020 Jul 28
|
||||
*usr_40.txt* For Vim version 8.2. Last change: 2020 Sep 02
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -453,15 +453,15 @@ matching BufWritePre autocommands and executes them, and then it
|
||||
performs the ":write".
|
||||
The general form of the :autocmd command is as follows: >
|
||||
|
||||
:autocmd [group] {events} {file-pattern} [nested] {command}
|
||||
:autocmd [group] {events} {file-pattern} [++nested] {command}
|
||||
|
||||
The [group] name is optional. It is used in managing and calling the commands
|
||||
(more on this later). The {events} parameter is a list of events (comma
|
||||
separated) that trigger the command.
|
||||
{file-pattern} is a filename, usually with wildcards. For example, using
|
||||
"*.txt" makes the autocommand be used for all files whose name end in ".txt".
|
||||
The optional [nested] flag allows for nesting of autocommands (see below), and
|
||||
finally, {command} is the command to be executed.
|
||||
The optional [++nested] flag allows for nesting of autocommands (see below),
|
||||
and finally, {command} is the command to be executed.
|
||||
|
||||
|
||||
EVENTS
|
||||
@@ -578,7 +578,7 @@ trigger any new events. If you read a file in response to a FileChangedShell
|
||||
event, it will not trigger the autocommands that would set the syntax, for
|
||||
example. To make the events triggered, add the "nested" argument: >
|
||||
|
||||
:autocmd FileChangedShell * nested edit
|
||||
:autocmd FileChangedShell * ++nested edit
|
||||
|
||||
|
||||
EXECUTING AUTOCOMMANDS
|
||||
|
@@ -327,9 +327,9 @@ Grouping is done with parentheses. No surprises here. Example: >
|
||||
:echo (10 + 5) * 2
|
||||
< 30 ~
|
||||
|
||||
Strings can be concatenated with ".". Example: >
|
||||
Strings can be concatenated with ".." (see |expr6|). Example: >
|
||||
|
||||
:echo "foo" . "bar"
|
||||
:echo "foo" .. "bar"
|
||||
< foobar ~
|
||||
|
||||
When the ":echo" command gets multiple arguments, it separates them with a
|
||||
@@ -496,9 +496,9 @@ So far the commands in the script were executed by Vim directly. The
|
||||
very powerful way to build commands and execute them.
|
||||
An example is to jump to a tag, which is contained in a variable: >
|
||||
|
||||
:execute "tag " . tag_name
|
||||
:execute "tag " .. tag_name
|
||||
|
||||
The "." is used to concatenate the string "tag " with the value of variable
|
||||
The ".." is used to concatenate the string "tag " with the value of variable
|
||||
"tag_name". Suppose "tag_name" has the value "get_cmd", then the command that
|
||||
will be executed is: >
|
||||
|
||||
@@ -514,7 +514,7 @@ This jumps to the first line and formats all lines with the "=" operator.
|
||||
To make ":normal" work with an expression, combine ":execute" with it.
|
||||
Example: >
|
||||
|
||||
:execute "normal " . normal_commands
|
||||
:execute "normal " .. normal_commands
|
||||
|
||||
The variable "normal_commands" must contain the Normal mode commands.
|
||||
Make sure that the argument for ":normal" is a complete command. Otherwise
|
||||
@@ -531,12 +531,12 @@ If you don't want to execute a string but evaluate it to get its expression
|
||||
value, you can use the eval() function: >
|
||||
|
||||
:let optname = "path"
|
||||
:let optval = eval('&' . optname)
|
||||
:let optval = eval('&' .. optname)
|
||||
|
||||
A "&" character is prepended to "path", thus the argument to eval() is
|
||||
"&path". The result will then be the value of the 'path' option.
|
||||
The same thing can be done with: >
|
||||
:exe 'let optval = &' . optname
|
||||
:exe 'let optval = &' .. optname
|
||||
|
||||
==============================================================================
|
||||
*41.6* Using functions
|
||||
@@ -1288,7 +1288,7 @@ Example: >
|
||||
: let n = n + len(split(getline(lnum)))
|
||||
: let lnum = lnum + 1
|
||||
: endwhile
|
||||
: echo "found " . n . " words"
|
||||
: echo "found " .. n .. " words"
|
||||
:endfunction
|
||||
|
||||
You can call this function with: >
|
||||
@@ -1301,7 +1301,7 @@ It will be executed once and echo the number of words.
|
||||
range, with the cursor in that line. Example: >
|
||||
|
||||
:function Number()
|
||||
: echo "line " . line(".") . " contains: " . getline(".")
|
||||
: echo "line " .. line(".") .. " contains: " .. getline(".")
|
||||
:endfunction
|
||||
|
||||
If you call this function with: >
|
||||
@@ -1325,11 +1325,11 @@ so on. The variable "a:0" contains the number of extra arguments.
|
||||
|
||||
:function Show(start, ...)
|
||||
: echohl Title
|
||||
: echo "start is " . a:start
|
||||
: echo "start is " .. a:start
|
||||
: echohl None
|
||||
: let index = 1
|
||||
: while index <= a:0
|
||||
: echo " Arg " . index . " is " . a:{index}
|
||||
: echo " Arg " .. index .. " is " .. a:{index}
|
||||
: let index = index + 1
|
||||
: endwhile
|
||||
: echo ""
|
||||
@@ -1737,10 +1737,10 @@ Another useful mechanism is the ":finally" command: >
|
||||
|
||||
:let tmp = tempname()
|
||||
:try
|
||||
: exe ".,$write " . tmp
|
||||
: exe "!filter " . tmp
|
||||
: exe ".,$write " .. tmp
|
||||
: exe "!filter " .. tmp
|
||||
: .,$delete
|
||||
: exe "$read " . tmp
|
||||
: exe "$read " .. tmp
|
||||
:finally
|
||||
: call delete(tmp)
|
||||
:endtry
|
||||
@@ -2091,8 +2091,8 @@ prepending it with "s:".
|
||||
We will define a function that adds a new typing correction: >
|
||||
|
||||
30 function s:Add(from, correct)
|
||||
31 let to = input("type the correction for " . a:from . ": ")
|
||||
32 exe ":iabbrev " . a:from . " " . to
|
||||
31 let to = input("type the correction for " .. a:from .. ": ")
|
||||
32 exe ":iabbrev " .. a:from .. " " .. to
|
||||
..
|
||||
36 endfunction
|
||||
|
||||
@@ -2197,7 +2197,7 @@ a few lines to count the number of corrections: >
|
||||
30 function s:Add(from, correct)
|
||||
..
|
||||
34 let s:count = s:count + 1
|
||||
35 echo s:count . " corrections now"
|
||||
35 echo s:count .. " corrections now"
|
||||
36 endfunction
|
||||
|
||||
First s:count is initialized to 4 in the script itself. When later the
|
||||
@@ -2240,11 +2240,11 @@ Here is the resulting complete example: >
|
||||
28 noremap <SID>Add :call <SID>Add(expand("<cword>"), 1)<CR>
|
||||
29
|
||||
30 function s:Add(from, correct)
|
||||
31 let to = input("type the correction for " . a:from . ": ")
|
||||
32 exe ":iabbrev " . a:from . " " . to
|
||||
31 let to = input("type the correction for " .. a:from .. ": ")
|
||||
32 exe ":iabbrev " .. a:from .. " " .. to
|
||||
33 if a:correct | exe "normal viws\<C-R>\" \b\e" | endif
|
||||
34 let s:count = s:count + 1
|
||||
35 echo s:count . " corrections now"
|
||||
35 echo s:count .. " corrections now"
|
||||
36 endfunction
|
||||
37
|
||||
38 if !exists(":Correct")
|
||||
@@ -2492,7 +2492,7 @@ should be undone. Set the b:undo_ftplugin variable to the commands that will
|
||||
undo the settings in your filetype plugin. Example: >
|
||||
|
||||
let b:undo_ftplugin = "setlocal fo< com< tw< commentstring<"
|
||||
\ . "| unlet b:match_ignorecase b:match_words b:match_skip"
|
||||
\ .. "| unlet b:match_ignorecase b:match_words b:match_skip"
|
||||
|
||||
Using ":setlocal" with "<" after the option name resets the option to its
|
||||
global value. That is mostly the best way to reset the option value.
|
||||
@@ -2613,17 +2613,17 @@ The following example shows how it's done: >
|
||||
map <F19> :call BufNetWrite('something')<CR>
|
||||
|
||||
let s:did_load = 1
|
||||
exe 'au FuncUndefined BufNet* source ' . expand('<sfile>')
|
||||
exe 'au FuncUndefined BufNet* source ' .. expand('<sfile>')
|
||||
finish
|
||||
endif
|
||||
|
||||
function BufNetRead(...)
|
||||
echo 'BufNetRead(' . string(a:000) . ')'
|
||||
echo 'BufNetRead(' .. string(a:000) .. ')'
|
||||
" read functionality here
|
||||
endfunction
|
||||
|
||||
function BufNetWrite(...)
|
||||
echo 'BufNetWrite(' . string(a:000) . ')'
|
||||
echo 'BufNetWrite(' .. string(a:000) .. ')'
|
||||
" write functionality here
|
||||
endfunction
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*version5.txt* For Vim version 8.2. Last change: 2020 Aug 15
|
||||
*version5.txt* For Vim version 8.2. Last change: 2020 Sep 02
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -4417,7 +4417,7 @@ Now map <xF4> to <F4>, so that the user can override this.
|
||||
When compiling os_win32.c with MIN_FEAT the apply_autocmds() should not be
|
||||
used. (Aaron)
|
||||
|
||||
This autocommand looped forever: ":au FileChangedShell * nested e <afile>"
|
||||
This autocommand looped forever: ":au FileChangedShell * ++nested e <afile>"
|
||||
Now FileChangeShell never nests. (Roemer)
|
||||
|
||||
When evaluating an ":elseif" that was not going to matter anyway, ignore
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*vim9.txt* For Vim version 8.2. Last change: 2020 Aug 27
|
||||
*vim9.txt* For Vim version 8.2. Last change: 2020 Sep 07
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -114,7 +114,7 @@ There is no "a:" dictionary or "a:000" list.
|
||||
|
||||
Variable arguments are defined as the last argument, with a name and have a
|
||||
list type, similar to TypeScript. For example, a list of numbers: >
|
||||
def MyFunc(...itemlist: list<number>)
|
||||
def MyFunc(...itemlist: list<number>)
|
||||
for item in itemlist
|
||||
...
|
||||
|
||||
@@ -128,8 +128,8 @@ function or variable the "g:" prefix should be used. For functions in an
|
||||
autoload script the "name#" prefix is sufficient. >
|
||||
def ThisFunction() # script-local
|
||||
def s:ThisFunction() # script-local
|
||||
def g:ThatFunction() # global
|
||||
def ThatFunction() # global if no local ThatFunction()
|
||||
def g:ThatFunction() # global
|
||||
def ThatFunction() # global if no local ThatFunction()
|
||||
def scriptname#function() # autoload
|
||||
|
||||
When using `:function` or `:def` to specify a new function inside a function,
|
||||
@@ -173,7 +173,7 @@ blocks. Once the block ends the variable is no longer accessible: >
|
||||
else
|
||||
let inner = 0
|
||||
endif
|
||||
echo inner " Error!
|
||||
echo inner # Error!
|
||||
|
||||
The declaration must be done earlier: >
|
||||
let inner: number
|
||||
@@ -190,7 +190,7 @@ To intentionally avoid a variable being available later, a block can be used:
|
||||
let temp = 'temp'
|
||||
...
|
||||
}
|
||||
echo temp " Error!
|
||||
echo temp # Error!
|
||||
|
||||
An existing variable cannot be assigned to with `:let`, since that implies a
|
||||
declaration. Global, window, tab, buffer and Vim variables can only be used
|
||||
@@ -222,7 +222,7 @@ isn't that easy.
|
||||
Omitting :call and :eval ~
|
||||
|
||||
Functions can be called without `:call`: >
|
||||
writefile(lines, 'file')
|
||||
writefile(lines, 'file')
|
||||
Using `:call` is still possible, but this is discouraged.
|
||||
|
||||
A method call without `eval` is possible, so long as the start is an
|
||||
@@ -329,26 +329,26 @@ Notes:
|
||||
current function.
|
||||
- No line break is allowed in the LHS of an assignment. Specifically when
|
||||
unpacking a list |:let-unpack|. This is OK: >
|
||||
[var1, var2] =
|
||||
[var1, var2] =
|
||||
Func()
|
||||
< This does not work: >
|
||||
[var1,
|
||||
[var1,
|
||||
var2] =
|
||||
Func()
|
||||
- No line break is allowed in between arguments of an `:echo`, `:execute` and
|
||||
similar commands. This is OK: >
|
||||
echo [1,
|
||||
echo [1,
|
||||
2] [3,
|
||||
4]
|
||||
< This does not work: >
|
||||
echo [1, 2]
|
||||
echo [1, 2]
|
||||
[3, 4]
|
||||
- No line break is allowed in the arguments of a lambda, between the "{" and
|
||||
"->". This is OK: >
|
||||
filter(list, {k, v ->
|
||||
filter(list, {k, v ->
|
||||
v > 0})
|
||||
< This does not work: >
|
||||
filter(list, {k,
|
||||
filter(list, {k,
|
||||
v -> v > 0})
|
||||
|
||||
|
||||
@@ -372,11 +372,11 @@ The 'ignorecase' option is not used for comparators that use strings.
|
||||
White space ~
|
||||
|
||||
Vim9 script enforces proper use of white space. This is no longer allowed: >
|
||||
let var=234 " Error!
|
||||
let var= 234 " Error!
|
||||
let var =234 " Error!
|
||||
let var=234 # Error!
|
||||
let var= 234 # Error!
|
||||
let var =234 # Error!
|
||||
There must be white space before and after the "=": >
|
||||
let var = 234 " OK
|
||||
let var = 234 # OK
|
||||
White space must also be put before the # that starts a comment after a
|
||||
command: >
|
||||
let var = 234# Error!
|
||||
@@ -386,14 +386,14 @@ White space is required around most operators.
|
||||
|
||||
White space is not allowed:
|
||||
- Between a function name and the "(": >
|
||||
call Func (arg) " Error!
|
||||
call Func
|
||||
\ (arg) " Error!
|
||||
call Func(arg) " OK
|
||||
call Func(
|
||||
\ arg) " OK
|
||||
call Func(
|
||||
\ arg " OK
|
||||
call Func (arg) # Error!
|
||||
call Func
|
||||
\ (arg) # Error!
|
||||
call Func(arg) # OK
|
||||
call Func(
|
||||
\ arg) # OK
|
||||
call Func(
|
||||
\ arg # OK
|
||||
\ )
|
||||
|
||||
|
||||
@@ -438,7 +438,7 @@ converted to string. >
|
||||
|
||||
Simple types are string, float, special and bool. For other types |string()|
|
||||
can be used.
|
||||
|
||||
*false* *true*
|
||||
In Vim9 script one can use "true" for v:true and "false" for v:false.
|
||||
|
||||
Indexing a string with [idx] or [idx, idx] uses character indexes instead of
|
||||
@@ -455,16 +455,16 @@ same time tries to support the legacy Vim commands. Some compromises had to
|
||||
be made. Here is a summary of what might be unexpected.
|
||||
|
||||
Ex command ranges need to be prefixed with a colon. >
|
||||
-> " legacy Vim: shifts the previous line to the right
|
||||
->func() " Vim9: method call in continuation line
|
||||
:-> " Vim9: shifts the previous line to the right
|
||||
-> # legacy Vim: shifts the previous line to the right
|
||||
->func() # Vim9: method call in continuation line
|
||||
:-> # Vim9: shifts the previous line to the right
|
||||
|
||||
%s/a/b " legacy Vim: substitute on all lines
|
||||
%s/a/b # legacy Vim: substitute on all lines
|
||||
x = alongname
|
||||
% another " Vim9: line continuation without a backslash
|
||||
:%s/a/b " Vim9: substitute on all lines
|
||||
'text'->func() " Vim9: method call
|
||||
:'t " legacy Vim: jump to mark m
|
||||
% another # Vim9: line continuation without a backslash
|
||||
:%s/a/b # Vim9: substitute on all lines
|
||||
'text'->func() # Vim9: method call
|
||||
:'t # legacy Vim: jump to mark m
|
||||
|
||||
Some Ex commands can be confused with assignments in Vim9 script: >
|
||||
g:name = value # assignment
|
||||
@@ -484,7 +484,7 @@ Vim9 functions are compiled as a whole: >
|
||||
if !has('feature')
|
||||
return
|
||||
endif
|
||||
use-feature " May give compilation error
|
||||
use-feature # May give compilation error
|
||||
enddef
|
||||
For a workaround, split it in two functions: >
|
||||
func Maybe()
|
||||
@@ -497,7 +497,7 @@ For a workaround, split it in two functions: >
|
||||
use-feature
|
||||
enddef
|
||||
endif
|
||||
Of put the unsupported code inside an `if` with a constant expression that
|
||||
Or put the unsupported code inside an `if` with a constant expression that
|
||||
evaluates to false: >
|
||||
def Maybe()
|
||||
if has('feature')
|
||||
@@ -699,8 +699,8 @@ Type inference *type-inference*
|
||||
|
||||
In general: Whenever the type is clear it can be omitted. For example, when
|
||||
declaring a variable and giving it a value: >
|
||||
let var = 0 " infers number type
|
||||
let var = 'hello' " infers string type
|
||||
let var = 0 # infers number type
|
||||
let var = 'hello' # infers string type
|
||||
|
||||
The type of a list and dictionary comes from the common type of the values.
|
||||
If the values all have the same type, that type is used for the list or
|
||||
@@ -719,8 +719,8 @@ string doesn't start with a number. Quite often this leads to hard-to-find
|
||||
bugs.
|
||||
|
||||
In Vim9 script this has been made stricter. In most places it works just as
|
||||
before, if the expected type was already. There will sometimes be an error,
|
||||
thus breaking backwards compatibility. For example:
|
||||
before, if the value used matches the expected type. There will sometimes be
|
||||
an error, thus breaking backwards compatibility. For example:
|
||||
- Using a number other than 0 or 1 where a boolean is expected. *E1023*
|
||||
- Using a string value when setting a number options.
|
||||
- Using a number where a string is expected. *E1024*
|
||||
@@ -801,6 +801,9 @@ Then you can use "That.EXPORTED_CONST", "That.someValue", etc. You are free
|
||||
to choose the name "That", but it is highly recommended to use the name of the
|
||||
script file to avoid confusion.
|
||||
|
||||
`:import` can also be used in legacy Vim script. The imported items still
|
||||
become script-local, even when the "s:" prefix is not given.
|
||||
|
||||
The script name after `import` can be:
|
||||
- A relative path, starting "." or "..". This finds a file relative to the
|
||||
location of the script file itself. This is useful to split up a large
|
||||
@@ -846,7 +849,7 @@ actually needed. A recommended mechanism:
|
||||
items and any private items. >
|
||||
vim9script
|
||||
let localVar = 'local'
|
||||
export def FilterFunc(arg: string): string
|
||||
export def FilterFunc(arg: string): string
|
||||
...
|
||||
< This goes in .../import/someother.vim.
|
||||
|
||||
@@ -934,8 +937,8 @@ the well-known parts of legacy Vim script.
|
||||
|
||||
Since Vim already uses `:let` and `:const` and optional type checking is
|
||||
desirable, the JavaScript/TypeScript syntax fits best for variable
|
||||
declarations. >
|
||||
const greeting = 'hello' " string type is inferred
|
||||
declarations: >
|
||||
const greeting = 'hello' # string type is inferred
|
||||
let name: string
|
||||
...
|
||||
name = 'John'
|
||||
@@ -945,32 +948,40 @@ are doing. Some details are unexpected and can be fixed. For example how the
|
||||
|| and && operators work. Legacy Vim script: >
|
||||
let result = 44
|
||||
...
|
||||
return result || 0 " returns 1
|
||||
return result || 0 # returns 1
|
||||
|
||||
Vim9 script works like JavaScript/TypeScript, keep the value: >
|
||||
let result = 44
|
||||
...
|
||||
return result || 0 " returns 44
|
||||
return result || 0 # returns 44
|
||||
|
||||
On the other hand, overloading "+" to use both for addition and string
|
||||
concatenation goes against legacy Vim script and often leads to mistakes.
|
||||
For that reason we will keep using ".." for string concatenation. Lua also
|
||||
uses ".." this way.
|
||||
|
||||
There is no intention to completely match TypeScript syntax and semantics. We
|
||||
just want to take those parts that we can use for Vim and we expect Vim users
|
||||
are happy with. TypeScript is a complex language with its own advantages and
|
||||
disadvantages. People used to other languages (Java, Python, etc.) will also
|
||||
find things in TypeScript that they do not like or do not understand. We'll
|
||||
try to avoid those things.
|
||||
|
||||
|
||||
Import and Export ~
|
||||
|
||||
A problem of legacy Vim script is that by default all functions and variables
|
||||
are global. It is possible to make them script-local, but then they are not
|
||||
available in other scripts.
|
||||
available in other scripts. This defies the concept of a package that only
|
||||
exports selected items and keeps the rest local.
|
||||
|
||||
In Vim9 script a mechanism very similar to the JavaScript import and export
|
||||
mechanism is supported. It is a variant to the existing `:source` command
|
||||
that works like one would expect:
|
||||
- Instead of making everything global by default, everything is script-local,
|
||||
unless exported.
|
||||
- When importing a script the symbols that are imported are listed, avoiding
|
||||
name conflicts and failures if later functionality is added.
|
||||
- When importing a script the symbols that are imported are explicitly listed,
|
||||
avoiding name conflicts and failures if functionality is added later.
|
||||
- The mechanism allows for writing a big, long script with a very clear API:
|
||||
the exported function(s) and class(es).
|
||||
- By using relative paths loading can be much faster for an import inside of a
|
||||
@@ -982,27 +993,28 @@ that works like one would expect:
|
||||
When sourcing a Vim9 script from a legacy script, only the items defined
|
||||
globally can be used, not the exported items. Alternatives considered:
|
||||
- All the exported items become available as script-local items. This makes
|
||||
it uncontrollable what items get defined.
|
||||
it uncontrollable what items get defined and likely soon leads to trouble.
|
||||
- Use the exported items and make them global. Disadvantage is that it's then
|
||||
not possible to avoid name clashes in the global namespace.
|
||||
- Completely disallow sourcing a Vim9 script, require using `:import`. That
|
||||
makes it difficult to use scripts for testing, or sourcing them from the
|
||||
command line to try them out.
|
||||
Note that you can also use `:import` in legacy Vim script, see above.
|
||||
|
||||
|
||||
Classes ~
|
||||
|
||||
Vim supports interfaces to Perl, Python, Lua, Tcl and a few others. But
|
||||
these have never become widespread. When Vim 9 was designed a decision was
|
||||
made to phase out these interfaces and concentrate on Vim script, while
|
||||
encouraging plugin authors to write code in any language and run it as an
|
||||
external tool, using jobs and channels.
|
||||
these interfaces have never become widespread. When Vim 9 was designed a
|
||||
decision was made to phase out these interfaces and concentrate on Vim script,
|
||||
while encouraging plugin authors to write code in any language and run it as
|
||||
an external tool, using jobs and channels.
|
||||
|
||||
Still, using an external tool has disadvantages. An alternative is to convert
|
||||
the tool into Vim script. For that to be possible without too much
|
||||
translation, and keeping the code fast at the same time, the constructs of the
|
||||
tool need to be supported. Since most languages support classes the lack of
|
||||
class support in Vim is then a problem.
|
||||
support for classes in Vim is then a problem.
|
||||
|
||||
Previously Vim supported a kind-of object oriented programming by adding
|
||||
methods to a dictionary. With some care this could be made to work, but it
|
||||
@@ -1010,7 +1022,7 @@ does not look like real classes. On top of that, it's very slow, because of
|
||||
the use of dictionaries.
|
||||
|
||||
The support of classes in Vim9 script is a "minimal common functionality" of
|
||||
class support in most languages. It works mostly like Java, which is the most
|
||||
class support in most languages. It works much like Java, which is the most
|
||||
popular programming language.
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
*windows.txt* For Vim version 8.2. Last change: 2020 Aug 15
|
||||
*windows.txt* For Vim version 8.2. Last change: 2020 Sep 02
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -955,12 +955,12 @@ CTRL-W g } *CTRL-W_g}*
|
||||
cursor. This is less clever than using |:ptag|, but you don't
|
||||
need a tags file and it will also find matches in system
|
||||
include files. Example: >
|
||||
:au! CursorHold *.[ch] nested exe "silent! psearch " . expand("<cword>")
|
||||
:au! CursorHold *.[ch] ++nested exe "silent! psearch " . expand("<cword>")
|
||||
< Warning: This can be slow.
|
||||
|
||||
Example *CursorHold-example* >
|
||||
|
||||
:au! CursorHold *.[ch] nested exe "silent! ptag " . expand("<cword>")
|
||||
:au! CursorHold *.[ch] ++nested exe "silent! ptag " . expand("<cword>")
|
||||
|
||||
This will cause a ":ptag" to be executed for the keyword under the cursor,
|
||||
when the cursor hasn't moved for the time set with 'updatetime'. The "nested"
|
||||
@@ -973,7 +973,7 @@ be found. Also see |CursorHold|. To disable this again: >
|
||||
A nice addition is to highlight the found tag, avoid the ":ptag" when there
|
||||
is no word under the cursor, and a few other things: >
|
||||
|
||||
:au! CursorHold *.[ch] nested call PreviewWord()
|
||||
:au! CursorHold *.[ch] ++nested call PreviewWord()
|
||||
:func PreviewWord()
|
||||
: if &previewwindow " don't do this in the preview window
|
||||
: return
|
||||
|
Reference in New Issue
Block a user