May 16, 2020 • ☕️ 5 min read
Wow, it has been a long time since I wrote anything on this blog. To be honest the last year was a bit too much. And surprisingly this year is no better.
Anyways, just like everyone, I am using this quarantine to skill up and make good use of it. I am picking up things I always wanted to do and one of those things was learning Vim. I have seen a lot of tutorials with people using Vim which mostly confused me. Like why would you want to write in a command line tool. WITHOUT A MOUSE??? Are you kidding me. How are you even going to navigate around? That doesn’t even make sense!
This is not a tutorial, rather my story of deciding to use Vim as my primary text editing tool.
Well, turns out, if you start spending 10+ hours writing code everyday, you realise that using a mouse is actually slower. Like really slow. Hear me out. If you use VSCode/Any other editor it has some basic issues which become annoying.
nano
is not present. But Vim is always on each one of the servers. So yeah it makes sense to invest time in Vim.But what makes Vim so good that I want to learn it? Well I am still to experience the benefits myself as I have literally just started. But here are some good things I heard about it:
.vimrc
file and BOOM! you feel right at home.0.25s
and if you are not a touch typer (I am not) you are even slower when you come back to the home rows because you have to position your hands back to where they were. But if you use h
, j
, k
and l
to navigate around, it really becomes easy to just keep your hands at one place and enjoy typing!Glad you are sold. Start by installing Vim (It should already be installed on most linux based OS) you can find tons of tutorials by just Googling Install Vim on X operating system
Okay, now that we have Vim installed, the first thing I did was complete the vimtutor
file. It is a text file which gives you an idea about using Vim by actually asking you to editing the file while you are reading it. Felt like an episode of Bandersnatch to me. It is okay if you have to read it more than one to get the hang of commands.
Most of the commands are pretty intuitive, you want to quit? :q
, you want to save(write)? :w
Want to move a word forward? just press w
. i
puts you in insert mode. ciw
changes inside word, (d actually waits for a motion before deleting anything. Like diw for delete inner word, this will delete a word when your caret is on any letter of the word). You actually don’t have to memorise the commands, after sometime, they just flow naturally, like you are speaking… in Vim’s language.d
deletes the character you are at
Okay, so one more thing. There is a thing called .vimrc
I talked about, that is the configuration file for Vim. Which means any modifications/plugins you add to .vimrc
configurations can and will be persisted across different Vim sessions. One benefit is that these can be persisted across different machines as well. Just push your .vimrc
file to Github/any server from where you can download later. On the new server just download your .vimrc
file, and you are in your familiar setup on the new machine as well, with all the syntax highlighting and all your plugins.
There are a lot of Vim plugins and a lot more .vimrc
files available on the web. A quick search on Github returns around 19,519 repository results. This is just mind-blowing and you will never be able to go through all those .vimrc
files.
The approach I am taking on is to create my own .vimrc
file from scratch by adding plugins and settings on need basis rather than blindly copying/using someone else’s .vimrc
file. I am still looking at other people’s vimrc’s and adding bits and pieces here and there but only after understanding what it does and is it actually adding any value to my flow.
The ones I have added for now are Vundler, NerdTree and Enable Line Numbers! :D
Anyways for those interested, I am adding my .vimrc
on Github hoping it would motivate someone to use Vim in 2020 and beyond (If we make it past 2020).
Back to Blog list • Edit on GitHub • Discuss on Twitter
Personal blog by Anand Raj.
I learn by breaking stuff (mostly code).