diff options
-rw-r--r-- | runtime/doc/eval.txt | 52 | ||||
-rw-r--r-- | runtime/doc/filetype.txt | 1 | ||||
-rw-r--r-- | runtime/doc/index.txt | 2 | ||||
-rw-r--r-- | runtime/doc/options.txt | 4 | ||||
-rw-r--r-- | runtime/doc/popup.txt | 2 | ||||
-rw-r--r-- | runtime/doc/syntax.txt | 9 | ||||
-rw-r--r-- | runtime/doc/tags | 15 | ||||
-rw-r--r-- | runtime/doc/term.txt | 6 | ||||
-rw-r--r-- | runtime/doc/todo.txt | 28 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 2 | ||||
-rw-r--r-- | runtime/doc/various.txt | 7 | ||||
-rw-r--r-- | runtime/doc/version6.txt | 2 | ||||
-rw-r--r-- | runtime/doc/vi_diff.txt | 2 | ||||
-rw-r--r-- | runtime/doc/vim9.txt | 100 | ||||
-rw-r--r-- | runtime/ftplugin/vim.vim | 10 | ||||
-rw-r--r-- | runtime/syntax/c.vim | 19 | ||||
-rw-r--r-- | runtime/syntax/cpp.vim | 5 |
17 files changed, 150 insertions, 116 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4bab6ef6f8..217e69dc08 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.2. Last change: 2021 Jan 13 +*eval.txt* For Vim version 8.2. Last change: 2021 Jan 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4084,8 +4084,9 @@ delete({fname} [, {flags}]) *delete()* A symbolic link itself is deleted, not what it points to. - The result is a Number, which is 0 if the delete operation was - successful and -1 when the deletion failed or partly failed. + The result is a Number, which is 0/false if the delete + operation was successful and -1/true when the deletion failed + or partly failed. Use |remove()| to delete an item from a |List|. To delete a line from the buffer use |:delete| or @@ -6222,8 +6223,8 @@ has({feature} [, {check}]) has_key({dict}, {key}) *has_key()* - The result is a Number, which is 1 if |Dictionary| {dict} has - an entry with key {key}. Zero otherwise. + The result is a Number, which is TRUE if |Dictionary| {dict} + has an entry with key {key}. FALSE otherwise. Can also be used as a |method|: > mydict->has_key(key) @@ -6266,16 +6267,16 @@ haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()* GetWinnr()->haslocaldir() hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* - The result is a Number, which is 1 if there is a mapping that - contains {what} in somewhere in the rhs (what it is mapped to) - and this mapping exists in one of the modes indicated by - {mode}. + The result is a Number, which is TRUE if there is a mapping + that contains {what} in somewhere in the rhs (what it is + mapped to) and this mapping exists in one of the modes + indicated by {mode}. When {abbr} is there and it is |TRUE| use abbreviations instead of mappings. Don't forget to specify Insert and/or Command-line mode. Both the global mappings and the mappings local to the current buffer are checked for a match. - If no matching mapping is found 0 is returned. + If no matching mapping is found FALSE is returned. The following characters are recognized in {mode}: n Normal mode v Visual and Select mode @@ -6311,8 +6312,8 @@ histadd({history}, {item}) *histadd()* character is sufficient. If {item} does already exist in the history, it will be shifted to become the newest entry. - The result is a Number: 1 if the operation was successful, - otherwise 0 is returned. + The result is a Number: TRUE if the operation was successful, + otherwise FALSE is returned. Example: > :call histadd("input", strftime("%Y %b %d")) @@ -6335,8 +6336,8 @@ histdel({history} [, {item}]) *histdel()* an index, see |:history-indexing|. The respective entry will be removed if it exists. - The result is a Number: 1 for a successful operation, - otherwise 0 is returned. + The result is TRUE for a successful operation, otherwise FALSE + is returned. Examples: Clear expression register history: > @@ -6388,7 +6389,7 @@ histnr({history}) *histnr()* GetHistory()->histnr() < hlexists({name}) *hlexists()* - The result is a Number, which is non-zero if a highlight group + The result is a Number, which is TRUE if a highlight group called {name} exists. This is when the group has been defined in some way. Not necessarily when highlighting has been defined for it, it may also have been used for a syntax @@ -6561,7 +6562,7 @@ inputrestore() *inputrestore()* Restore typeahead that was saved with a previous |inputsave()|. Should be called the same number of times inputsave() is called. Calling it more often is harmless though. - Returns 1 when there is nothing to restore, 0 otherwise. + Returns TRUE when there is nothing to restore, FALSE otherwise. inputsave() *inputsave()* Preserve typeahead (also from mappings) and clear it, so that @@ -6569,7 +6570,7 @@ inputsave() *inputsave()* followed by a matching inputrestore() after the prompt. Can be used several times, in which case there must be just as many inputrestore() calls. - Returns 1 when out of memory, 0 otherwise. + Returns TRUE when out of memory, FALSE otherwise. inputsecret({prompt} [, {text}]) *inputsecret()* This function acts much like the |input()| function with but @@ -7045,7 +7046,7 @@ listener_flush([{buf}]) *listener_flush()* listener_remove({id}) *listener_remove()* Remove a listener previously added with listener_add(). - Returns zero when {id} could not be found, one when {id} was + Returns FALSE when {id} could not be found, TRUE when {id} was removed. Can also be used as a |method|: > @@ -7728,8 +7729,8 @@ mkdir({name} [, {path} [, {prot}]]) flag is passed (since patch 8.0.1708). However, without the "p" option the call will fail. - The function result is a Number, which is 1 if the call was - successful or 0 if the directory creation failed or partly + The function result is a Number, which is TRUE if the call was + successful or FALSE if the directory creation failed or partly failed. Not available on all systems. To check use: > @@ -9205,6 +9206,7 @@ server2client({clientid}, {string}) *server2client()* Send a reply string to {clientid}. The most recent {clientid} that sent a string can be retrieved with expand("<client>"). {only available when compiled with the |+clientserver| feature} + Returns zero for success, -1 for failure. Note: This id has to be stored before the next command can be received. I.e. before returning from the received command and @@ -9342,8 +9344,8 @@ setcmdpos({pos}) *setcmdpos()* before inserting the resulting text. When the number is too big the cursor is put at the end of the line. A number smaller than one has undefined results. - Returns 0 when successful, 1 when not editing the command - line. + Returns FALSE when successful, TRUE when not editing the + command line. Can also be used as a |method|: > GetPos()->setcmdpos() @@ -9402,8 +9404,8 @@ setline({lnum}, {text}) *setline()* When {lnum} is just below the last line the {text} will be added below the last line. - If this succeeds, 0 is returned. If this fails (most likely - because {lnum} is invalid) 1 is returned. + If this succeeds, FALSE is returned. If this fails (most likely + because {lnum} is invalid) TRUE is returned. Example: > :call setline(5, strftime("%c")) @@ -11378,7 +11380,7 @@ win_gettype([{nr}]) *win_gettype()* win_gotoid({expr}) *win_gotoid()* Go to window with ID {expr}. This may also change the current tabpage. - Return 1 if successful, 0 if the window cannot be found. + Return TRUE if successful, FALSE if the window cannot be found. Can also be used as a |method|: > GetWinid()->win_gotoid() diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 19720e1841..d3a4bde8b0 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -147,6 +147,7 @@ can be used to overrule the filetype used for certain extensions: *.w g:filetype_w |ft-cweb-syntax| *.i g:filetype_i |ft-progress-syntax| *.p g:filetype_p |ft-pascal-syntax| + *.pp g:filetype_pp |ft-pascal-syntax| *.sh g:bash_is_sh |ft-sh-syntax| *.tex g:tex_flavor |ft-tex-plugin| diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index aec4ca04af..e5d29ad20b 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 8.2. Last change: 2020 Oct 05 +*index.txt* For Vim version 8.2. Last change: 2021 Jan 15 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 2963193a00..8b655dc600 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3273,7 +3273,7 @@ A jump table for the options with a short description can be found at |Q_op|. See the 'endofline' option. *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* -'fkmap' 'fk' boolean (default off) *E198* +'fkmap' 'fk' boolean (default off) global {only available when compiled with the |+rightleft| feature} @@ -5221,7 +5221,7 @@ A jump table for the options with a short description can be found at |Q_op|. NOTE: This option is set to the Vi default value when 'compatible' is set and to the Vim default value when 'compatible' is reset. - *'mouse'* *E538* + *'mouse'* 'mouse' string (default "", "a" for GUI and Win32, set to "a" or "nvi" in |defaults.vim|) global diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt index 54302a95d8..005b57f0d0 100644 --- a/runtime/doc/popup.txt +++ b/runtime/doc/popup.txt @@ -588,8 +588,6 @@ properties. It is in one of four forms: If you want to create a new buffer yourself use |bufadd()| and pass the buffer number to popup_create(). -It is not possible to use the buffer of a terminal window. *E278* You CAN -create a hidden terminal buffer and use that one in a popup window. The second argument of |popup_create()| is a dictionary with options: line Screen line where to position the popup. Can use a diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index c171a20acf..a2a12b0cf0 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -2335,11 +2335,12 @@ http://papp.plan9.de. PASCAL *pascal.vim* *ft-pascal-syntax* -Files matching "*.p" could be Progress or Pascal. If the automatic detection -doesn't work for you, or you don't edit Progress at all, use this in your -startup vimrc: > +Files matching "*.p" could be Progress or Pascal and those matching "*.pp" +could be Puppet or Pascal. If the automatic detection doesn't work for you, +or you only edit Pascal files, use this in your startup vimrc: > - :let filetype_p = "pascal" + :let filetype_p = "pascal" + :let filetype_pp = "pascal" The Pascal syntax file has been extended to take into account some extensions provided by Turbo Pascal, Free Pascal Compiler and GNU Pascal Compiler. diff --git a/runtime/doc/tags b/runtime/doc/tags index 1b36eb2984..24cdded5aa 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -1045,6 +1045,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 't_da' term.txt /*'t_da'* 't_db' term.txt /*'t_db'* 't_dl' term.txt /*'t_dl'* +'t_fd' term.txt /*'t_fd'* +'t_fe' term.txt /*'t_fe'* 't_fs' term.txt /*'t_fs'* 't_k1' term.txt /*'t_k1'* 't_k2' term.txt /*'t_k2'* @@ -3112,9 +3114,11 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* :sip change.txt /*:sip* :sir change.txt /*:sir* :sl various.txt /*:sl* +:sl! various.txt /*:sl!* :sla windows.txt /*:sla* :slast windows.txt /*:slast* :sleep various.txt /*:sleep* +:sleep! various.txt /*:sleep!* :sm change.txt /*:sm* :smagic change.txt /*:smagic* :smap map.txt /*:smap* @@ -4028,7 +4032,6 @@ E194 message.txt /*E194* E195 starting.txt /*E195* E196 various.txt /*E196* E197 mlang.txt /*E197* -E198 options.txt /*E198* E199 cmdline.txt /*E199* E20 motion.txt /*E20* E200 autocmd.txt /*E200* @@ -4114,7 +4117,6 @@ E274 eval.txt /*E274* E275 textprop.txt /*E275* E276 eval.txt /*E276* E277 remote.txt /*E277* -E278 popup.txt /*E278* E279 terminal.txt /*E279* E28 syntax.txt /*E28* E280 if_tcl.txt /*E280* @@ -4180,7 +4182,6 @@ E337 gui.txt /*E337* E338 editing.txt /*E338* E339 message.txt /*E339* E34 various.txt /*E34* -E340 vi_diff.txt /*E340* E341 message.txt /*E341* E342 message.txt /*E342* E343 options.txt /*E343* @@ -4388,7 +4389,6 @@ E534 options.txt /*E534* E535 options.txt /*E535* E536 options.txt /*E536* E537 options.txt /*E537* -E538 options.txt /*E538* E539 options.txt /*E539* E54 pattern.txt /*E54* E540 options.txt /*E540* @@ -6351,6 +6351,7 @@ expression-commands eval.txt /*expression-commands* expression-syntax eval.txt /*expression-syntax* exrc starting.txt /*exrc* extend() eval.txt /*extend()* +extendnew() eval.txt /*extendnew()* extension-removal cmdline.txt /*extension-removal* extensions-improvements todo.txt /*extensions-improvements* f motion.txt /*f* @@ -8680,6 +8681,7 @@ read-in-close-cb channel.txt /*read-in-close-cb* read-messages insert.txt /*read-messages* read-only-share editing.txt /*read-only-share* read-stdin version5.txt /*read-stdin* +readblob() eval.txt /*readblob()* readdir() eval.txt /*readdir()* readdirex() eval.txt /*readdirex()* readfile() eval.txt /*readfile()* @@ -8945,6 +8947,7 @@ sinh() eval.txt /*sinh()* skeleton autocmd.txt /*skeleton* skip_defaults_vim starting.txt /*skip_defaults_vim* slice eval.txt /*slice* +slice() eval.txt /*slice()* slow-fast-terminal term.txt /*slow-fast-terminal* slow-start starting.txt /*slow-start* slow-terminal term.txt /*slow-terminal* @@ -9340,6 +9343,8 @@ t_f6 version4.txt /*t_f6* t_f7 version4.txt /*t_f7* t_f8 version4.txt /*t_f8* t_f9 version4.txt /*t_f9* +t_fd term.txt /*t_fd* +t_fe term.txt /*t_fe* t_float-variable eval.txt /*t_float-variable* t_fs term.txt /*t_fs* t_func-variable eval.txt /*t_func-variable* @@ -9714,6 +9719,7 @@ type-inference vim9.txt /*type-inference* type-mistakes tips.txt /*type-mistakes* typecorr-settings usr_41.txt /*typecorr-settings* typecorr.txt usr_41.txt /*typecorr.txt* +typename() eval.txt /*typename()* u undo.txt /*u* uganda uganda.txt /*uganda* uganda.txt uganda.txt /*uganda.txt* @@ -10314,6 +10320,7 @@ xterm-command-server term.txt /*xterm-command-server* xterm-copy-paste term.txt /*xterm-copy-paste* xterm-cursor-keys term.txt /*xterm-cursor-keys* xterm-end-home-keys term.txt /*xterm-end-home-keys* +xterm-focus-event term.txt /*xterm-focus-event* xterm-function-keys term.txt /*xterm-function-keys* xterm-modifier-keys term.txt /*xterm-modifier-keys* xterm-mouse options.txt /*xterm-mouse* diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 0456a8b89b..8eea4a59e7 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -1,4 +1,4 @@ -*term.txt* For Vim version 8.2. Last change: 2020 Dec 29 +*term.txt* For Vim version 8.2. Last change: 2021 Jan 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -373,9 +373,9 @@ Added by Vim (there are no standard codes for these): t_Ri restore icon text from stack *t_Ri* *'t_Ri'* t_TE end of "raw" mode *t_TE* *'t_TE'* t_TI put terminal into "raw" mode *t_TI* *'t_TI'* - t_fd disable focus-event tracking *t_TI* *'t_TI'* + t_fd disable focus-event tracking *t_fd* *'t_fd'* |xterm-focus-event| - t_fe enable focus-event tracking *t_TI* *'t_TI'* + t_fe enable focus-event tracking *t_fe* *'t_fe'* |xterm-focus-event| Some codes have a start, middle and end part. The start and end are defined diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 6e5fe4cc09..75133f78bc 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.2. Last change: 2021 Jan 11 +*todo.txt* For Vim version 8.2. Last change: 2021 Jan 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -38,15 +38,7 @@ browser use: https://github.com/vim/vim/issues/1234 *known-bugs* -------------------- Known bugs and current work ----------------------- -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) => []) +test_autocmd failure in Windows: Something wrong with system()? Vim9 - Make everything work: - Expand `=expr` in :next, :argedit, :argadd, :argdelete, :drop @@ -117,6 +109,8 @@ Vim9 - Make everything work: - 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. +- Using "windo echo expr" does not accept a line break inside "expr" (in a + :def function and at script level in a not executed block). #7681 Once Vim9 is stable: - Change the help to prefer Vim9 syntax where appropriate @@ -287,6 +281,9 @@ Have another look at the implementation. Patch to implement the vimtutor with a plugin: #6414 Was originally written by Felipe Morales. +Adding "10" to 'spellsuggest' causes spell suggestions to become very slow. +(#4087) + Patch to find Python dll using registry key. (#7540) Remove SPACE_IN_FILENAME ? It is only used for completion. @@ -479,9 +476,6 @@ Help for ":argadd fname" says that if "fname" is already in the argument list that entry is used. But instead it's always added. (#6210) Add flag AL_FIND_ADD, if there is one argument find it in the list. -Adding "10" to 'spellsuggest' causes spell suggestions to become very slow. -(#4087) - behavior of i_CTRl-R_CTRL-R differs from documentation. (Paul Desmond Parker, #5771) @@ -556,14 +550,6 @@ when "qq" is mapped and after the first "q" the mouse is moved outside of the gvim window (with focus follows mouse), then the K_FOCUSLOST key is put in the input buffer. (#5302) -xterm should be able to pass focus changes to Vim, so that Vim can check for -buffers that changed. Perhaps in misc.c, function selectwindow(). -Xterm 224 supports it! -Patch to make FocusGained and FocusLost work in modern terminals. (Hayaki -Saito, 2013 Apr 24) Update 2016 Aug 12. -Also see issue #609. -We could add the enable/disable sequences to t_ti/t_te or t_ks/t_ke. - :buffer completion does not escape "+" properly and results in a regexp error. (#5467) diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 5d4686ae04..965a97732d 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 8.2. Last change: 2021 Jan 08 +*usr_41.txt* For Vim version 8.2. Last change: 2021 Jan 13 VIM USER MANUAL - by Bram Moolenaar diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index c116d69f2c..729cde334c 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 8.2. Last change: 2020 Nov 16 +*various.txt* For Vim version 8.2. Last change: 2021 Jan 16 VIM REFERENCE MANUAL by Bram Moolenaar @@ -411,7 +411,7 @@ N *+mouse_sysmouse* Unix only: *BSD console mouse handling |sysmouse| B *+mouse_sgr* Unix only: sgr mouse handling |sgr-mouse| B *+mouse_urxvt* Unix only: urxvt mouse handling |urxvt-mouse| N *+mouse_xterm* Unix only: xterm mouse handling |xterm-mouse| -N *+multi_byte* 16 and 32 bit characters |multibyte| +T *+multi_byte* Unicode support, 16 and 32 bit characters |multibyte| *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime| N *+multi_lang* non-English language support |multi-lang| m *+mzscheme* Mzscheme interface |mzscheme| @@ -722,6 +722,9 @@ K Run a program to lookup the keyword under the available when compiled with the |+netbeans_intg| feature} + *:sl!* *:sleep!* +:[N]sl[eep]! [N] [m] Same as above, but hide the cursor + *:xrestore* *:xr* :xr[estore] [display] Reinitializes the connection to the X11 server. Useful after the X server restarts, e.g. when running Vim for diff --git a/runtime/doc/version6.txt b/runtime/doc/version6.txt index 82405e7f5f..6b9f1d9343 100644 --- a/runtime/doc/version6.txt +++ b/runtime/doc/version6.txt @@ -9661,7 +9661,7 @@ Solution: Check for tcsetattr() to return an error, retry when it does. Files: src/os_unix.c Patch 6.2f.018 -Problem: Mac OS X 10.2: OK is defined to zero in cursus.h while Vim uses +Problem: Mac OS X 10.2: OK is defined to zero in curses.h while Vim uses one. Redefining it causes a warning message. Solution: Undefine OK before defining it to one. (Taro Muraoka) Files: src/vim.h diff --git a/runtime/doc/vi_diff.txt b/runtime/doc/vi_diff.txt index c7c7f7e38c..0fb29e4946 100644 --- a/runtime/doc/vi_diff.txt +++ b/runtime/doc/vi_diff.txt @@ -73,7 +73,7 @@ edit the termcap entry and try again. Vim has the |terminal-options|. Vim has only a few limits for the files that can be edited {Vi: can not handle <Nul> characters and characters above 128, has limited line length, many other limits}. - *E340* + Maximum line length 2147483647 characters. Longer lines are split. Maximum number of lines 2147483647 lines. Maximum file size 2147483647 bytes (2 Gbyte) when a long integer is diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index a7b91db0a4..93c3ddd2f9 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 10 +*vim9.txt* For Vim version 8.2. Last change: 2021 Jan 15 VIM REFERENCE MANUAL by Bram Moolenaar @@ -487,6 +487,9 @@ Now "exit_cb: Func})" is actually a valid command: save any changes to the file "_cb: Func})" and exit. To avoid this kind of mistake in Vim9 script there must be white space between most command names and the argument. +However, the argument of a command that is a command won't be recognized. For +example, after "windo echo expr" a line break inside "expr" will not be seen. + Notes: - "enddef" cannot be used at the start of a continuation line, it ends the @@ -527,17 +530,17 @@ that using a literal key is much more common than using an expression, and considering that JavaScript uses this syntax, using the {} form for dictionary literals is considered a much more useful syntax. In Vim9 script the {} form uses literal keys: > - let dict = {key: value} + var dict = {key: value} This works for alphanumeric characters, underscore and dash. If you want to use another character, use a single or double quoted string: > - let dict = {'key with space': value} - let dict = {"key\twith\ttabs": value} - let dict = {'': value} # empty key + var dict = {'key with space': value} + var dict = {"key\twith\ttabs": value} + var dict = {'': value} # empty key In case the key needs to be an expression, square brackets can be used, just like in JavaScript: > - let dict = {["key" .. nr]: value} + var dict = {["key" .. nr]: value} No :xit, :t, :append, :change or :insert ~ @@ -552,6 +555,29 @@ Comparators ~ The 'ignorecase' option is not used for comparators that use strings. +For loop ~ + +Legacy Vim script has some tricks to make a for loop over a list handle +deleting items at the current or previous item. In Vim9 script it just uses +the index, if items are deleted then items in the list will be skipped. +Example legacy script: > + let l = [1, 2, 3, 4] + for i in l + echo i + call remove(l, index(l, i)) + endfor +Would echo: + 1 + 2 + 3 + 4 +In compiled Vim9 script you get: + 1 + 3 +Generally, you should not change the list that is iterated over. Make a copy +first if needed. + + White space ~ Vim9 script enforces proper use of white space. This is no longer allowed: > @@ -576,15 +602,17 @@ the start and end: > White space is not allowed: - Between a function name and the "(": > - call Func (arg) # Error! - call Func + Func (arg) # Error! + Func \ (arg) # Error! - call Func(arg) # OK - call Func( - \ arg) # OK - call Func( - \ arg # OK - \ ) + Func + (arg) # Error! + Func(arg) # OK + Func( + arg) # OK + Func( + arg # OK + ) Conditions and expressions ~ @@ -648,12 +676,13 @@ for v:null. When converting a boolean to a string "false" and "true" are used, not "v:false" and "v:true" like in legacy script. "v:none" is not changed, it is only used in JSON and has no equivalent in other languages. -Indexing a string with [idx] or [idx, idx] uses character indexes instead of +Indexing a string with [idx] or [idx : idx] uses character indexes instead of 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. +To exclude the last character use |slice()|. 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 @@ -670,21 +699,22 @@ 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 a 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: modulo operator in a continuation line + :%s/a/b Vim9: substitute on all lines + 't legacy Vim: jump to mark t + 'text'->func() Vim9: method call + :'t Vim9: jump to mark t Some Ex commands can be confused with assignments in Vim9 script: > - g:name = value # assignment - g:pattern:cmd # invalid command - ERROR - :g:pattern:cmd # :global command + g:name = value # assignment + g:pattern:cmd # invalid command - ERROR + :g:pattern:cmd # :global command Functions defined with `:def` compile the whole function. Legacy functions can bail out, and the following lines are not parsed: > @@ -704,7 +734,7 @@ Vim9 functions are compiled as a whole: > For a workaround, split it in two functions: > func Maybe() if has('feature') - call MaybyInner() + call MaybeInner() endif endfunc if has('feature') @@ -720,7 +750,7 @@ evaluates to false: > endif enddef < *vim9-user-command* -Another side effect of compiling a function is that the precense of a user +Another side effect of compiling a function is that the presence 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> @@ -1090,7 +1120,7 @@ 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 searchfor#Stuff(<f-args>) < This goes in .../plugin/anyname.vim. "anyname.vim" can be freely chosen. @@ -1183,12 +1213,12 @@ When compiling lines of Vim commands into instructions as much as possible should be done at compile time. Postponing it to runtime makes the execution slower and means mistakes are found only later. For example, when encountering the "+" character and compiling this into a generic add -instruction, at execution time the instruction would have to inspect the type -of the arguments and decide what kind of addition to do. And when the -type is dictionary throw an error. If the types are known to be numbers then -an "add number" instruction can be used, which is faster. The error can be -given at compile time, no error handling is needed at runtime, since adding -two numbers cannot fail. +instruction, at runtime the instruction would have to inspect the type of the +arguments and decide what kind of addition to do. And when the type is +dictionary throw an error. If the types are known to be numbers then an "add +number" instruction can be used, which is faster. The error can be given at +compile time, no error handling is needed at runtime, since adding two numbers +cannot fail. The syntax for types, using <type> for compound types, is similar to Java. It is easy to understand and widely used. The type names are what were used in diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim index 3307de5410..6adadbda94 100644 --- a/runtime/ftplugin/vim.vim +++ b/runtime/ftplugin/vim.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Vim " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Jan 05 +" Last Change: 2021 Jan 12 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -51,12 +51,12 @@ setlocal keywordprg=:help if "\n" .. getline(1, 10)->join("\n") =~# '\n\s*vim9\%[script]\>' " Set 'comments' to format dashed lists in comments setlocal com=sO:#\ -,mO:#\ \ ,eO:##,:# - " Comments start with a double quote in a legacy script; - " with # in a Vim9 script - setlocal commentstring=\"%s + " Comments starts with # in Vim9 script + setlocal commentstring=#%s else setlocal com=sO:\"\ -,mO:\"\ \ ,:\" - setlocal commentstring=#%s + " Comments starts with a double quote in legacy script + setlocal commentstring=\"%s endif diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index 7925e88aa5..d07aaf2658 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Aug 28 +" Last Change: 2021 Jan 11 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -13,6 +13,9 @@ set cpo&vim let s:ft = matchstr(&ft, '^\([^.]\)\+') +" check if this was included from cpp.vim +let s:in_cpp_family = exists("b:filetype_in_cpp_family") + " Optional embedded Autodoc parsing " To enable it add: let g:c_autodoc = 1 " to your .vimrc @@ -55,7 +58,7 @@ if !exists("c_no_cformat") endif " cCppString: same as cString, but ends at end of line -if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") +if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat") " ISO C++11 syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell @@ -87,7 +90,7 @@ syn match cSpecialCharacter display "L\='\\\o\{1,3}'" syn match cSpecialCharacter display "'\\x\x\{1,2}'" syn match cSpecialCharacter display "L'\\x\x\+'" -if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) +if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) " ISO C11 or ISO C++ 11 if exists("c_no_cformat") syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend @@ -130,7 +133,7 @@ endif " But avoid matching <::. syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom if exists("c_no_curly_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -144,7 +147,7 @@ if exists("c_no_curly_error") syn match cErrInParen display contained "^[{}]\|^<%\|^%>" endif elseif exists("c_no_bracket_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -158,7 +161,7 @@ elseif exists("c_no_bracket_error") syn match cErrInParen display contained "[{}]\|<%\|%>" endif else - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell @@ -278,7 +281,7 @@ syn keyword cStorageClass static register auto volatile extern const if exists("c_gnu") syn keyword cStorageClass inline __attribute__ endif -if !exists("c_no_c99") && s:ft !=# 'cpp' +if !exists("c_no_c99") && !s:in_cpp_family syn keyword cStorageClass inline restrict endif if !exists("c_no_c11") @@ -420,7 +423,7 @@ endif syn cluster cLabelGroup contains=cUserLabel syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup -if s:ft ==# 'cpp' +if s:in_cpp_family sy |