Building and Deploying an Android app from the Shell
https://gist.github.com/seawolf/5343754
Eclipse is a productive environment for developing an Android application, but I still spend a lot of time at the shell working with Git, so I wondered if I could use Vim and a script to code and build/deploy my app.
I concluded that I'd need my Vim to format Java files the same way as Eclipse, which means:
- indenting lines with one, four-character tabstop (Ruby is two spaces)
- using one tabstop instead four spaces (Ruby is spaces instead of tabs)
- ending each file with a blank line (I like Vim to chomp whitespace off of the end of lines and end the file at the last line of text, as Git is whitespace-observant by default)
Adding this into my .vimrc allowed for these rules only in Java files:
au FileType java :setlocal softtabstop=4 tabstop=4 shiftwidth=4 noexpandtab
It's the setlocal
that tells Vim to use these settings only in the current buffer, and not for the rest of the session (i.e. when you open another file). I also needed the colon in there for some reason.
With my Vim featuring syntax highlighting, autocompletion and the like, I can now code Java without going against the coding style used by Eclipse. The only problem, however, is that coding solely Ruby, JavaScript and Bash/Zsh for the past few years has left my Java skills too weak without the keyword and syntax helpers and code block auto-generation that Eclipse provides. Still, I find Git and this build script a lot quicker to use and run than the equivalent process in Eclipse, even if I'm not coding in Vim.