Hi,

ZyX wrote:
> Reply to message «how to go to a file,lineno», 
> sent 08:19:12 05 September 2011, Monday
> by sinbad:
> 
>> i have a file name and line number, how can i go to that
>> file,line in vimscript. the following isn't working.
>>
>> exe ":silent! e".fname
>> exe ":silent! ".lineno
>> exe ":redraw"
> Of course, it is not. You forgot to escape filename and forgot to add a space 
> after :e:
> 
>     execute 'silent edit '.fnameescape(fname)
>     execute 'silent '.lineno
>     redraw
> Don't use `:silent!', it is a bad practise to junk possible error messages. 
> And 
> you need neither :execute before :redraw, nor `:' before commands in 
> :execute. 
> You can also use
> 
>     execute 'silent edit' fnameescape(fname) '+'.lineno

the syntax for :edit is

    :e[dit] [++opt] [+cmd] {file}

so you'll have to swap the file name and the command:

    execute 'silent edit' '+'.lineno fnameescape(fname)

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

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

Reply via email to