Sunday, March 19, 2017

Re: Passing current line number to shell command

On 19 March 2017 at 10:51, Honggyu Kim <honggyu.kp@gmail.com> wrote:
>
> Hi all,
>
> I would like to ask a question regarding getting the current line number.
> I can get it as follows:
>
> :echo line(',')
>
> It works fine but my question is in command execution with '!' in the front.
>
> :!echo line('.')
>
> But "line" is not interpreted before going to shell and makes an error.

That's because as soon as you do ":!echo" your shell's builtin "echo"
will be invoked rather
than vim's echo and your shell's echo hasn't got any idea what kind of
an argument: "line('.')"
is and freaks out.

>
> Can anyone give me some guide how I can pass the current line number to shell?
>
> Thanks,
> Honggyu

Honggyu, my guess is that you are probably trying to do something that
you probably shouldn't
be trying to do and maybe advised to have a rethink.

IIRC, in vim there is:

:h 10_commandments

From the top of my head, one of them being:

"Thou shalt not pass an internal vim variable to your shell. It's
considerably worse than incest
or folk dancing."

HTH.


Regards,

--

Frank

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

Post a Comment