Vim

Today we'll talk about vim, the ubiquitous keyboard-driven highly customizable CLI text editor.

Featured image

Today we’ll talk about vim, the ubiquitous keyboard-driven highly customizable CLI text editor, first released in 1991 and, at the time of posting, it is currently at version 8.1. By the way, this post was written using 100% vim. (Tag changers’ note: I added the tags, so not anymore.)

Why use vim

As I said earlier, vim is a modal editor. That means you don’t need to use the mouse while editing in vim at all. The bindings are all close (at least in an qwerty keyboard), so vim ends up being ergonomic as hell. Also, as it’s slogan says, vim is ubiquitous. It is pre-installed on most *nix distributions. That means you can use vim at work, at home, and even at the server.

However, I think vim’s slogan should be “vim: once in, never out. Seriously.” image Lots of people joke about the sequence of characters you have to type to leave vim:

But seriously, I haven’t met anyone who started using vim then stopped because they started disliking it.

Modes

Also, another powerful feature in vim are the modes. You have lots of modes in vim, but the ones people use the most are:

This may seem strange at first, but it really pays off once you’re used to it.

How to start using vim?

If you use linux, vim is almost certainly already installed in your machine. If not, you are using a more bare-bones distribution and you know how to install it. If you use macOS or Windows, follow a tutorial on another site on how to install vim.

vim is hard to get used to. You have modes, you don’t use the mouse, you have weird controls. But don’t worry, it’s like that for everyone. image To start, we’ll talk about how to move your little cursor. you can use the arrow keys or HJKL.

image vim uses hjkl mainly because of historical reasons. (Picture of an ADM-3A computer)

You should use hjkl because it is closer to the rest of your keyboard, and so you don’t need to move your hand too much to type other commands. And since vim is all about efficiency, you should do the change. (I’ll explain to you how to disable arrow keys soon; be patient.)

To learn more vim commands, run vimtutor in your terminal. It’ll guide you through the dark arts of vim. And here is an awesome vim cheatsheet.

.vimrc

This is where the customization part comes in.

~/.vimrc is your vim configuration file. Here, you can change vim’s bindings, add commands, change vim’s interface, and many more things. .vimrc uses vimscript, a language hated by many, but it still is 200 times better than vim’s rival, emacs, ((((who uses elisp for configuration)))).

For example, a binding I made and that I use a lot, is one that jumps to the start of a line, and inserts a comment (//) there.

This is the binding I’m talking about: nno c ^i//<Space><ESC>^ Woah! That’s a lot of things for one line. Let’s break it down.

So, as I said earlier, you can paste this in your .vimrc to disable the arrow keys.

There are more things you can put in your vimrc. If you are curious, here is a link to my vimrc. You’ll require Vundle (a vim plugin manager) to use it, though.

And this is how my vim looks like. For more cool things to put on your vimrc, check out the vim wiki.


Written by Alice