On Monday, October 17, 2016 at 6:08:35 PM UTC-4, Luis Henriquez-Perez wrote:
> I am using vim to code my java projects. I've been noticing I've been jumping 
> back to the terminal a lot to compile and run my code. So I want to create a 
> function that does all this for me (and gets rid of the class files 
> afterwards). The code below is my attempt. Could someone let me know how I 
> can fix my code?
> 
> func! CompileFolderJava()
> 
>       " compile all java files in folder of the current buffer
>       :!javac "%:p:h" . "/*.java"       "  javac 
> path/name/to/current/buffer/directory/*.java
> 
> 
>       " run Main java file in that folder
>       :!java "%:p:h" . ".Main"            " java 
> path/name/to/current/buffer/directory.Main
> 
>       " delete all the .class files in that folder
>       :!rm "%:p:h" . ".class"
> 
>       " :echo "Done"
> endfunc

I managed to get the compiling and the removing to work. For running, I think I 
have to be in the parent directory of the file. The format needs to be: java 
ParentDir.Main

func! CompileFolderJava()
        " compile all java files in folder
        :!javac %:p:h/*.java

        " a java thing I have to be in this directory to call java main
        :cd ..
        " run all the java files in folder
        :!java %:h.Main

        " delete all the .class files in folder
        :!rm %:p:h/*.class

        " :echo "hello"
endfunc

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to