special character for "the current editing line number" in :!{cmd}

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

special character for "the current editing line number" in :!{cmd}

Kiwon Um

Hello.

I have a question.
I'm now trying to use a cmd on vim like as follows:
:!xdvi -sourceposition "[currently editing line number] %" %<.dvi

The character '%' is replaced with current file name well.
Then, what's the corresponding special character for the [currently
editing line number]?

Best regards,
Kiwon Um
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Ivan Tishchenko


> Hello.
>
> I have a question.
> I'm now trying to use a cmd on vim like as follows:
> :!xdvi -sourceposition "[currently editing line number] %" %<.dvi
>
> The character '%' is replaced with current file name well.
> Then, what's the corresponding special character for the [currently
> editing line number]
There is no special character; you can use expression line('.')
instead.  Your command will look like:
:exe '!xdvi -sourceposition '.line('.').' %<.dvi'

WBR,
Ivan.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Andreas Politz

Ivan Tishchenko wrote:

>
>> Hello.
>>
>> I have a question.
>> I'm now trying to use a cmd on vim like as follows:
>> :!xdvi -sourceposition "[currently editing line number] %" %<.dvi
>>
>> The character '%' is replaced with current file name well.
>> Then, what's the corresponding special character for the [currently
>> editing line number]
> There is no special character; you can use expression line('.')
> instead.  Your command will look like:
> :exe '!xdvi -sourceposition '.line('.').' %<.dvi'
>
> WBR,
> Ivan.

Here are some more ideas with varying pros and cons.

cabbr <expr> %l line('.')
cmap <expr> %l line('.')
nnoremap <silent> : :let $lnum=line('.')<cr>:

-ap

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Kiwon Um
In reply to this post by Ivan Tishchenko

Thanks for your reply.

On 7월22일, 오후6시40분, Ivan Tishchenko <[hidden email]> wrote:

> > Hello.
>
> > I have a question.
> > I'm now trying to use a cmd on vim like as follows:
> > :!xdvi -sourceposition "[currently editing line number] %" %<.dvi
>
> > The character '%' is replaced with current file name well.
> > Then, what's the corresponding special character for the [currently
> > editing line number]
>
> There is no special character; you can use expression line('.')
> instead.  Your command will look like:
> :exe '!xdvi -sourceposition '.line('.').' %<.dvi'

Then, is there any way to use the ".line('.')." in :!{cmd} context,
not in :exe ?

>
> WBR,
> Ivan.

Best regards,
Kiwon Um
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Ivan Tishchenko


>> There is no special character; you can use expression line('.')
>> instead.  Your command will look like:
>> :exe '!xdvi -sourceposition '.line('.').' %<.dvi'
>>    
>
> Then, is there any way to use the ".line('.')." in :!{cmd} context,
> not in :exe ?
The only one I know is to use <c-r>. Suppose you've entered everything
up to the place when you need current line, then you type
<c-r>=line('.')<cr> -- and you have line number inserted. But I'd think
it's easier to enter line number manually.

On the other hand, <c-r>= has history, so if you need it often, you'll
just use <up> to find what you need. And just hitting <cr> in <c-r>=
prompt will evaluate last expression.

WBR,
Ivan.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Teemu Likonen
In reply to this post by Kiwon Um

Kiwon Um wrote (2008-07-22 03:55 -0700):

> On 7월22일, 오후6시40분, Ivan Tishchenko <[hidden email]> wrote:
> > There is no special character; you can use expression line('.')
> > instead.  Your command will look like:
> > :exe '!xdvi -sourceposition '.line('.').' %<.dvi'
>
> Then, is there any way to use the ".line('.')." in :!{cmd} context,
> not in :exe ?

No. You need :execute (:exe) command because otherwise functions like
line() are not evaluated. While we are at it we might want to escape the
filename too:

    :exe '!xdvi -sourceposition '.line('.').' '.shellescape(escape(expand('%:r'),'%#').'.pdf')

(If you ask me, I think filenames and special characters are a complete
mess in Vim.)

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Teemu Likonen

Teemu Likonen wrote (2008-07-22 14:50 +0300):

>     :exe '!xdvi -sourceposition '.line('.').' '.shellescape(escape(expand('%:r'),'%#').'.pdf')
                                                                                           ^^^
Obviosly it should read "dvi" here --------------------------------------------------------/

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Kiwon Um
In reply to this post by Ivan Tishchenko

Thanks again.

On 7월22일, 오후8시33분, Ivan Tishchenko <[hidden email]> wrote:

> >> There is no special character; you can use expression line('.')
> >> instead.  Your command will look like:
> >> :exe '!xdvi -sourceposition '.line('.').' %<.dvi'
>
> > Then, is there any way to use the ".line('.')." in :!{cmd} context,
> > not in :exe ?
>
> The only one I know is to use <c-r>. Suppose you've entered everything
> up to the place when you need current line, then you type
> <c-r>=line('.')<cr> -- and you have line number inserted. But I'd think
> it's easier to enter line number manually.
>

Actually I'm now using latex-suite for editing latex document. (FYI,
just refer to http://vim-latex.sourceforge.net/)
In this plug-in, user can set the dvi viewer rule, g:Tex_ViewRule_dvi.
My setting is:
let g:Tex_ViewRule_dvi = 'xdvi -sourceposition "'.line('.').' %"'
With this setting, line('.') seems to be 1 always, I don't know why...
strange...
If you are familiar with latex-suite, I expect you can help me. :)

Temporarily, as an alternative, I mapped your suggestion, :exe '!xdvi -
sourceposition "'.line('.').' %" %<.dvi', with <F12> key.
It works well. Thanks.


> On the other hand, <c-r>= has history, so if you need it often, you'll
> just use <up> to find what you need. And just hitting <cr> in <c-r>=
> prompt will evaluate last expression.
>
> WBR,
> Ivan.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: special character for "the current editing line number" in :!{cmd}

Ivan Tishchenko


> Actually I'm now using latex-suite for editing latex document. (FYI,
> just refer to http://vim-latex.sourceforge.net/)
> In this plug-in, user can set the dvi viewer rule, g:Tex_ViewRule_dvi.
> My setting is:
> let g:Tex_ViewRule_dvi = 'xdvi -sourceposition "'.line('.').' %"'
> With this setting, line('.') seems to be 1 always, I don't know why...
> strange...
> If you are familiar with latex-suite, I expect you can help me. :)
>
> Temporarily, as an alternative, I mapped your suggestion, :exe '!xdvi -
> sourceposition "'.line('.').' %" %<.dvi', with <F12> key.
> It works well. Thanks.
>  
The problem is: line('.') is evaluated at the time the value is assigned
to g:Tex_ViewRule_dvi, but must be evaluated at the time the plugin uses
the variable... I don't know how to do that in your case. If help on the
plugin doesn't say anything about this, you can fix this only by diving
into sources of LatexSuite and fix the code in question.

WBR,
Ivan.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---