Silent invocation of gvim on Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Silent invocation of gvim on Windows

Ritmo2k
I have a use case where the optimal tool for my need is gvim as I don't have access to anything more suitable in the context. I am trying to invoke gvim as a process to perform a replacement (no shell or batch based invocation).

The arguments I am passing (which are simply string joined with a space) are:

string[] arguments =
{
    "-N",
    "-u",
    "NONE",
    "-i",
    "NONE",
    "-n",
    "-es",
    "-c",
    "\"%s/.*foo.*/bar/g | w\"",
    @"x:\path\to\file"
};

The replacement is performed as expected, however the return code is 1. Is that by design, or as a result of something I have done incorrectly? The facility performing the invocation checks for a non zero return code and it would be desirable for that to be the case when a genuine error has occurred.

Thanks

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Silent invocation of gvim on Windows

Ben Fritz
On Wednesday, November 1, 2017 at 6:45:39 PM UTC-5, Joseph L. Casale wrote:

> I have a use case where the optimal tool for my need is gvim as I don't have access to anything more suitable in the context. I am trying to invoke gvim as a process to perform a replacement (no shell or batch based invocation).
>
> The arguments I am passing (which are simply string joined with a space) are:
>
> string[] arguments =
> {
>     "-N",
>     "-u",
>     "NONE",
>     "-i",
>     "NONE",
>     "-n",
>     "-es",
>     "-c",
>     "\"%s/.*foo.*/bar/g | w\"",
>     @"x:\path\to\file"
> };
>
> The replacement is performed as expected, however the return code is 1. Is that by design, or as a result of something I have done incorrectly? The facility performing the invocation checks for a non zero return code and it would be desirable for that to be the case when a genuine error has occurred.
>
> Thanks
Why gvim and not console vim? I don't know if it is the cause, but if you must use gvim then on Linux and similar systems you need to also pass the "-f" argument if you want your code to wait for gvim to be exited. This doesn't work in Windows, but the official installer can create a .bat file with an implementation of a similar feature.

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Silent invocation of gvim on Windows

Ritmo2k
On Friday, November 3, 2017 at 1:49:18 PM UTC-6, Ben Fritz wrote:

> >     "-c",
> >     "\"%s/.*foo.*/bar/g | w\"",

> Why gvim and not console vim? I don't know if it is the cause, but if you must use gvim then on Linux and similar systems you need to also pass the "-f" argument if you want your code to wait for gvim to be exited. This doesn't work in Windows, but the official installer can create a .bat file with an implementation of a similar feature.

Hi Ben,
What solved it was multiple invocations of -c, one for each command.

I don't have a preference on gvim versus vim, however the next time I
am making changes I will explorer that just for curiosities sake.

Thanks.

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