Commit: patch 9.2.0976: Vim9: line continuation for command arguments is undocumented
Christian Brabandt <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0976: Vim9: line continuation for command arguments is undocumented Commit: https://github.com/vim/vim/commit/a20071113aa9bec2d47924e6af0269b6e1929ac5 Author: Amariah Kamau <[email protected]> Date: Tue Aug 18 21:02:17 2026 +0000 patch 9.2.0976: Vim9: line continuation for command arguments is undocumented Problem: Line continuation for command arguments such as :command and :autocmd is not documented (Ryosuke Akiyama). Solution: Document and test the required backslash form (Amariah Kamau). fixes: #21070 closes: #21073 Co-Authored-By: atlarix-agent <[email protected]> Signed-off-by: Amariah Kamau <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 082b9ba85..505482684 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -914,8 +914,16 @@ Notes: echo [1, 2] [3, 4] - In some cases it is difficult for Vim to parse a command, especially when - commands are used as an argument to another command, such as `:windo`. In - those cases the line continuation with a backslash has to be used. + commands are used as an argument to another command, such as `:windo`, + `:command` or `:autocmd`. In those cases the line continuation with a + backslash has to be used. For example: > + command! Foo call Bar('x', { + \ 'key': 'value', + \ }) + autocmd BufWritePre * call Bar('x', { + \ 'key': 'value', + \ }) +< White space ~ diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index b76cec4f3..1f33bd2b4 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -4070,6 +4070,24 @@ func Test_autocmd_with_block() augroup END endfunc +" Test for a backslash line continuation in an :autocmd command +func Test_autocmd_line_continuation() + let lines =<< trim END + vim9script + def Bar(label: string, value: any): void + g:result = [label, value] + enddef + autocmd BufWritePre * call Bar('x', { + \ 'key': 'value', + \ }) + doautocmd BufWritePre + assert_equal(['x', {'key': 'value'}], g:result) + END + call v9.CheckScriptSuccess(lines) + unlet g:result + au! BufWritePre +endfunc + " Test for a {} block at script level in an :autocmd nested in another one func Test_autocmd_nested_block() let lines =<< trim END diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim index 7f8fea421..a615f35c0 100644 --- a/src/testdir/test_usercommands.vim +++ b/src/testdir/test_usercommands.vim @@ -927,6 +927,24 @@ func Test_usercmd_custom() delfunc T2 endfunc +" Test for a backslash line continuation in a :command replacement +func Test_usercmd_line_continuation() + let lines =<< trim END + vim9script + def Bar(label: string, value: any): void + g:result = [label, value] + enddef + command! Foo call Bar('x', { + \ 'key': 'value', + \ }) + Foo + assert_equal(['x', {'key': 'value'}], g:result) + END + call v9.CheckScriptSuccess(lines) + unlet g:result + delcommand Foo +endfunc + " Test for a {} block in a command nested in :command or :autocmd func Test_usercmd_nested_block() command DefineIt command DoNested { diff --git a/src/version.c b/src/version.c index fcb088bdb..7b88e90e5 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 976, /**/ 975, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wwR9E-00AlOD-AL%40256bit.org.