Howdy, Vim users! Today, I stumbled upon a cool utility to sharpen your Vim usage skills. Undoubtedly, Vim is a great editor to write and edit code. However, some of you might be struggling with the steep learning curve. Not anymore! Meet PacVim, a CLI game that helps you to learn Vim commands.
PacVim is inspired by the classic game PacMan and it gives you plenty of practice with Vim commands in a fun and interesting way. Simply put, PacVim is a fun, free way to learn about the vim commands in-depth.
Please do not confuse PacMan with pacman (the Arch Linux package manager). PacMan is a classic, popular arcade game released in the 1980s.
Without further ado, let us see how to install and use PacVim in Linux.
Table of Contents
Install PacVim in Linux
First, install Ncurses library and development tools as described in the following links.
Please note that this game may not compile and install properly without gcc version 4.8.X or higher. I tested PacVim on Ubuntu 18.04 LTS and it worked just fine.
Once Ncurses and gcc are installed, run the following commands to install PacVim.
$ git clone https://github.com/jmoon018/PacVim.git
$ cd PacVim
$ sudo make install
Learn Vim Commands using PacVim
PacVim game teaches you vim commands in fun and engaging way. You must move pacman (the green cursor) to highlight each word on the gameboard while avoiding the ghosts (in red).
Start PacVim game
To play this game, just run:
$ pacvim [LEVEL_NUMER] [MODE]
For example, the following command starts the game in 5th level with normal mode.
$ pacvim 5 n
Here, "5"
represents the level and "n"
represents the mode. There are currently two modes. They are:
- n - normal mode.
- h - hard mode.
The default mode is h, which is hard.
To start from the beginning (0 level), just run:
$ pacvim
Here is the sample output from my Ubuntu 18.04 LTS system.
To begin the game, just press ENTER.
Now start playing the game. Read the next chapter to know how to play.
To quit, press ESC or q.
The following command starts the game in 5th level with hard mode.
$ pacvim 5 h
Or,
$ pacvim 5
How to play PacVim?
The usage of PacVim is very similar to PacMan.
You must run over all the characters on the screen while avoiding the ghosts (the red color characters).
PacVim has two special obstacles:
- You cannot move into the walls (yellow color). You must use vim motions to jump over them.
- If you step on a tilde character (cyan
~
), you lose!
You are given three lives. You gain a life each time you beat level 0, 3, 6, 9, etc. There are 10 levels in total, starting from 0 to 9. After beating the 9th level, the game will reset to the 0th level, but the ghosts move faster.
Winning conditions
Use vim commands to move the cursor over the letters and highlight them. After all letters are highlighted, you win and proceed to the next level.
Losing conditions
If you touch a ghost (indicated by a red G) or a tilde character, you lose a life. If you have less than 0 lives, you will lose the entire game.
Here is the list of Implemented Commands:
Keyboard shortcut | What it does |
---|---|
q | quit the game |
h | move left |
j | move down |
k | move up |
l | move right |
w | move forward to next word beginning |
W | move forward to next WORD beginning |
e | move forward to next word ending |
E | move forward to next WORD ending |
b | move backward to next word beginning |
B | move backward to next WORD beginning |
$ | move to the end of the line |
0 | move to the beginning of the line |
gg/1G | move to the beginning of the first line |
numberG | move to the beginning of the line given by number |
G | move to the beginning of the last line |
^ | move to the first word at the current line |
& | 1337 cheatz (beat current level) |
After playing couple levels, you should notice there is a slight improvement in Vim usage. Keep playing this game once in a while until you mastering the Vim usage.
Conclusion
Playing PacVim is fun, interesting and keep you occupied. At the same time, you should be able to learn Vim commands thoroughly. Give it a try, you won't be disappointed.
Suggested read:
- How To Comment Out Multiple Lines At Once In Vim Editor
- Read And Write Remote Files With Vim On Linux
- Edit Remote Files With Vim On Linux
- How To Edit Multiple Files Using Vim Editor
- How To Use Spell Check Feature In Vim Text Editor
- How To Use Vim Editor To Input Text Anywhere In Linux
- How To Password Protect Text Files Using Vim Editor In Linux
- Vimium Helps You To Browse The Web With Vim Keybindings
Resource:
4 comments
Although Vim (short for VI Improved) is almost the most popular text editor for Linux systems, it is still difficult for users to learn, as Vim has a large variety of functions. Many Linux newbies are literally afraid to learn this powerful and highly recommended text editor. On the other hand, so much effort was directed by the sedicomm and Linux community to simplify Vim learning; from creating tutorials about Vim, sharing useful tips on using Vim, to developing interactive tutorial web applications and command line games such as PacVim.
Agreed.
Thanks for the useful info!
thx u