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.
Nevertheless I don't use it anymore.
Firsty, I want to tell you my story with Vim and PhpStorm in order for you to understand how you can switch between the two.
Then I will compare the two and underline what Vim brings on the table.
Vim: the hate before the love
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?
At that point I went in a crusade. 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 leaving for new and crazy adventures.
I wanted at the same moment to 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.
Quickly 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, too afraid that it would put down my productivity.
I stopped using PhpStorm in two weeks.
Vim vs PhpStorm
Vim on the left, PhpStorm on the right. The clash.
Here we are finally: the comparison between PhpStorm and Vim. Do you want to replace PhpStorm with something more powerful and versatile? Do you want to be sure that Vim is the good choice?
I won't cover here how to do a PHP IDE out of Vim since I wrote another article on the topic.
Following all the answers to (almost) every questions!
Who's in charge: you or your IDE?
An IDE is obviously very important for developers. It's 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 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 by typing two words. Not even command lines. Words.
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.
PhpStorm only allow you to 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?
Even better: the plugins can be activated depending of the file type you are editing. You will never have the Ruby autocompletion while editing a PHP file. Sweet, isn't it?
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's 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. And he doesn't do well.
Even on my very lightweight arch linux / i3 system (running on very good hardware), everything suddenly slow down. Welcome to the Matrix, or the stop motion applied to computing!
Sometimes I like to open two projects at the same time to get some configuration or code 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 a feather. So light! You can run multiple instances of it if you want, your computer won't slow down.
Try to use Vim, then come back to PhpStorm and you will see what I'm talking about.
Your hardware will love 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 Google. Yes, by yourself only!
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 like an old friend. 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 till the letter
In comparison, PhpStorm is boring. To me 70% of the tools are useless (by adding a useless graphical interface on top on very efficient terminal tools) and the editor itself use the mouse extensively, like 99% of the editors in the world.
If shortcuts were invented, it's because it is more convenient and fast to use the keyboard to execute actions. Vim definitely nailed that.
To be honest with Vim I always have the impression I'm 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's 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'm 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 a good cherry on the cake. Especially 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 allow you to do more than PhpStorm
Here some examples what you can do with Vim but not with 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 php.net with a keystroke when you are on a method / function / whatever to see its definition. Very 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.
The possibilities are infinite.
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.
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. It works like a charm.
I want to be in love with Vim! Tell me how!
First you need to be motivated and learn how to properly use it. It is less complicated than you think.
You work on Linux or macOs? Try Vimtutor!
First, go to your terminal.
vimtutor. Press enter.
Here we are!
Vimtutor comes with a lot of linux-based distribution. It is a 15 minutes tutorial for you to learn Vim's basics. After that, you can begin to use Vim for whatever need you have.
15 minutes! Who said that Vim was complicated?
You don't believe me? Just try it!
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.
Be careful though. It is tempting to copy entire configuration from others but you will be lost very quickly. 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 the plugin is doing. Take your time. Read the plugin documentations. In short: do everything with Vim you should do as a developer. Analyzing, acting step by step and see if it suits your need.
Vim 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!
Vim is a winner! But... do I miss PhpStorm?
I hope you are now ready to replace PhpStorm by Vim!
Now let be honest with one another:
Yes PhpStorm has some tool that 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 slightly better. I really, really thought I would miss it... but no. Not even one second.
PhpStorm gives you access to a powerful local file history. Vim doesn't. However you can save your undo history for whatever file you're editing in Vim. The editor will do that for you transparently. It means that you can undo whatever modifications in whatever files you want, even after one week you did them.
You need to configure much more Vim to have a powerful PHP IDE. It means as well that you can personalize it the way you want. An IDE should suits your need, not imposing them!
After three weeks using Vim as my PHP IDE, I tried to reinstall PhpStorm. I used it for ten minutes before coming back to Vim.
I won't get back to you, PhpStorm. Never. I am a faithful man to Vim now.