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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

UncleBill
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.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4cefdbda-f8ff-404f-ab4b-7052b350d4c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Christian Brabandt

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
--
Munterbleiben, heute ist Weltuntergang!

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190714131855.GA31610%40256bit.org.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Salman Halim


--

Salman

On Sun, Jul 14, 2019, 09:18 Christian Brabandt <[hidden email]> 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

--
--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

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

UncleBill
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 <[hidden email]>于2019年7月14日 周日下午10:46写道:


--

Salman

On Sun, Jul 14, 2019, 09:18 Christian Brabandt <[hidden email]> 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

--
--
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 [hidden email].
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.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAPHDgoOzhq0s77XMV_c0Bzj9Y_OnzsEXa9jgM%2BvVGh6DBzK5MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

UncleBill
Salman Halim,

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

吴祖姜 <[hidden email]>于2019年7月16日 周二上午1:19写道:
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 <[hidden email]>于2019年7月14日 周日下午10:46写道:


--

Salman

On Sun, Jul 14, 2019, 09:18 Christian Brabandt <[hidden email]> 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

--
--
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 [hidden email].
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.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAPHDgoM1roeVRjxe6S9H2Shnm13jVnp-QqHPZBy-xHUwLEaTJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Christian Brabandt
In reply to this post by UncleBill

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

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190715172540.GO31610%40256bit.org.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

UncleBill
Thank you! It really helps!

Christian Brabandt <[hidden email]> 于2019年7月16日周二 上午1:25写道:

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

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190715172540.GO31610%40256bit.org.
For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAPHDgoOaXmZqiBpAqv6T6Rk4e_b1t%3D31-U7yxTV-LOszhXBs_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.