:echo command-line completion doesn't find functions beginning with g:

8 views
Skip to first unread message

Gary Johnson

unread,
Jan 12, 2021, 10:45:10 PM1/12/21
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

Gary Johnson

unread,
Jan 12, 2021, 11:51:55 PM1/12/21
to vim...@googlegroups.com
I just did.

A bug was introduced at v7.4.260 that prevented function names from
beginning with g:. That was fixed at v7.4.264 but introduced the
bug that prevents ":echo g:^D" from finding global functions.

Regards,
Gary

Bram Moolenaar

unread,
Jan 13, 2021, 1:50:05 PM1/13/21
to vim...@googlegroups.com, Gary Johnson
Fixed by 8.2.2341.

--
hundred-and-one symptoms of being an internet addict:
135. You cut classes or miss work so you can stay home and browse the web.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages