sponsor Vim development Vim logo Vim Book Ad

Mines : Play Mines with vim

 script karma  Rating 70/36, Downloaded by 8175  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
script type
Mines implements the popular game of Mines using Vim, retaining your best scores for each of three levels: Easy, Medium, and Hard.  Mines includes cecutil.vim and Rndm.vim (for screen restoration and for pseudo-random number generation).  The latest developments in Mines.vim will always be available at


        \mfe : play an easy mines game
        \mfm : play a  medium-difficulty mines game
        \mfh : play a  high-difficulty mines game
        \mfr : restore a game

Note that using the \mf_ maps above will save the files showing in all windows and save your session.  Although I've used the backslash in the maps as shown here, they actually use <Leader>, so you may customize your maps using mapleader as you wish.

Mines.vim is a use-at-your-own-risk game.  However, an effort has been made to preserve your files.  The game does a "windo w" and uses mksession to both save your working files that are showing in your windows and to preserve your window layout for subsequent restoration.

On many terminals, all you need to do is to click with the left mouse (to see what's there, or maybe to go BOOM!) or to click with the rightmouse to flag what you think is a mine.

    More Maps:

        x   move the cursor around the field;
            pressing x is just like pressing a
            <leftmouse> -- find out what's

        f   just like the <rightmouse>, flag
            what's under the cursor as a mine

        s   suspend the game, restore the display
            and session  (\mfr will subsequently
            restore the game)

        q   quit the game, restore the display

     -New Games-
        E   starts up a new easy game
            (only while an old game is showing)

        M   starts up a new medium game
            (only while an old game is showing)

        H   starts up a new hard game
            (only while an old game is showing)

The objective of the game is to flag all mines and to reveal all safe squares.  As soon as you click a <leftmouse> or x, the square under the cursor is revealed with either a count of the number of bombs around it or as a BOOM.

If you win Minnie will do a cartwheel for you!

Sigh -- there appears to be a problem with Sun Solarus dtterms -- Mines highlights several characters with the same foreground and background colors, and this action appears to turn the cursor off on dtterms.  I'm afraid I don't know how to work around this; does anyone know how to turn the cursor back on???

Thank you for rating Mines.vim -- and good luck!
install details
1. Make sure you have at least v18 of vimball:
   (if you have vim 7.1a or later, you probably can skip this step)

2. vim Mines.vba.gz
   :so %

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
Mines.vba.gz 19 2013-03-12 7.0 Charles Campbell * "nearbyflags" counter implemented
* bugfix: a "windo" is now protected by a noautocmd
* enhancement: uses nnoremaps instead of nmaps
Mines.vba.gz 18 2011-03-08 7.3 Charles Campbell Autoloading implemented for Mines (quicker vim startup)
Bug fix: an errant "norm" was changed to "norm!"
Improvement: options saved-set-restored using local variants (and noswf, noet)

Have fun clearing those minefields!  I'm getting about 59.8% wins on "Easy!"
Mines.vba.gz 17 2009-08-06 7.0 Charles Campbell * Pressing "x" when atop an "f" now is a no-op; one must use an "f" to clear an "f"
* Attempting to modify a completed minefield no longer produces not-modifiable error messages.
* cecutil bug fix incorporated
* bugfix: works with simple .vimrcs; I usually use (:set ve-all), and the lack of virtualedit was causing problems.

Enjoy!  On easy mode, I win 51.7% of the time on Easy mode...
Mines.vba.gz 16 2007-02-21 6.0 Charles Campbell On wins, percentage won now shown to 3 decimal places.
Works with Rndm.vim to save seeds in $HOME/.seed to improve pseudo-random nature of games.
Mines.vba.gz 15 2007-01-17 6.0 Charles Campbell At end of game due to hitting a mine, empty squares mistakenly flagged as bombs are shown with a blue background
Now includes cecutil to handle saving/restoring user maps
Insures that it cleans up the -Mines- file
Flickering flood bug fixed
Mines.vba.gz 14 2006-06-27 7.0 Charles Campbell Added "Flags Used" field while playing.
New commands for speedier play: pressing "c" changes corner, pressing 0,$,gg,G changes cursor position but stays inside the minefield.
Improved playability: medium is now 15% mines on an 18x18 grid, hard is 18% mines.
Mines.tar.gz 13 2006-01-06 6.0 Charles Campbell When you win, Minnie will tell you your winning percentage to the nearest 1/10 percent.
Mines now uses cecutil to save/restore user maps.
Mines.vim.gz 12 2005-12-22 6.0 Charles Campbell Mines's winning banner now includes a percentage of wins.
When Rndm.vim is missing, Mines will issue a warning about it (and where to get Rndm.vim)
Any players out there?  I've now got a 47% winning rate with Easy mode...
Mines.vim.bz2 11 2004-08-27 6.0 Charles Campbell 1: An X will now mark the bomb that went off
2: Flipped the cterm=NONE and fg/bg specs about; some machines were showing all bold which equated to one color.
3: bugfix: an "f" on a previously determined site (whether numbered or blank) will now have no effect
Mines.vim.bz2 10 2004-07-30 6.0 Charles Campbell Highlighting is now fixed after a colorscheme change.  The updatetime is now set to 200ms during the game (it gets restored) to facilitate the timing statistics and colorscheme handling.  Statistics are now kept separately for each size, and better streak statistics are kept, too.
Mines.vim.bz2 9 2004-06-28 6.0 Charles Campbell For some reason I didn't consider light backgrounds before -- Mines.vim now displays well on light as well as dark backgrounds.  To do so it uses the "background" option's setting, which colorschemes normally set (in the colorscheme sampler, only brown bw c dante delek
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.