logoalt Hacker News

Show HN: Zsweep – Play Minesweeper using only Vim motions

39 pointsby oug-tlast Sunday at 2:00 PM16 commentsview on HN

Comments

QuadmasterXLIItoday at 6:42 PM

For reference, here are the supported motions:

    case '0': return { type: 'ZERO' };
    case '_': return { type: 'START_ROW' };

    // --- SEARCH ---
    case '/': return { type: 'START_SEARCH' };
    case 'n': return { type: 'NEXT_MATCH' };
    case 'N': return { type: 'PREV_MATCH' };

    // --- MOVEMENT (WASD Removed) ---
    case 'h': case 'ArrowLeft':  return { type: 'MOVE_CURSOR', dx: -1, dy: 0 };
    case 'j': case 'ArrowDown':  return { type: 'MOVE_CURSOR', dx: 0, dy: 1 };
    case 'k': case 'ArrowUp':    return { type: 'MOVE_CURSOR', dx: 0, dy: -1 };
    case 'l': case 'ArrowRight': return { type: 'MOVE_CURSOR', dx: 1, dy: 0 };
    
    // --- SKIPS ---
    case 'w': return { type: 'NEXT_UNREVEALED' };
    case 'b': return { type: 'PREV_UNREVEALED' };

    // --- ACTIONS ---
    case 'i': case 'Enter': return { type: 'REVEAL' };
    case ' ': return { type: 'SMART' };
    case 'f': return { type: 'FLAG' };
    
    // --- ADVANCED MOTIONS ---
    case '$': return { type: 'MOVE_CURSOR', dx: 999, dy: 0 };  
    case 'G': return { type: 'GO_BOTTOM' }; 
    case 'g': return { type: 'GO_TOP' };  
No macros or block select yet, still fun! probably for the best that /mine doesn't work yet
johnhamlintoday at 6:44 PM

Love games like this. I used Vim Snake to make the muscle memory for hjkl finally stick in my brain. (I wish you could disable the insert mode toggling -- it's cute but didn't help when I was trying to break the habit of moving my finger up to press W or Up Arrow and remember that everything is in a straight line.)

https://vimsnake.com

TheGRStoday at 6:49 PM

Very nice, only feedback I have rn is you should keep the board state displayed after you hit a mine. I like to look around the board to see what I missed after making a mistake.

unformedeltatoday at 5:27 PM

This was fun!

It would feel a little more intuitive if w/b worked on groups of unrevealed tiles instead of just moving 1 space when you were already on an unrevealed tile. i.e. unrevealed = words, revealed = spaces. That way, you could also use them to meaningfully navigate around unrevealed groups better than using h/l. I also found myself missing "e" to go to the end of a word, apparently I use it more often than "w".

I really appreciated the attention to detail though, I was delighted when I realized that gg/G/0/$ all worked as expected.

alejoartoday at 6:29 PM

Remember to exclude vimium from the site!

1313ed01today at 5:27 PM

It is common in traditional roguelikes to support vi keys as an alternative to arrow keys. I use that all the time when playing Brogue. Have a great vi keys muscle memory now thanks to that, but I use Emacs and only rarely vi, so it's not doing me much good.

show 1 reply
kejtoday at 5:21 PM

This is a fun idea and the implementation works pretty well.

The only complaint I have is that enter for clearing feels awkward in conjunction with hjkl movement; maybe add (d)elete and (f)lag as alternatives to enter and space to keep everything on the home row without requiring stretching?

oug-tlast Sunday at 2:00 PM

Hi HN,

I’m the creator of zsweep. It’s a keyboard-centric Minesweeper clone where you play entirely using Vim motions (h, j, k, l to move; w/b to skip words; etc.).

The Backstory: I wanted to build a project to get my hands dirty with Svelte 5 and the new Runes system. I also wanted a way to practice Vim muscle memory that wasn't just typing code.

Tech Stack:

Frontend: Svelte 5 (Runes) + SvelteKit

Styling: Tailwind CSS

State: Custom Finite State Machine (FSM) for the game logic

The Challenge: One of the hardest parts was getting the "chording" logic right (where you clear multiple squares at once) while keeping the keyboard navigation feeling instant and "vim-like."

It’s open source, so if you’re curious about how Svelte 5 handles game state, feel free to poke around the code: https://github.com/oug-t/zsweep

I’d love to hear your feedback on the controls or any edge cases you find!

show 1 reply
zahrevskytoday at 6:26 PM

Too bad it doesn't display the keyboard on mobile :-(

sodacannertoday at 6:39 PM

Very useful as someone who's trying to use Vim motions more often, thanks!

lasgawetoday at 6:14 PM

This is nice! love this

oug-tlast Sunday at 2:12 PM

Play at: https://zsweep.com

show 1 reply