Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

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

Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

Michel Grassi
Hi,
I'd like to know if someone here can help-me.

I need to store in a variable in the shell prompt the stdout of "vim -c {parameters}".
But to make it works and meet my need, the Vim must be run externally by the shell (something like "vim -c{input recognized by vim}"), passing it input parameters and the result of this output, store in a variable X.
I tried using the command vim -c 'command vim' but this did not work !

Explaining what I need is:
1) The Vim must be "called" by a script.sh and should take parameters as input to do something.
2) This parameters, will be passed to vim in variables (three variables). The variables are: $A, that contains a file name, $L that contains the number of a line of this file and $C that contains column number (the cursor position on the line $L)
3) With those data, the vim will use this input shift the cursor to the line $L at position $C of $A file.
4) Once the cursor being in the requested position, the char contained in the specified position must be copied and assigned to the variable X shell.

--
--
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: Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

Tumbler Terrall
Sure, make a custom function that takes parameters. Then call it from the shell like so:

vim -c"call MyFunction(myParameter1, myParameter2)"

You'll need to dynamically fill in the parameters, but that should be manageable.

On Thu, Jul 21, 2016 at 1:36 PM, Michel Grassi <[hidden email]> wrote:
Hi,
I'd like to know if someone here can help-me.

I need to store in a variable in the shell prompt the stdout of "vim -c {parameters}".
But to make it works and meet my need, the Vim must be run externally by the shell (something like "vim -c{input recognized by vim}"), passing it input parameters and the result of this output, store in a variable X.
I tried using the command vim -c 'command vim' but this did not work !

Explaining what I need is:
1) The Vim must be "called" by a script.sh and should take parameters as input to do something.
2) This parameters, will be passed to vim in variables (three variables). The variables are: $A, that contains a file name, $L that contains the number of a line of this file and $C that contains column number (the cursor position on the line $L)
3) With those data, the vim will use this input shift the cursor to the line $L at position $C of $A file.
4) Once the cursor being in the requested position, the char contained in the specified position must be copied and assigned to the variable X shell.

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

--
--
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: Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

Michel Grassi
Em quinta-feira, 21 de julho de 2016 17:01:41 UTC-3, Tumbler Terrall  escreveu:

> Sure, make a custom function that takes parameters. Then call it from the shell like so:
>
>
> vim -c"call MyFunction(myParameter1, myParameter2)"
>
>
> You'll need to dynamically fill in the parameters, but that should be manageable.
>
>
> On Thu, Jul 21, 2016 at 1:36 PM, Michel Grassi <[hidden email]> wrote:
> Hi,
>
> I'd like to know if someone here can help-me.
>
>
>
> I need to store in a variable in the shell prompt the stdout of "vim -c {parameters}".
>
> But to make it works and meet my need, the Vim must be run externally by the shell (something like "vim -c{input recognized by vim}"), passing it input parameters and the result of this output, store in a variable X.
>
> I tried using the command vim -c 'command vim' but this did not work !
>
>
>
> Explaining what I need is:
>
> 1) The Vim must be "called" by a script.sh and should take parameters as input to do something.
>
> 2) This parameters, will be passed to vim in variables (three variables). The variables are: $A, that contains a file name, $L that contains the number of a line of this file and $C that contains column number (the cursor position on the line $L)
>
> 3) With those data, the vim will use this input shift the cursor to the line $L at position $C of $A file.
>
> 4) Once the cursor being in the requested position, the char contained in the specified position must be copied and assigned to the variable X shell.
>
>
>
> --
>
> --
>
> 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.
Ok, I understand, but I'm an amateur in Vim implementation.
Can you help me?
How can I to implement a function that go to, for example, line 123, position(column) 5, and that write the result into a kernel variable? I have no idea how do this.

--
--
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: Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

tooth pik
On Thu, Jul 21, 2016 at 01:40:52PM -0700, Michel Grassi wrote:

> Em quinta-feira, 21 de julho de 2016 17:01:41 UTC-3, Tumbler Terrall  escreveu:
> > Sure, make a custom function that takes parameters. Then call it from the shell like so:
> > vim -c"call MyFunction(myParameter1, myParameter2)"
> > You'll need to dynamically fill in the parameters, but that should be manageable.
> >
> > On Thu, Jul 21, 2016 at 1:36 PM, Michel Grassi <[hidden email]> wrote:
> > Hi,
> >
> > I'd like to know if someone here can help-me.
> > I need to store in a variable in the shell prompt the stdout of "vim -c {parameters}".
> > But to make it works and meet my need, the Vim must be run
> > externally by the shell (something like "vim -c{input recognized by
> > vim}"), passing it input parameters and the result of this output,
> > store in a variable X.
> >
> > I tried using the command vim -c 'command vim' but this did not work
> >
> > Explaining what I need is:
> >
> > 1) The Vim must be "called" by a script.sh and should take
> > parameters as input to do something.
> >
> > 2) This parameters, will be passed to vim in variables (three
> > variables). The variables are: $A, that contains a file name, $L
> > that contains the number of a line of this file and $C that contains
> > column number (the cursor position on the line $L)
> >
> > 3) With those data, the vim will use this input shift the cursor to
> > the line $L at position $C of $A file.
> >
> > 4) Once the cursor being in the requested position, the char
> > contained in the specified position must be copied and assigned to
> > the variable X shell.

at the risk of uttering blasphemy on the vim-use list, wouldn't awk be
better suited to this task than vim?



--
--
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: Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

arocker
>
> at the risk of uttering blasphemy on the vim-use list, wouldn't awk be
> better suited to this task than vim?
>

"Is this a nail I see before me" quoth the hammer-wielder. :-)*

--
--
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: Is there a way to run a shell script that "calls" VIM from outside, passing parameters to it (without to open yours interface)?

Charles Campbell
In reply to this post by tooth pik
toothpik wrote:

> On Thu, Jul 21, 2016 at 01:40:52PM -0700, Michel Grassi wrote:
>> Em quinta-feira, 21 de julho de 2016 17:01:41 UTC-3, Tumbler Terrall  escreveu:
>>> Sure, make a custom function that takes parameters. Then call it from the shell like so:
>>> vim -c"call MyFunction(myParameter1, myParameter2)"
>>> You'll need to dynamically fill in the parameters, but that should be manageable.
>>>
>>> On Thu, Jul 21, 2016 at 1:36 PM, Michel Grassi <[hidden email]> wrote:
>>> Hi,
>>>
>>> I'd like to know if someone here can help-me.
>>> I need to store in a variable in the shell prompt the stdout of "vim -c {parameters}".
>>> But to make it works and meet my need, the Vim must be run
>>> externally by the shell (something like "vim -c{input recognized by
>>> vim}"), passing it input parameters and the result of this output,
>>> store in a variable X.
>>>
>>> I tried using the command vim -c 'command vim' but this did not work
>>>
>>> Explaining what I need is:
>>>
>>> 1) The Vim must be "called" by a script.sh and should take
>>> parameters as input to do something.
>>>
>>> 2) This parameters, will be passed to vim in variables (three
>>> variables). The variables are: $A, that contains a file name, $L
>>> that contains the number of a line of this file and $C that contains
>>> column number (the cursor position on the line $L)
>>>
>>> 3) With those data, the vim will use this input shift the cursor to
>>> the line $L at position $C of $A file.
>>>
>>> 4) Once the cursor being in the requested position, the char
>>> contained in the specified position must be copied and assigned to
>>> the variable X shell.
> at the risk of uttering blasphemy on the vim-use list, wouldn't awk be
> better suited to this task than vim?
>
I agree that it sounds like awk would be better.

Nonetheless: if after looking at what awk can do, and it seems that vim
is still the way to go:

* use vim to generate a file script
* use your script and run that file script (using . scriptname   so the
variables are in the environment).
* I'm assuming by "kernel variable" you actually mean "environment
variable".  If you really mean a kernel variable, such as may be found
occasionally in files such as /proc/sys/kernel/core_uses_pid, this would
be a dangerous approach until you're absolutely certain that things are
working correctly.

Regards,
Chip Campbell

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