vim 8 support terminal, and has a api to let command in terminal to communicate back to vim.
For example:
In vim, define function like
" .vimrc
let g:cnt = get(g:, 'cnt', 0)
func! Tapi_Command_finish(bufnum, arglist) abort
let g:cnt += 1
endfunc " Tapi_Command_finish
open a terminal buffer, run command
printf '\033]51;["call","Tapi_%s", ["%s"]]\007' Command_finish
then go back to vim, :echo g:cnt
, 1
will be echoed, demonstrate function Tapi_Command_finish
being called.
This works in linux, but when i tried on windows gvim 8, it did not work.
I search around, some say cmd
do not support ansi escape sequence. (not sure if \033]51...
is ansi escape sequence or not.)
The question:
Is there a way to use terminal api on windows gvim?
== EDIT == (The echo part)
Below are 3 ways I can thought of to reproduce the echo part.
- 1 cat file approach
under posix shell, eg, cygwin
printf '\033]51;["call","Tapi_%s", ["%s"]]\007' Command_finish > xx
and cp
or scp
to current directory. then in terminal buffer
type xx
- 2 use python
create file yy.py
, with content
print('\033]51;["call","Tapi_%s", ["%s"]]\007' % ("Command_finish",""))
then in terminal buffer, run
python yy.py
- 3 use
echo
not tried, since I don't know how to reliably send '\033'.
Of the 3 ways, both 1 & 2 works on cygwin.
echo
? I guess that's perhaps one of the most important parts to reproducing your issue...echo part
.:terminal
window and run Cygwin bash there? But it doesn't work if:terminal
is running cmd.exe? Not even the Python one? (I'd expect it would behave similarly on Cygwin and on Windows)... Or by "on cygwin" do you mean running Vim from cygwin inside the cygwin shell, in which case the:terminal
window will be a Posix shell I'd expect?:terminal
works there... It's a good question, hopefully you'll get a good answer for it!