Loading ...
Sorry, an error occurred while loading the content.

106982Re: goto line depending on exit code of filter

Expand Messages
  • Tony Mechelynck
    Aug 31 11:55 PM
      On 22/08/09 16:56, bill lam wrote:
      > On Sat, 22 Aug 2009, Tim Chase wrote:
      >> 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 :)
      > Thanks Tim and Ben! "exec number" does the trick.
      > I got a pretty print for my source files, when there is syntax error,
      > I made it exit with an error code equal to that line number. I tried
      > and found vim can jump to lines beyond 4000.

      Vim can jump to any line that it can count, the problem is having your
      external program generate the required number as a return code: IIRC,
      return codes are limited to one byte, and those above 127 may have a
      special meaning (generated by the OS maybe).

      In bash,

      bash: foobar: command not found
      echo $?

      returns 127, for instance.

      Depending on what you exactly want, you could also write it as

      if v:shell_error | exe v:shell_error | endif


      if v:xhell_error | exe (v:shell_error % 256) | endif


      Best regards,
      hundred-and-one symptoms of being an internet addict:
      117. You are more comfortable typing in html.

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 11 messages in this topic