1

I'm trying to add a line to my .vimrc to run java.

If I type, :! basename % .java | xargs java

then all is good, but I cant get this into the vimrc without E492 Not an editor command.

I'd initially tried, nmap <leader> J :! basename % .java | xargs java and then tried to make a :Java command, but get the error both times. Any suggestions?

2

You can also use backticks for executing the command:

map <F11> :!javac %; java `basename % .java`<CR>
1

I've solved it

command Java execute "! basename % .java | xargs java"

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.