Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I've solved it

command Java execute "! basename % .java | xargs java"
share|improve this answer

You can also use backticks for executing the command:

map <F11> :!javac %; java `basename % .java`<CR>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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