Saturday, August 22, 2009

Re: goto line depending on exit code of filter

>> have a look at
>>
>> :help v:shell_error
>>
>> This variable holds the result of the last shell command.
>
> Thanks for help. Excuse me for being dense. How to write a vimscript
> command to jump to line number v:shell_error?
>
> :if v:shell_error do.
> : (jump to the error line)
> :else
> : (jump to the previous current line)
> :end

Though it's a bit of a horrible abuse, you can do

if v:shell_error > 0 | exec v:shell_error | endif

which exploits the fact that an ex command of just a number means
to go to that line. Granted, the range of exit codes may limit
you to a pretty small range (1-127, IIRC), so you can't jump to a
line beyond this max. But it's what you asked for :)

There's no good help target that I could find for the ":<number>"
syntax -- the closest I could get are:

:help gg " the item after it is ":[range]" with no tag
:help cmdline.txt " search for "goto line 3"
:help cpo-- " has a mention of using it
:help 'sol' " has a mention of using it

Hope this helps,

-tim


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

No comments: