Gary Johnson
unread,Jan 12, 2021, 10:45:10 PM1/12/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
The command-line completion for the :echo command does not find
functions whose names begin with g:.
To demonstrate this, first start vim like this,
$ vim -N -u NONE -i NONE
then source a file containing the following.
let FooVar = "foo"
let g:BarVar = "bar"
function! FooFunc()
echo "foo"
endfunction
function! g:BarFunc()
echo "bar"
endfunction
Now, try completing each of those symbols after :echo with ^D
(Ctr-D).
:echo g:
g:BarVar g:FooVar
:echo Bar
BarFunc() BarVar
:echo Foo
FooFunc() FooVar
Note that the global variables are expanded following g: even if
they were not defined with g:, but that neither global function is
expanded following g: even if g: was in its name when defined.
I know the problem can be worked around, but when I see a function
defined with g: in its name, I'd like to be able to echo its return
value by typing the first few characters of its name as I see them
without having to think very much about it, as I can with global
variables.
I'm using vim 8.2.2340 in a terminal on an Ubuntu 20.04 system.
The problem also exists with vim 8.1.497. This works differently on
7.2.330, more as I would expect it to.
:echo g:
g:BarFunc() g:BarVar g:FooVar
:echo Bar
BarVar
:echo Foo
FooFunc() FooVar
I understand the desirability of expanding global symbols with or
without using the g: prefix, but I think including the g: prefix
should expand global function names as well as global variables.
I have not performed a git bisect to find the offending commit.
Regards,
Gary