Corona SDK Meets Vim

Using Vim for Corona SDK development is really a good option. Here are the tips you need to use Vim together with Corona.

Syntax Coloring

When you use a recent version of Vim (< 7.x) it should support syntax highlighting for Lua 5.1out of the box. You can download a Vim syntax file for Lua, if you use an earlier version.

Lua Reference Manual

You can access the reference manual for Lua 5.0 and 5.1 from within Vim. Download and install the Lua reference manual for Vim first.

Installation is easy:

  1. Download and unzip the package.
  2. Copy lua51refvim.txt to ~/.vim/doc/
  3. Copy luarefvim.vim to ~/.vim/plugin/
  4. Copy help.vim to ~/.vim/after/syntax/

Now when you have a Lua file open in Vim, you can access the Lua reference by moving the cursor on a keyword and entering the keyboard sequence \lr. Or \lc to get the table of contents.

Please note that you need to enter the key sequence quite quickly in one flow. If you stop after the first key for a second, Vim will not recognize it as a key sequence!

Starting the Simulator From within Vim

If you want to start the Corona SDK simulator from within Vim you need to add the following lines to your .vimrc file.

" Start the Corna Simulator with F3 for iPhone skin. Shift-F3 for iPad skin.
map <F3> :!/Applications/CoronaSDK/simulator -project %:p -skin iPhone<CR>
map <S-F3> :!/Applications/CoronaSDK/simulator -project %:p -skin iPad<CR>

Now you can start the iPhone simulator with the F3 key and the iPad simulator with Shift-F3.

Session Support

If you need to work on different Corona projects you will be glad to have session support.

Create a folder where you want to store your session files. My folder is named .vimSessions and is in my home directory.

Add the following lines to your .vimrc file:

" Session support. Save Session As and Session Open.
nmap SSA :wa<CR>:mksession! ~/.vimSessions/
nmap SO :wa<CR>:so ~/.vimSessions/

Now, when you want to save your session, just enter SSA and enter a session name. To return to a previously saved session just enter SO and enter the session name. You can use file name completion here by using the tab key.

Vim Versions

I use both the vim command line version, which you can access from within a terminal session, and the Mac application version MacVim.

I’m curious about your Vim tips and tricks for working with Corona. Please let me know them.


Jo's Profile ImageWritten by Jo Meenen who lives and works in Frankfurt building digital doodah. Stalk him on Twitter

ImpressumDatenschutz