Here's a trick I use for quickly launching and packaging my game from within vim. In my ~/.vimrc file, I have the lines:
Code: Select all
"change vim's directory to opened file
set autochdir
"change vim's directory when switching files
autocmd BufRead
"if it exists, run .vimrc from the current folder
set exrc
"restrict the privileges to minimize the damage that could arise from opening a downloaded file with a malicious .vimrc in the same directory
set secure
Which allows me to have a custom .vimrc file in each directory. And in the game's directory, I have a file called .vimrc with the following contents:
Code: Select all
"Run the game with ctrl+k
inoremap <C-K> <C-O>:!/Applications/love.app/Contents/MacOS/love .<CR>
map <C-K> :!/Applications/love.app/Contents/MacOS/love .<CR>
"Package the game into a .love file with ctrl+\
inoremap <C-\> <C-O>:!zip -FSr $(basename $(pwd)).love * -x .* *.love *.sh<CR>
map <C-\> :!zip -FSr $(basename $(pwd)).love * -x .* *.love *.sh<CR>
This lets me launch the game by hitting ctrl+k or package the game with ctrl+\ in insert or normal mode. Since it's per-directory, it's also nice to be able to set up different versions of the same .vimrc file depending on the game (e.g. changing the name from "game.love"). Also, if I'm working on a game with multiple directories, I'll put a .vimrc in each of the directories, with the paths adjusted accordingly.
(This is for a mac, obviously, you can adjust the path to the löve executable as needed for your OS)
Also, another tip: if you put the following line in your .vimrc, you can edit a .love file with vim directly by just using "vim foo.love". It's great.
Code: Select all
autocmd BufReadCmd *.love call zip#Browse(expand("<amatch>"))