Can remote-send trigger Tab-completion?

57 views
Skip to first unread message

Ivan

unread,
May 4, 2015, 9:43:26 AM5/4/15
to vim...@googlegroups.com
I'm sending keys from a shell to a running Vim instance using the "--remote-send" option. I want to trigger Tab-completion on Vim's command line (e.g. `vim --remote-send ":ed<Tab>"` -> ":edit") but it ends up inserting a Tab character rather than completing the command (":ed^I" rather than ":edit"). Is there a way to do this?

The reason I'm doing this in the first place is I'm using Vimrunner (https://github.com/AndrewRadev/vimrunner) to write integration tests for a Vim plugin I'm building. I ran into this problem using Vimrunner's api to interact with Vim, and under the hood it's using Vim's client/server remote functionality. I tried it directly in the shell and got the same results.

Jacky Liu

unread,
May 6, 2015, 7:25:30 AM5/6/15
to vim...@googlegroups.com
On Monday, May 4, 2015 at 9:43:26 PM UTC+8, Ivan wrote:
> I'm sending keys from a shell to a running Vim instance using the "--remote-send" option. I want to trigger Tab-completion on Vim's command line (e.g. `vim --remote-send ":ed<Tab>"` -> ":edit") but it ends up inserting a Tab character rather than completing the command (":ed^I" rather than ":edit"). Is there a way to do this?
>
> The reason I'm doing this in the first place is I'm using Vimrunner (https://github.com/AndrewRadev/vimrunner) to write integration tests for a Vim plugin I'm building. I ran into this problem using Vimrunner's api to interact with Vim, and under the hood it's using Vim's client/server remote functionality. I tried it directly in the shell and got the same results.


maybe you can use the remote-eval feature together with the "feedkeys()" function to replace remote-send, because AFAIK this function "feedkeys()" completely simulate user key strokes without any subtle background tricks.

regards ~

Ivan

unread,
May 6, 2015, 8:26:20 AM5/6/15
to vim...@googlegroups.com
On Monday, May 4, 2015 at 9:43:26 AM UTC-4, Ivan wrote:
> I'm sending keys from a shell to a running Vim instance using the "--remote-send" option. I want to trigger Tab-completion on Vim's command line (e.g. `vim --remote-send ":ed<Tab>"` -> ":edit") but it ends up inserting a Tab character rather than completing the command (":ed^I" rather than ":edit"). Is there a way to do this?
>
> The reason I'm doing this in the first place is I'm using Vimrunner (https://github.com/AndrewRadev/vimrunner) to write integration tests for a Vim plugin I'm building. I ran into this problem using Vimrunner's api to interact with Vim, and under the hood it's using Vim's client/server remote functionality. I tried it directly in the shell and got the same results.

Awesome! feedkeys() was the answer. What finally worked from the shell was:
--remote-send ':call feedkeys(":ed\<Tab>", "t")\<CR>'

and in ruby, using Vimrunner:
vim = Vimrunner.start
vim.feedkeys ':call feedkeys(":ed\<Tab>", "t")\<CR>'

Thanks a million!

Ivan

unread,
May 6, 2015, 10:09:47 PM5/6/15
to vim...@googlegroups.com
Actually, the vimrunner version can be shortened to:
vim.command(%q{call feedkeys(":ed\<Tab>", "t")})
Reply all
Reply to author
Forward
0 new messages