0

I want to compile and run a generated java executable inside of Vim quickfix. My .vimrc:

function! Make(script)
  if &ft ==# "c" || &ft ==# "cpp"
    compiler gcc
  elseif &ft ==# "java"
    compiler javac
  else
    return 0
  endif

  let &makeprg="bash " . a:script

  make! 
  copen
  redraw
endfunction

nnoremap <silent> <C-B> :call Make("build.bash")<CR><CR>

For C/C++ programs, this works correctly with a build.bash:

# This IS displayed
echo something
# This IS displayed
gcc file.c -o file
# This IS displayed
./file

For Java programs however, no output is displayed except for the output of the javac command, e.g build.bash:

# This is NOT displayed
echo something 
# This IS displayed
javac File.java
# This is NOT displayed
java File 

How can I solve this?

Your Answer

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

Browse other questions tagged or ask your own question.