Thursday, September 18, 2014

Re: Parse an error log and go to the line indicated as being the error?

>Hi, I have a function that calls my make application and if
>compilation fails it brings up a new window at the top of the term
>with the log open in it. All works well but what I'd like to do is
>grab the line from the error message and go to that line in my code
>script.
>
>Here is an example of one such line:
>
>I:\ut99\XConsole\Classes\XConsole.uc(4230) : Error, Unexpected 'i'
>
>So in this example I would like to place the cursor at line 4230.
>
>I can't find much in the way googling for this but I imagine it's
>possible. Perhaps there's a way of setting a variable from the line
>number and then going to it?
>
>Any ideas greatly appreciated.
>
>-Dave

Solved:

function BadLog()
7split
let log = '/tmp/ucc.log'
edit `=log`
vimgrep /Error,/ %
let eline=system('grep Error, /tmp/ucc.log | cut -d\( -f2 | cut -d\) -f1')
normal zt
wincmd j
call cursor(eline, 0)
endfun

-Dave

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