Back to Posts

A Favorite Thing About Vim

I've been a vim user for around one year and six months and it's been an awesome journey. It was a pretty tough one as well. I'm gonna try to explain why I love it so much and you might just give it a try.

Talk to the editor

I was always confused before when some seasoned devs told me:

Vim is awesome because you can talk to it and it will do exactly that.

I really did not understand it. How can you tell your editor what to do?

I was using Sublime at the time and really did not care too much. Then I was being mentored for a while by a pretty badass senior and he was a hardcore vim user. The thing was we were in different parts of the world and we had to do remote pairing and the best tools for remote pairing are usually tmux + vim so I went with it. It started with us pairing for around a month just to learn to use vim and tmux together and after around 4 weeks I was ready to use it day to day. I got gianz in productivity but the most amazing thing was that I could actually talk to my editor.

There are things in vim called commands and they go something like this:

d - Delete  
c - Change  
y - Yank ( copy )  
v - Visually select  
<, > - indent  
= - reformat

And there are also things called text objects which go something like this ( this is not an entire list ):

iw - inner word  
aw - around word  
ip - inner paragraph  
ap - around paragraph  
i) - inner parenthesis  

Now lets have a code example on how we can apply these:

def awesome_method  
 5.times {
  puts 'Hello there!'

If we do diw and we are on puts it will delete inner word which in this case is puts.

You can use all sorts of combos of these two and this is just a start. Hope you can see how powerful talking to your editor actually is. If you really get good you will not even need visual mode in vim ;)

That's all for today folks! Hope you liked it :)

Software engineer that loves business side of things as well. Also lifts a lot of weights.

Read Next

My two cents on React