How can I define a shell function (named `:` would be neat) from a terminal buffe and send commands to current vim clientr?

16 views
Skip to first unread message

陈世用

unread,
Jul 14, 2019, 2:53:52 AM7/14/19
to vim_use
Like in a terminal buffer, typing:

```
$ :vsp demo.file
```

`:` is the custom shell function's name.

It's expand to `<c-w>:vsp demo.file` or something.

Christian Brabandt

unread,
Jul 14, 2019, 9:19:03 AM7/14/19
to vim_use
I think it is unclear, what you are asking exactly. Please clarify.

Best,
Christian
--
Munterbleiben, heute ist Weltuntergang!

Salman Halim

unread,
Jul 14, 2019, 10:46:49 AM7/14/19
to Vim Users


--

Salman

On Sun, Jul 14, 2019, 09:18 Christian Brabandt <cbl...@256bit.org> wrote:

On Sa, 13 Jul 2019, 陈世用 wrote:

> Like in a terminal buffer, typing:
>
> ```
> $ :vsp demo.file
> ```
>
> `:` is the custom shell function's name.
>
> It's expand to `<c-w>:vsp demo.file` or something.

I think it is unclear, what you are asking exactly. Please clarify.

Best,
Christian

Sound like you want a terminal mapping. I think :help tmap may give you what you want, but if you remap the colon, you'll have trouble if you need to use it in an actual command. You could either map the double colon (::) to do this or to insert an actual single colon:

tmap : <c-w>:
tnoremap :: :

Or, depending on which you prefer, reverse the two mappings. 

Salman

吴祖姜

unread,
Jul 15, 2019, 1:20:13 PM7/15/19
to vim...@googlegroups.com
No, not a tmap. I know tmap. 

What I want is, to invoke vim command from a terminal with shell commands, without typing <c-w> prefix or entering normal mode. 

Like providing a shell function ‘send-keys-to-host-vim’ (and I want its name be ‘:’), then run

$ send-keys-to-host-vim vsp my.file<enter>

It equals to <c-w>:vsp my.file<enter>

Sorry for my poor English, hope it is explained clearly this time. 

Salman Halim <salma...@gmail.com>于2019年7月14日 周日下午10:46写道:
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEcCesOnUPGDGUsjjRAiQxfnJ7E_JskEzLiXcQrSJyF7DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

吴祖姜

unread,
Jul 15, 2019, 1:25:03 PM7/15/19
to vim...@googlegroups.com
Salman Halim,

Your mapping idea seems good. I will try it. Thanks.

吴祖姜 <billb...@gmail.com>于2019年7月16日 周二上午1:19写道:

Christian Brabandt

unread,
Jul 15, 2019, 1:25:44 PM7/15/19
to vim...@googlegroups.com

On Di, 16 Jul 2019, 吴祖姜 wrote:

> No, not a tmap. I know tmap. 
>
> What I want is, to invoke vim command from a terminal with shell commands,
> without typing <c-w> prefix or entering normal mode. 
>
> Like providing a shell function ‘send-keys-to-host-vim’ (and I want its name be
> ‘:’), then run
>
> $ send-keys-to-host-vim vsp my.file<enter>
>
> It equals to <c-w>:vsp my.file<enter>
>
> Sorry for my poor English, hope it is explained clearly this time. 

Have a look at `:h terminal-api`. I have a plugin that does something
similar: https://github.com/chrisbra/vpager you can also have a look
there.

Best,
Christian
--
Wie man sein Kind nicht nennen sollte:
Clara Schnaps

吴祖姜

unread,
Jul 16, 2019, 3:12:07 AM7/16/19
to vim...@googlegroups.com
Thank you! It really helps!

Christian Brabandt <cbl...@256bit.org> 于2019年7月16日周二 上午1:25写道:
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages