Vim

Vim also has a number of plugins to choose from that make it even more powerful, not only for efficient text editing, but also for expanding into an efficient code editor, which is one of the reasons why Vim is so widely used by programmers.

Vim is powerful, but it also has a steep learning curve, so it’s not easy for everyone to pick up. It’s a process of constant practice.

Today, I recommend a Vim game that can help you learn Vim – PacVim. It can make you learn Vim no longer boring. You can also learn Vim by playing games.

PacVim introduction

PacVim is a game that teaches you how to use Vim commands. In the game interface that opens, you need to move (green cursor) to highlight each word on the screen, while avoiding hitting the red moving cursor. PacVim is very similar to the well-known classic game PacMan. The author is also inspired by PacMan game to develop PacVim.

PacVim requires you to use Vim commands to move the cursor, which is a fun way to learn Vim commands.

Install PacVim

PacVim currently supports MacOS and Linux. You can download, install, and run it on Github using git commands.

git clone https://github.com/jmoon018/PacVim.git
cd PacVim
[sudo] make install
Copy the code

Note The [sudo] field in the command indicates that the current account needs sudo permission to execute the command. If the current account does not need sudo permission, delete the [sudo] field.

If you are using Docker, you can run the following command to run the game:

docker run -it freedomben/pacvim [LEVEL_NUMBER] [MODE]
Copy the code

[LEVEL_NUMBER] : Also called level, for example level 5, which is the number 5.

[MODE] : indicates the operating MODE. The value can be N (common MODE) or H (hard MODE). The default value is hard MODE.

How to play?

PacVim’s rules are very similar to PacMan’s in that you must avoid all characters on the screen while avoiding red characters (red G). PacVim has two particular obstacles:

1. You can’t enter walls (yellow), you have to use vim action to jump over them.

2, If you press the tilde character (cyan ~), you will lose the game!

To start, you are given three lives, each time you pass levels 0, 3, 6, and 9, you gain lives. There are 10 levels from 0 to 9, and after defeating level 9, the game resets to level 0, but the ghosts (red G) move faster.

Win condition: Use the vim command to move the cursor over the letter and highlight it. Letters that move more will turn green. After all letters are highlighted, you will win this level and move on to the next level.

Failure condition: Failure occurs if the letter G (denoted by red G) or tilde character is touched. If your life is less than 0, you lose the entire game.

Operation command:

Command (key) action
ESC or q Quit the game
h Move to the left
j Move down the
k Move up
l To the right
w Move to the beginning of the next word
W Moves to the beginning of the next string
e Move to the end of the next word
E Moves to the next end of the string
b Moves to the beginning of the previous list
B Moves to the beginning of the previous string
$ Move to the end of the line
0 Move to the top of the line
gg/1G Move to the beginning of the first row
numberG Move to the beginning of line number
G Move to the beginning of the last line
^ Moves to the beginning of the first word in the current line
& Cheat to win and move on to the next level

Write in the last

Through this game, you can master some of the commonly used movement commands in Vim. As you play the game, you will gradually memorize these actions, and the better you get at playing the game, the more skilled you will become at them.

If you are new to Vim, start by playing SpcVim games to practice your command operation in Vim.