To work with pascal
files, my .vimrc
contains this code:
"" Work with pascal files
augroup make_pascal
autocmd!
autocmd FileType pascal :compiler fpc
autocmd FileType pascal :set makeprg=clear;\ fpc\ %
augroup END
To demonstrate the issue I am experiencing see this easy hello-world-like demonstration code written in pascal
which intentionally contains an error:
program EasyExample (output);
begin
writeln ('Correct line.');
thisWillCauseAnError;
end.
When I run :make
on this file with my Vim cursor in any line that does not contain the error, everything works fine: the external fpc
compiler gets called and aborts compilation due to an error. After pressing ENTER
I get back to my source code and the cursor is in the line that contains the error, and the error message is displayed at the bottom.
But when I run :make
on this file with my Vim cursor in the line that does contain the error, an additional step is added (and I would like to remove it): After the compilation abortion pressing ENTER
does not get me back to my source code, but instead a new "window" (is that the quickfix list?) is shown with the following text at the bottom:
(5 of 8): Error: Identifier not found "thisWillCauseAnError"
Press ENTER or type command to continue
After pressing ENTER
again I see my source code again, the cursor in the line that contains the error, and the error message is displayed at the bottom.
Question
How do I get rid of that additional "window" that appears, so that the behaviour when running :make
is always the same (i.e. press ENTER
once to see my source code with highlighted error)?
:silent! make | redraw! | cw
is a great solution and is what I will use. Please post it as an answer (so that you get reputation and the vi/Vim site stats on Area51 get better) and I will happily accept it. It would be great if you could also mention a way how I could delete the.o
file automatically after compilation, as theautocmd
in my answer that deletes the object file does not work with the:silent! make | redraw! | cw
command: the quickfix list is empty and does not contain errors..o
file, maybe you could look at:h autocmd-events
and see if there's an event which corresponds to a compilation. MaybeQuickFixCmdPre
orQuickFixCmdPost
? That would give something likeautocmd QuickFixCmdPost * !rm\ -f\ %:r.o
I didn't try it so it may not work as expected.ShellCmdPost
then? You could also install a fire-once autocmd (the autocmd is installed and removed as soon as the command is executed) inside a function and call the latter from a mapping,c
or a custom command:CP
: vpaste.net/0t1i4