I am using a user-defined function (currently located in .vimrc) and not: make or another direct command line tool to compile / check my currently edited file for errors. Like this:
function! CompileMyCode(...) set errorformat=Error:\ %m\\,\ in\ line\ %l let l:output = "Error: bad code!, in line 9" return l:output endfunction command! -nargs=* CompileMyCode :call CompileMyCode(<f-args>)
when using a new command in command mode, an error window does not appear.
:CompileMyCode | cwindow
What am I doing wrong?
Edit: Now I tried the following, which also does not open any cwindow.
function! CompileMyCode(...) set errorformat=Error:\ %m\\,\ in\ line\ %l let l:output = "Error: bad code!, in line 9" " I tried both of the following lines separately cexpr l:output call setqflist([l:output]) endfunction
The suggested cexpr and setqflist() do not correctly open the cwindow window in my example. Can anyone suggest a complete solution?
Edit 2:
The main problem is resolved. Here is my current code:
let l:result = expand("%").'|8| errortext' cexpr [ l:result, l:result ] caddexpr '' cwindow
This example looks at the default error format that vim seems to support. When cexpr outputs the actual error and uses errorformat , cwindow seems to ignore this.
However, I wanted to stick to the default error format anyway on the output, not relying on a custom errorformat
Thanks for your answers!
source share