diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index ee38379cfc..318ba96605 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2837,19 +2837,21 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()* (`vim.api.keyset.command_info`) Map of maps describing commands. nvim_cmd({cmd}, {opts}) *nvim_cmd()* - Executes an Ex command. + Executes an Ex command `cmd`, specified as a Dict with the same structure + as returned by |nvim_parse_cmd()|. - Unlike |nvim_command()| this command takes a structured Dict instead of a - String. This allows for easier construction and manipulation of an Ex - command. This also allows for things such as having spaces inside a - command argument, expanding filenames in a command that otherwise doesn't - expand filenames, etc. Command arguments may also be Number, Boolean or - String. - - The first argument may also be used instead of count for commands that - support it in order to make their usage simpler with |vim.cmd()|. For - example, instead of `vim.cmd.bdelete{ count = 2 }`, you may do - `vim.cmd.bdelete(2)`. + Use `magic={…=false}` to disable special chars: >lua + vim.api.nvim_cmd({ + cmd = 'edit', + args = { '%foo"|bar#baz"' }, + magic = { file = false, bar = false } + }, + {} + ) +< + • See |nvim_parse_cmd()| to parse a cmdline string (which can then be + passed to `nvim_cmd`). + • See |nvim_command()| to execute a cmdline string. On execution error: fails with Vimscript error, updates v:errmsg. @@ -2857,11 +2859,10 @@ nvim_cmd({cmd}, {opts}) *nvim_cmd()* Since: 0.8.0 Parameters: ~ - • {cmd} (`vim.api.keyset.cmd`) Command to execute. Must be a Dict that - can contain the same values as the return value of - |nvim_parse_cmd()| except "addr", "nargs" and "nextcmd" which - are ignored if provided. All values except for "cmd" are - optional. + • {cmd} (`vim.api.keyset.cmd`) Command to execute, a Dict with the + same structure as the return value of |nvim_parse_cmd()| + (except "addr", "nargs" and "nextcmd" are ignored). All keys + except "cmd" are optional. • {opts} (`vim.api.keyset.cmd_opts`) Optional parameters. • output: (boolean, default false) Whether to return command output. @@ -2871,8 +2872,9 @@ nvim_cmd({cmd}, {opts}) *nvim_cmd()* true, else empty string. See also: ~ - • |nvim_exec2()| • |nvim_command()| + • |nvim_exec2()| + • |nvim_parse_cmd()| *nvim_create_user_command()* nvim_create_user_command({name}, {command}, {opts}) diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 111cdc5191..d5ce2c2209 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1261,6 +1261,9 @@ vim.cmd({command}) *vim.cmd()* -- Ex command :vertical resize +2 vim.cmd.resize({ '+2', mods = { vertical = true } }) + + -- Pass arg literally, without needing to escape special chars: + vim.cmd.edit({ '%foo"|bar#baz"', magic = { file = false, bar = false } }) < Parameters: ~ diff --git a/runtime/doc/vimfn.txt b/runtime/doc/vimfn.txt index 72efe5abd0..a6e3010b06 100644 --- a/runtime/doc/vimfn.txt +++ b/runtime/doc/vimfn.txt @@ -1551,6 +1551,8 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E69 (`T`) delete({fname} [, {flags}]) *delete()* + Lua: see |vim.fs.rm()|. + Without {flags} or with {flags} empty: Deletes the file by the name {fname}. @@ -2093,7 +2095,7 @@ expand({string} [, {nosuf} [, {list}]]) *expand()* current script ID ||