One year at the helm of Vim

One year ago I started using an old text editor called Vim. I’m happy to say that I’m still sticking with it. I’m now very comfortable with VIM and more empowered translate Ideas into working solutions.

In this year I’ve become accustomed to working the terminal, embracing the VIM way while realizing that that coding is just one part of the challenge.

Not your IDE

Transitioning from PhpStorm, I desired the same IDE-like features in VIM. After multiple config changes and plugin tests, I had an epiphany: VIM is an editor and that’s it. It is one of the tools in your shed. You combine it with other command line tools to empower an efficient workflow. I believe this is key to making the most of VIM.

With this also comes the realization that tabs, though it looks nice, is not the most efficient way to switch between files. A short list of buffers is the way to go. I always close the editor when I’m done with a task and re-open it for the next one. This ensures that all current buffers are closed and I can start with a low memory footprint every time.

Who Uses Caps Lock anyways?

A common thing in the VIM community is to modifying CAPS LOCK key. As a programmer you don’t really use CAPS LOCK, you will mainly use SHIFT for upper case. Some VIM users take CAPS LOCK as an extra escape and others as another CTRL. I have chosen CTRL as many commands require this button, which is awkwardly placed on my Mac Keyboard.

Hard Times are good for you

One of the first things I embraced was Hard mode. With this activated, VIM disables the arrow keys for navigation and stops you from jumping up more than one line at a time (using h,j,k,l). This pushed me to use other movements. I would argue this to be a must for any VIM beginner. You simply don’t understand how powerful these other movements are until you get used to them. It is excruciating in the begging but the benefits far outweigh the cost. After some time I turned this mode off and used “Hard Time” instead, which works the same but is a little more forgiving.

Undo and try again

Practicing all the time is critical to mastering VIM. By practicing, I mean on the Job training, while you’re working and editing. If you find that you did something and it took too long, or you remember a faster way to do it. Stop, undo and redo it in a more efficient way. This more effecient way becomes the default going forward and you save yourself many many seconds in future. Adding all these ups definitely increases your editing speed.

Another note on this is not to worry about the time it takes to add a shortcut to your config files. Every second you shave off your workflow gets multiplied by how many times you have to repeat the same editing tasks and this is a major win!

Trying not to use so many plugins

The VIM plugin echosstem makes it much easier for newbies feel comfortable and for masters to craft the exact experience they desire.

I discovered that plugins can get in the way just as much as they can help. You need to make sure you really need a plugin before installing it. What I do is try to I try to get away without a plugin to see if I cant modify my VIMRC to do the same thing a plugin does. As a last resort, I’ll use a plugin.

Onwards and Upwards?

I would encourage everyone to learn VIM, but honestly but I understand that not every workflow will benefit from being close to the Command Line.

You are not in a mutually exclusive relationship with your editor. Use the one that’s better for the task at hand. I occasionally jump into Atom ( forgive me VS Code champs ). As Daniel Miessler puts it, the content matters more than the editor.

Let’s not allow our tools to get in the way. These are our weapons of mass impact and ultimately only a means to an end.

So I tried an editor called VIM

But Why?

I’ve tried many editors, but with each of them, I found a few things I didn’t like. I always knew about VIM and I knew how to exit vim ( link for the pun ), but never thought it serious enough to work in until I saw how magically other people were using it.  That’s when I started thinking about trying it out. I’ve been using it for little over a month now and this week marks the end fo the first week of using it at work.

First steps

I started googling around for the best guides on where to start. This led me to the book called Practical Vim. This is the only book a beginner needs. It covers all the most important things you need to know. It also gives you a great foundation from which to grow your very own .vimrc.

The IDE rabbit hole

On making the switch I realised that I’m seriously going to miss PhpStorm if I don’t figure out how to use VIM effectively.

Enter plugins, the magical stuff you drop in to give VIM super powers. Then enter plugin managers. The first one I tried was one called Pathogen. It worked like a charm, but then I realised I needed to add git submodules for each new plugin. The thing with vim is that you want to version control all the things so you can easily take your environment with you when switching machines. So I’ve got a plugin manager and I have that under version control, but adding so many submodules was not working out especially after the 5th plugin. I eventually switch to something that only keeps a few strings in your config called Plug.

Side note, if you want the best way to keep your dotfiles on GH see this: https://news.ycombinator.com/iterThem?id=11070797

Now that you have all the vim niceness you’ll soon realise you need a better way to manage the terminal. You need tabs, panes or some sort of split window system. There are many, many options. I looked at a few and decided on Tmux, the main reason for doing so is that it is terminal based and works on many platforms. I’m totally happy with this.

Mastery

I hear that people use this editor for years and still learn new things. I’ve seen from using it for a month that you’re alway tweaking your workflow. There’s always something new that you can add or change in your .vimrc.  The best thing about VIM is that no two people use it in the same way. It should become an extension of your thoughts so that the editor gets out of your way. I’m not there yet, but I can see how my muscle memory is forming day by day.

Portability

I can now freely move between machines and take my editor with me.  I has dot fileshttps://github.com/dwainm/dotfiles

My Struggles

In PhpStorm, Cmd + L gives you this magic wand that fixes code indentation a common coding standard issues. I miss it so much. I need to figure out how to do this in VIM.

Another struggle I have now is that I’m constantly pressing the wrong keys. This will probably get better with time. I found that I can use the numbers keys at the top fo the keyboard because I don’t know where keys 4-7 is in the dark. I’ll have to learn this.

Lastly I the struggle is just to adjust to a new workflow. One where I’m constantly tweaking things to better my productivity. I believe this will pay off over time and I’m excited about my new vim adventure.