Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You can also use backticks for executing the command:

map <F11> :!javac %; java `basename % .java`<CR>
share|improve this answer
up vote 1 down vote accepted

I've solved it

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .