Skip to content

A short guide to vim

New Course Coming Soon:

Get Really Good at Git

vim is a very popular file editor, especially among programmers. It’s actively developed and frequently updated, and there’s a very big community around it. There’s even a Vim conference!

vi in modern systems is just an alias to vim, which means vi improved.

You start it by running vi on the command line.

You can specify a filename at invocation time to edit that specific file:

vi test.txt

You have to know that Vim has 2 main modes:

When you start the editor, you are in command mode. You can’t enter text like you expect from a GUI-based editor. You have to enter insert mode. You can do this by pressing the i key. Once you do so, the -- INSERT -- word appear at the bottom of the editor:

Now you can start typing and filling the screen with the file contents:

You can move around the file with the arrow keys, or using the h - j - k - l keys. h-l for left-right, j-k for down-up.

Once you are done editing you can press the esc key to exit insert mode, and go back to command mode.

At this point you can navigate the file, but you can’t add content to it (and be careful which keys you press as they might be commands).

One thing you might want to do now is saving the file. You can do so by pressing : (colon), then w.

You can save and quit pressing : then w and q: :wq

You can quit without saving, pressing : then q and !: :q!

You can undo and edit by going to command mode and pressing u. You can redo (cancel an undo) by pressing ctrl-r.

Those are the basics of working with Vim. From here starts a rabbit hole we can’t go into in this little introduction.

I will only mention those commands that will get you started editing with Vim:

To find out more about Vim I can recommend the Vim FAQ and especially running the vimtutor command, which should already be installed in your system and will greatly help you start your vim explorations.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!

Here is how can I help you: