This is the 29th day of my participation in the August More Text Challenge

A lifelong learner, practitioner and sharer committed to the path of technology, a busy and occasionally lazy original blogger, an occasionally boring and occasionally humorous teenager.

Welcome to dig friends wechat search “Jie Ge’s IT journey” attention!

GitHub star 2.9K+! Teach you to learn VIM by playing games!

Vim is no stranger to programmers. Is there any way to learn Vim more efficiently? There must be. So, today I would like to introduce an open source project: PacVim

What is PacVim?

PacVim is a game that lets you learn Vim commands by playing the game. You simply move the Pacman green cursor to highlight each word on the board while avoiding red obstacles. PacVim is a Github developer: Jamal Moon. In order to help him learn VIM and make learning easier, he developed this game.

Ii. Purpose of establishing PacVim

VIM was a great tool for editing code, but many people, including Jamal Moon, struggled with learning the hard way and didn’t find a fun way to learn the VIM commands in depth, so PacVim was born. Inspired by the classic PacMan, it will give anyone a lot of practice with VIM commands while still having a lot of fun.

Download and install PacVim

Mac OS X 3.1

PacVim has been compiled as a HomeBrew package, if you are a MAC user, you can run the following command to install it.

$ brew install pacvim
Copy the code

The 3.2 Linux

Download, compile and install GNU Ncurses (graphics library)

GNU Ncurses is a programming library that provides apis that allow programmers to write textual user interfaces in a terminal independent way.

Using Ubuntu as an example, you can run the following command on a terminal:

$ sudo apt-get install libncurses5-dev 
Copy the code

Or through the source package decompression, compilation, installation; (Source package version download address: ftp.gnu.org/pub/gnu/ncu…

$wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz $tar XZF ncurses - 5.7. Tar. Gz $CD ncurses - 5.7 $. / configure  --prefix=/opt/ncurses $ make && make install $ ls -la /opt/ncursesCopy the code

Or you can install it using Git.

# git clone https://github.com/jmoon018/PacVim.git is clone to 'PacVim'... Remote: Enumerating Objects in Flue: 627, done. Remote: Total 627 (Delta 0), In Flue 0 (delta 0), Pack-Flue 627 100% (627/627) and 3.20 MiB | KiB/s, 22.00. Working with delta: 100% (341/341), Dockerfile gifs Makefile maps readme.md SRC # make install g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread -c -o src/avatar.o src/avatar.cpp g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread -c -o src/ghost1.o src/ghost1.cpp g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread -c -o src/helperFns.o src/helperFns.cpp g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread -c -o src/game.o src/game.cpp g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread -c -o src/globals.o src/globals.cpp g++ -std=c++11 -DMAPS_LOCATION='"/usr/local/share/pacvim-maps"' -pthread src/avatar.o src/ghost1.o src/helperFns.o src/game.o src/globals.o -o pacvim -lncurses -lpthread install -Dm755 pacvim /usr/local/bin/pacvim install -d /usr/local/share/pacvim-maps install -t /usr/local/share/pacvim-maps maps/map0.txt maps/map1.txt maps/map5.txt maps/map7.txt maps/map2.txt maps/map9.txt maps/map6.txt maps/map3.txt maps/map4.txt maps/map8.txtCopy the code

3.3 using a Docker

Docker image can also be used to run, directly execute the following code, you can start PacVim game.

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

LEVEL_NUMBER Ranges from 0 to 9. The higher the number, the more difficult it is.

MODE The value can be Nor H. N indicates Normal difficulty. H means Hard.

Four, PacVim how to play?

If you have PacVim installed in Ubuntu, you can directly run the following command to start the game.

$ pacvim 8 n
Copy the code

The goal of PacVim is similar to that of PacMan in that the PacVim game must be started under the terminal and all characters must be run on the screen while avoiding the red G barrier.

4.1 PacVim has two special obstacles

1, can not enter the walls (yellow), you must use vim command to skip them.

2, if you step on the tilde character (cyan ~), you will lose!

PacVim map file

/usr/local/share/ PacVim -maps = /usr/local/share/ PacVim -maps = /usr/local/share/ PacVim -maps = /usr/local/share

Each text file name is in map#.txt format, where # represents a number, such as 0, 1, 9, 14, etc. And make sure you change NUM_OF_LEVELS in globals.cpp, otherwise you will not be able to load a new map equal to the highest map number.

In map text files, walls are represented by ampersand # and tilde by ~, and the boundaries of the map must be limited and closed.

Vi. Schematic diagram of PacVim game

Winning conditions: Use the vim command to move the cursor above the letter and highlight it. After all the letters are displayed, you will win and enter the next level.

Failure condition: If you touch an obstacle (red G) or tilde character, you will fail. If your life is less than 0, you lose the entire game.

7. PacVim Project address

If you are interested in this project and want to consolidate your knowledge of Vim through this project, you can try it.

Github address: github.com/jmoon018/Pa…

In this paper, to the end.


Original is not easy, if you think this article is useful to you, please kindly like, comment or forward this article, because this will be my power to output more high-quality articles, thank you!

By the way, please give me some free attention! In case you get lost and don’t find me next time.

See you next time!