DEV Community

Cover image for Vim? Vim who?
iAmGjert
iAmGjert

Posted on • Updated on

Vim? Vim who?

Preface

There are a plethora of terminal editors out there to choose from and if you'd like to explore a few more thoroughly I'd recommend checking out this list published last year by Aaron Kili. At the end of the day most editors accomplish he same goal and the one you use is up to personal preference. I am still learning everyday and by tomorrow my opinion could be completely different!

Over the course of the last few weeks the projects I've worked on have had me editing files directly in the terminal. At first, the terminal editors I used was dictated by what tutorial video I was watching and whether or not they had me download some editor. Now, when I need to edit a file directly in the terminal I almost always use Vim. Vim is available on any Linux machine and is a powerful text editor. I've taken a little time to learn the basics of Vim to quickly navigate and edit specific lines in my files. Even knowing just the simplest of commands that the Vim editor has to offer has made it a tool that I use daily as a developer.

code snippet in VIM editor

History of the Vim editor

Interestingly, Vim wasn't always intended to replace vi. Vim started out as "Vi IMitation" on systems as early as "Amiga", a personal computer introduced in 1985. Vi was originally written way back in 1976 by a programmer named Bill Joy, but since around 1992 when Vim was first released it has been almost completely replaced. Over time Vim was renamed to "Vi IMproved" as it was ported throughout many other platforms. Vim's original author and, according to this Wiki article, "benevolent dictator for life of Vim" is Bram Moolenaar. (pictured below)

the dictator himself

Learning all that Vim has to offer could take a long time, but could be highly beneficial as a programmer if you've got the time. There are hundreds of commands and it's highly customizable. It has a shallow memory fingerprint and it's commands can perform highly complex tasks with just a few keystrokes. With just a few basic tutorials I was surprised how easily I could manipulate text documents easily in environments that I wasn't able to access a UI. I can also rest well knowing that most all machines I access will have the Vim editor pre-installed and I can use the commands I've learned on these systems.

Most useful commands

Some of the commands I find myself using the most are gg and G. These commands bring you to the first and last line of the document respectively. Traversing the vim terminal may seem tedious at first, but commands like 5gg or 5G will bring you directly to line 5. Since by default you can't just click where you'd like your cursor to be memorizing some of the commands to move around the terminal will speed up your hacking time. If you lose your cursor zz will center it on the screen. Pressing i puts you into 'insert' mode so you can type at the position where you cursor was, and I does the same, but at the start of the line your cursor is on.

Enable mouse in vim

Vim actually does have mouse support, you just have to know how to enable it! navigate to your .vimrc file and add a line. It's that simple! There are a few different options on what line you can add to give your mouse functionality in the different modes that vim has. The commands below enable special use cases as you see fit:

a = all
n = normal mode
v = visual mode
i = insert mode
Enter fullscreen mode Exit fullscreen mode

There are plenty of other commands you can enable if you want. To view them all use the help command or click this link to view a command cheat sheet.

Top comments (0)