https://github.com/zyedidia/vim-snake
Snake game written in Vimscript
https://github.com/zyedidia/vim-snake
Last synced: 10 months ago
JSON representation
Snake game written in Vimscript
- Host: GitHub
- URL: https://github.com/zyedidia/vim-snake
- Owner: zyedidia
- License: mit
- Created: 2014-11-30T15:01:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-04T17:07:24.000Z (almost 8 years ago)
- Last Synced: 2025-01-16T09:56:34.469Z (12 months ago)
- Language: Vim script
- Homepage:
- Size: 42 KB
- Stars: 25
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vim Snake
Play ascii snake without leaving Vim! This game is written in Vimscript and allows
you to play snake from the comfort of your editor.
Control the snake with the hjkl keys (so that you can hone your vim movement
skills). Eat the apples and don't run into the wall or yourself.

## Installation
You can install this plugin with your favorite plugin manager.
Vundle (for example):
```
Plugin 'zyedidia/vim-snake'
```
Start the game by running `:Snake`.
## Options
You can choose different options for the width/height of the play area:
```
let g:snake_rows = 20
let g:snake_cols = 50
```
You can also choose the update time (millisecond delay between frame updates):
```
let g:snake_update = 125
```
## How does it work?
The game loop is run by abusing the `CursorHold` autocommand. If no keys are
pressed for a certain amount of time, the autocommand will be triggered. Notice
that if you hold down a key during the game, the loop stops.
You can read about this trick [here](http://vim.wikia.com/wiki/Timer_to_execute_commands_periodically).