Vim 8 built-in terminal allows communication to and from a running job. The manual describes a terminal API :h terminal-api that lets a running job to Vim. An example message is provided to open a file with

<Esc>]51;["drop", "README.md"]<07>

My question is how to actually send this to Vim from a running bash interactive session or a shell script? If this line has to be typed literally how can one enter the escape codes before and after the list?

1 Answer 1


My understanding of the word job in that doc is that it refers to whatever is running in the :term (a shell, gdb, etc.).

You can encode the message in bash with printf:

printf '<Esc>]51;%s\a' message. 

Here, the esc sequence is entered as Ctrl-V followed by Esc

  • This doesn't work for the message ["drop", "README.md"] in the example of my question. It just prints the message and a 7 at the end. I tried replacing \x007 with the bell character ^G but then it only prints the message. Jul 10, 2019 at 16:08
  • If \x007 is the bell character, then use \a
    – D. Ben Knoble
    Jul 10, 2019 at 16:57
  • What finally worked for me is printf '<Esc>]51;["drop", "README.md"]<CTRL-G>' where <Esc> and <CTRL-G>` were input followed by Ctrl-V. Your answer has the bracket after <Esc> the other way [ which is why probably it was not recognized as the proper escape sequence. Jul 10, 2019 at 19:12
  • @SigmaPiEpsilon ive corrected the answer then. Hope that helps.
    – D. Ben Knoble
    Jul 10, 2019 at 19:39
  • I've accepted the answer, thanks! Jul 10, 2019 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.