Wednesday, May 25, 2016

Re: Channel commands: special characters, quotes and escaping

Jan Bundesmann wrote:

> > I think this should also work:
> >
> > ["ex", 'call feedkeys("ggOHello, world!\\e")']
> Nope, it does not. Channel log says:
> 82.925983 RECV on 0: '["ex", 'call feedkeys("ggOHello, world!\\e")']'
> 82.926009 ERR on 0: Decoding failed - discarding input

Oh wait, this is JSON and JSON only accepts double quoted strings.

> > Keep in mind this is in Python. And in Python a backslash inside a
> > single quoted string has a special meaning, unlike Vim.
> I still think, it's somehow related to the handler. Or is this, too,
> written in Python?
>
> Out of curiousity, I tried the same but with a simple socket, established via "netcat".
> ["ex", "call feedkeys(\"ggOHello, world!\\e\")"] works
> ["ex", 'call feedkeys("ggOHello, world!\\e")'] does not

Yes, you must use double quoted strings. And then take care of what
Python does with the backslashes.

--
hundred-and-one symptoms of being an internet addict:
10. And even your night dreams are in HTML.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: