Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

Can you do something with Vim? – Ehm, actually, yeah, why not! I’d better not tell you where I got that enlightening moment. But I get this question over and over again, so here I am or better said, here is your Vim beginners course.

But why?

Don’t only use grumpy bearded men like me Vim? Isn’t Vim an ancient piece of software? Isn’t Vim only available on the command line? Aren’t there better things like Sublime, Atom or IntelliJ?

Well, no, no, probably no, yes.

You don’t have actually to use Vim to profit from it. The power of Vim comes directly from the art of using it. Or better said, harnessing the power of Vim.

I don’t use Vim that much in the past year. But I use extensions or emulator for Vim in Atom, PyCharm, PHPStorm and any other editor I get my hands on.

And that’s the point. You can use a so called emulator in nearly any idea and still use the power of Vim combined with the delicate parts of you favorite IDE.

But for the tutorial, I will use Vim in the terminal, so stick with me. In a later part, I will give you my recommendations for different editors and IDEs.

Installation

Come on; I won’t spend too much time here.

If you are on Mac as I do, just get homebrew and type:

brew install vim

On Linux use your package manager, for example on Debian or Ubuntu use apt:

apt install vim

Windows, I don’t know, use the Linux Subsystem or just google 😉

First try

Are you ready to change your whole life? Ok, maybe the way you write code. Type vim hit Enter.

Congrats, you opened Vim for the first time. If you now start typing, you will recognize, it doesn’t act like a regular editor, where you just type on, and text appears.

Now type i and you should note that the bottom bar changes.

This means you are in INSERT MODE. Now you can type like in every other editor. When you are finished writing your novel, we can save our work.

For that, we have to leave the INSERT MODE and this works by pressing the ESC key. Now the bottom line disappears, and we are back in command mode.

To save your file you need to start the command mode which is entered by typing a colon followed by a command. In this case, type :w novel.txt , which results in saving the file. Now you also can quit vim by entering :q.

But here comes the absolute hammer secret trick. Ok, it isn’t that secret, and you will get problems because you will try to use it everywhere, in emails, browser and maybe even on paperwork: You can easily combine commands in Vim, and here is the most popular one, try to combine write and quit like this :wq novel.txt. So basically you are saving your file and quitting Vim at the same time. Ain’t that impressive?

Edit Files

Ok, now you know how to write a new file. Only for the sense of completion, I have to tell you how to edit existing files. It is as easy as with every bash command. Just type on vim novel.txt the command line, and you are in vim, editing novel.txt.


Like what you see? Follow me on Twitter to stay up to date:


What else?

Easy dude. You have learned a few things today about Vim, which is amazing! In the next chapters of this tutorial, I will show you how to navigate through Vim and how to train yourself to be more productive with Vim. A lot to learn!

Follow me on Social Media, YouTube or my Newsletter to stay up to date with the tutorial.


There are no comments.

Leave a Reply