From 8eff0ca6d50bf2ef0897a08f5fdbc0abed7c1266 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 25 Dec 2021 06:56:33 +0800 Subject: vim-patch:8.2.2468: not easy to get the full command name from a shortened one Problem: Not easy to get the full command name from a shortened one. Solution: Add fullcommand(). (Martin Tournoij, closes vim/vim#7777) https://github.com/vim/vim/commit/038e09ee7645731de0296d255aabb17603276443 --- runtime/doc/eval.txt | 20 ++++++++++++++++++-- runtime/doc/usr_41.txt | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index aef303195d..9a2b9f5069 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2410,10 +2410,11 @@ foldlevel({lnum}) Number fold level at {lnum} foldtext() String line displayed for closed fold foldtextresult({lnum}) String text for closed fold at {lnum} foreground() Number bring the Vim window to the foreground +fullcommand({name}) String get full command from {name} funcref({name} [, {arglist}] [, {dict}]) - Funcref reference to function {name} + Funcref reference to function {name} function({name} [, {arglist}] [, {dict}]) - Funcref named reference to function {name} + Funcref named reference to function {name} garbagecollect([{atexit}]) none free memory, breaking cyclic references get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def} get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def} @@ -4550,6 +4551,21 @@ foreground() Move the Vim window to the foreground. Useful when sent from |remote_foreground()| instead. {only in the Win32 GUI and console version} +fullcommand({name}) *fullcommand()* + Get the full command name from a short abbreviated command + name; see |20.2| for details on command abbreviations. + + {name} may start with a `:` and can include a [range], these + are skipped and not returned. + Returns an empty string if a command doesn't exist or if it's + ambiguous (for user-defined functions). + + For example `fullcommand('s')`, `fullcommand('sub')`, + `fullcommand(':%substitute')` all return "substitute". + + Can also be used as a |method|: > + GetName()->fullcommand() +< *funcref()* funcref({name} [, {arglist}] [, {dict}]) Just like |function()|, but the returned Funcref will lookup diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 6a9284dac9..7e611a47f3 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -852,6 +852,7 @@ Command line: *command-line-functions* getcmdtype() return the current command-line type getcmdwintype() return the current command-line window type getcompletion() list of command-line completion matches + fullcommand() get full command name Quickfix and location lists: *quickfix-functions* getqflist() list of quickfix errors -- cgit