Sunday, March 19, 2017

Re: Passing current line number to shell command

Hi Honggyu,

2017-3-19(Sun) 20:16:57 UTC+9 Honggyu Kim:
> 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.
>
> Can anyone give me some guide how I can pass the current line number to shell?

There is a way to pass it via environment variables.
See document.
:help :let-$


Sample:

:let $xxx=line('.')
:echo $xxx
12
:!echo $xxx
12

Press ENTER or type command to continue

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

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