How did I replace PhpStorm by Vim in my heart: the true story

Vim

I wrote an article some time ago in order to give you the most useful tips and tricks for my favorite php IDE, PhpStorm.

Well, sorry PhpStorm, you were my favorite IDE. Things changed. I love another one now.

Its name is Vim.

Are you confused? Are you yelling "why"? What happened between PhpStorm and me? Why a PHP developer would use this... old smelly thing called Vim?

I was happy with PhpStorm. We had a productive relationship. Its basic rules was simple, as simple as many text editor in the computing world. You use a mouse, you click where you want to change or add something, somewhere. The basic editor. We are all used to that from the beginning of times!

I loved the auto completion with PhpStorm! I loved the fact that you could find easily a peculiar file even within a massive codebase. I loved its stability. I liked the snippets. I loved its numerous options to refactor, generate getter / properties / methods using one or two handy shortcuts.

So, how Vim replaced PhpStorm in my heart?

The hate before the love

Vim Hate, love and whatnot.

It was a newcomer who first showed me Vim configured for PHP development.

He was a developer hired in my company. I was curious, I began to look what IDE he was using, expecting that, like every good PHP developer, he was using the holy PhpStorm.

"I don't use PhpStorm" said the newcomer. "Vim is way better!".

Vim! This dinosaur! This 70s boring terminal editor! So complex nobody knows how to use it, except the perfect nerd without life / girlfriend / whatever real things!
How can he compares the wonderful shiny PhpStorm with this relic?

Obviously I tried to show him how a good IDE with tons of features could suit his needs even better than this... Vim thing! Without success, I let him at his mistake, sad he couldn't see the Truth as I was.

Time past. I began to understand that this newcomer was a very interested and knowledgeable developer. It astonished me. How can he be that good and use Vim?

Quickly we began to work on the same project and we formed a tandem.

The time of mockeries

I mocked my work tandem. A lot. He was persisting in his mistake to use Vim and I couldn't do anything to dissuade him.

I mocked the austerity of Vim's interface. I mocked the fact that he had to configure everything. I mocked that this configuration (in my opinion) was always broken. Who wants to code with a broken IDE? It was pure nonsense.

With hindsight I may have been a bit jealous. He mastered a tool full of shortcuts in order to use the mouse as less as he can, and, without knowing it, I envied him.
I envied him because I didn't feel capable to learn how to use Vim in a reasonable amount of time.

More and more my contempt toward Vim let place to curiosity.

PhpStorm and me: the breakdown

My attraction and curiosity toward Vim kept growing and growing.

The hate metamorphosis in love when I decided two things:

  • Quitting the company I was working in
  • Learning to type like true crazy typists.

I wasn't happy at that time till I really decided to quit the company I was working for. My decision opened new horizons and a true desire to learn more about everything.
Moreover I wanted to learn a maximum from my fellow work tandem before going for new adventures.

I wanted at the same moment get rid of my very bad habit of typing with two or three fingers. I wanted to use typists techniques: using the home row keys and my ten fingers.

I began to understand the power of this typing method. You feel definitely faster and more in control of your computer. A very cool sensation!
I knew as well that Vim was designed for this type of typing. Due to the pleasure I had with my new typing techniques, I slowly decided to give Vim a chance.

More and more I asked tips to my tandem to learn it. At first I just wanted to use it for editing configuration or text files, not for actual coding.
I stopped using PhpStorm very, very quickly.

Why Vim is better than PhpStorm

Vim-vs-PhpStorm Vim on the left, PhpStorm on the right. The clash.

Who is in charge: you or your IDE?

An IDE is obviously very important for developers. It is the tool which helps us doing what we like: coding. It simplifies our life, automatize all those boring stuff you repeat over and over again.

Therefore your IDE should reflect the way you are coding. It should give you the choice for you to do what you want, the way you want.

PhpStorm doesn't really give you a lot of choices: it is a bunch of tools and you have to stick with them.
I never used 70% of it. I know a lot of shortcuts and I am able to navigates in the panels without even using the mouse. However I never used the composer tools / terminal / git GUI / database interface thingy integrated in PhpStorm.

I couldn't configure that. I couldn't choose to install what I wanted, what I needed. PhpStorm was choosing for me.

The result? A lot of panels and notifications popping, a lot of visual noise which was totally useless for me. Perfect to lose your focus.

Some may argue that PhpStorm is really configurable compared to other IDE. It is nothing compared to Vim.

Vim has a great community who develop a LOT of plugin. Nowadays you can install them and get rid of them in two command lines.
You can choose exactly what you want and what suits you. You can even modify it easily and extends it. Vim can be bent following your wishes.

You are the master.

With PhpStorm you can only code in... php

Another point which was bothering me for a long time. Of course you can use it to write HTML / CSS but you won't have a lot of tools for those. And what about Go you want to learn so hardly? Ruby? Basic?

Vim is an editor, not an IDE, but you can make an IDE out of it for every language you want. Right now, I have very good auto completion systems for PHP, JavaScript, Go and Ruby.
Even better: the plugins can be activated depending of the file type you are editing. You will never have the Ruby autocompletion while editing some PHP.

I have tons of plugin for refactoring, creating snippets and so on. No need to change IDE and get use to different interfaces. With Vim I can switch from one language to another transparently. Believe me, it is awesome.

When I open Vim, everything I need is there for whatever language.

Vim is light

Each time I open PhpStorm I have the impress that my computer is running a marathon. Even on my very lightweight arch linux / i3 system, everything suddenly slow down. Welcome to the Matrix, or the stop motion applied to computing!

Sometimes I like to open two projects in the same time to get some configuration from one to another. Sometimes I want to open even more if I need to work with multiple micro services.

With PhpStorm... you know what I am talking about. Your memory scream, your CPU burns some calories, your vans consume more electricity than your fridge.

In comparison, Vim is so light! You can throw ten instances of it if you want, your computer won't feel it.
Try to use Vim, then come back to PhpStorm and you will see how much Jetbrain's IDE will slow down your computer.

Your hardware like Vim.

Vim is fun!

This is something I didn't imagine: Vim is really fun to use.

It is time to precise a bit how to use it. There are many modes in this editor. The Normal mode is for executing commands (delete words, lines, paragraphs and a lot of others). The insert mode is there for you to concretely write.
A simple separation of concern and, believe me, it is brilliant!

This is Vim: you can learn to be productive with it in a couple of minutes (I promise). Get used to it may take a bit more time and then you will learn new stuff all your life. The whole editor feel so logical that you will come up with new way to do things without even ask to Google.

Like: "Maybe if I press those keys it will do that eventually. Yes it does! I am a genius!"

Indeed, Vim is so sweet you can talk to it! For example: you want to delete all characters from your cursor till the coma? In Normal mode, type dt,, means delete till the coma. You can do as well dtf, which delete everything till the letter f. Magical!

In comparison, PhpStorm is boring. To me 70% of the tools are useless and the editor itself use the mouse extensively, like 99% of the editors in the world.
If shortcuts were invented, it is because it is more convenient and fast to use the keyboard... and have fun with it! Vim definitely nailed that.

To be honest I always have the impression I am some sort of a hacker doing crazy things with my keyboard in three different Vim instances. Of course I am just writing down my shopping list but... who cares?

I am always happy when I discover a new shortcut or way to do thing even more easily.

PhpStorm cost money

PhpStorm is not free, far from it. Even if it is pretty affordable (around 100euro), you pay only for one year. Welcome to the era of renting instead of acquiring...

If you want a Go, Ruby or whatever IDE for whatever language, you have to pay. Again.

Vim is free, available on everything (linux, windows, mac).

You may be faster with Vim...

Honestly I don't care that much if I am faster with it. To me being fast doesn't mean being a good developer. Our brain is more valuable than our typing speed.

However you will feel fast and precise, which is always nice. Specially when you have to move a bunch of classes and renaming namespaces again and again. You know, what we call refactoring: Vim can simplify that and many other things.

Vim can do more than PhpStorm

  • You can search through open tabs ("buffers" in Vim), files and entire projects very fast with the fzf plugin. Even faster than with PhpStorm.

  • You can go directly to the PHP documentation website with a shortcut when you are on a method / function / whatever. Pretty handy!

  • You can run Vim with a GUI or in the terminal. Doing the last will open a lot of possibility like the winning combo zsh / tmux / Vim. You will have a lot of flexibility and fun with those tools, I can guarantee it!

  • Since a ton of plugins exist for Vim you can extend the possibilities as you wish. You can even write little functions which extend / alter whatever you want.

A great community

A lot of people use Vim and will be happy to help you. You have access to a lot of plugins for every development language you dream of.

Some will argue (as I did) than Vim is too old. It is a strength! Think about it: what software is more stable than the one tested for decades?

It is very stable indeed, thanks to the community. If you are stuck, if you have a problem, you have tons of resources where you can found the solution.

Neovim!

Vim is old and maintained for a long long time, which means as well that its codebase is (apparently) not-that-goodish.
That is why a bunch of people rewrote the whole editor. It's called Neovim and it's compatible with every Vim plugin available.

Even if it's still in beta I didn't have any issues with it.

I want to be in love with Vim! Tell me how!

You have Linux? Try Vimtutor!

Vimtutor comes with a lot of linux distribution. It is a 15 minutes tutorial for you to learn Vim's basics. After that, you can begin to use it.

15 minutes! Who said that Vim was complicated?

You don't believe me? Simply type vimtutor in your terminal.

Get inspired by other configurations

Vim alone is a bit... too weak functionality wise. You need plugins, and the best way to find what you need is to look to configurations from other developers.
They are most of the time hosted publicly on github/bitbucket, like mine.

Be careful though. It is tempting to copy entire configuration from others but you will be lost very quickly in another world. Vim needs to be personalized. It can suits you if you take the time to tune it depending on your needs.

Take the configurations available on the web as inspirations. Copy them little by little, plugin by plugin. Test it, try to understand what your are doing. Take your time. Read the plugin documentations. In short: do everything with Vim you should do as a developer...

Cheat sheet

My advice for the beginning: having a cheat sheet printed you can refer to. You can find a lot of them everywhere.

It will help you memorising the basics of Vim and experimenting to be more effective and have even more fun!

In conclusion: do I miss PhpStorm?

Now let be honest with one another:

  • Yes PhpStorm has some tool than Vim ecosystem doesn't. The search plugin I use for example has less options than PhpStorm's search... but seriously who use those options and how often?

  • In PhpStorm the auto completion is better and faster. I really, really thought I would miss it... but no. Not at all. You simply don't need the auto completion as much as you think.

  • PhpStorm gives you access to a local file history. Vim doesn't. However you can save your undo history per file your editing in Vim. The editor will do that for you transparently. It means that you can undo whatever modifications in whatever files you want, whenever you want.
    You want to undo somes changes you did last week? It is possible... and it goes even beyond that.

  • There are less thing to configure in PhpStorm to have a functional PHP IDE. It means as well that you can’t personalize it the way you want. An IDE should suits your need, not imposing them!

As you can see I could never come back to PhpStorm. I tried to reinstall it. I used it for ten minutes before coming back to Vim.

I won't get back to you, PhpStorm. I am a faithful man to Vim now.

Vim