1

I am sure this has been solved, but I cannot find a matching question.

I have a log file with the format:

<LOG SEVERITY> <FILENAME> (<LINENO>) @<TIME> <MESSAGE>

Where <FILENAME> and <LINENO> are the file and line in the src code that printed that message to the logfile.

I want have a split vim window with the logfile in one window, and the file that line in the log points to in the other window.

I have looked at:

  • vim-logreview
  • quickfix
  • <c-w>f

<c-w>f is the closest to what I want. But I want it to auto update when I move the cursor in the logfile. I also want it to move to the line pointed to by the logfile.

I have tried the quickfix feature using :grep for specific patterns, but this only lets me navigate through the logfile. I want to navigate through the files pointed to by the logfile entries.

1

<c-w>f is the closest to what I want.

There's also Ctrl-WF that accepts line number and it's documented right next to Ctrl-Wf.

But I want it to auto update when I move the cursor in the logfile.

Of course, you can trap <CursorMoved> and do some stuff automatically, but IMO it always creates more problems than it solves. It is much more natural to remap, say, <CR> to open preview on demand, e.g.

nnoremap <buffer>CR :pedit +<C-R>=matchstr(getline('.'), '(\zs\d\+\ze)')<CR> <cfile><CR>

Then put it under your custom "ftplugin" and you're done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.