DEV Community

Abolarin Olanrewaju Olabode
Abolarin Olanrewaju Olabode

Posted on

On learning Vim.

Welcome to Vi

The first thing I found was that to learn Vim, I needed to accept it for the weird older gentleman that it is, It is different than every text-editing tool I have ever used on a fundamental level. Most people think their problem with Vim is the terminal, but even in Gvim or even emulation mode for Vs Code or <insert fancy IntelliJ product/> they would still have the same fundamental issue. Vim has a language for text editing and to use Vim you must have at least basic familiarity with the language mastery is not required, in fact, you don't need to unlearn other languages like the use of a mouse or arrow keys you just have to learn this language also else you would hit a wall with every little thing till your head gives way or your ego does and you install Vs Code again.


What mode are we in?

During the workshop I gave about Vim at Omniswift my colleagues all asked, "how do I type what you just? It's not responding" and I knew to provide an answer I would have to ask "What mode are you in?"
One of the first things to come to terms within Vim is the fact that Vim is a Modal editor. This modal editing thing is why among many things it allows us to work with only our keyboard.

The way I see it being able to work without a mouse is an affordance of the editor it's not a requirement in order to make use of the editor and so using your mouse is not inherently taboo,"Vim don't care about none of that".

DISCLAIMER
I don't use a mouse with Vim, that's just my choice seeing as I have always favoured keyboard shortcuts over clicking on the UI.

The idea of a Modal editor is kind of like a state machine, the same keys can have a different meaning if at all any in different modes. The editor AFAIK defaults to what is called Normal mode. in this mode, you issue out instructions to the editor, these instructions could be any of the following:

  • Do something with the text under the cursor -  Cut it, go to the next word, find all occurrences of this word, delete it, change it, uppercase it… endless possibilities really.
  • Do something with the cursor -  Move it maybe
  • Open a file
  • Go to another mode -  The one where I get to type stuff maybe (this is what we often want)
  • Quit this whole thing. - Shoot! I forgot the -m flag again.

Now that you know Vim needs to be in a specific mode to do what you expect it to you can go about matching your workflow to Vim modes.
I just wanna type code (read bugs) then Vim has INSERT mode.
Now I wanna delete stuff I need to be in NORMAL mode and issue the right command(s) for this.


OPTIONS are Either Some(fun) or None

If you don't get that joke never mind. My point is to prepare yourself for a plethora of options to do the same thing. If you don't like that it's okay, stick with what works for you and don't let anybody tell you differently. You should know though that when you want to take advantage of Vim you may need to explore more options and their nuanced differences, much more than saved keystrokes, things like repeatability, composability and my favourite - ergonomics.
The coolest part is knowing that this editor and more specifically it's language allows you to be as awesome as you want to be.


But It must be pretty tho.

We like aesthetically pleasing workplaces and our editor must be an absolute beauty to behold. Fear for nothing Vim can be as pretty as you want - Which is more than I can say for a certain IDE ( fake-cough-Storm) you just need to know where to look.


I know ... but can it autocomplete tho.

There are lots of cool features that our editors give us and sensible autocomplete shouldn't be too much to ask, well you can have it with Vim too, checkout coc.nvim

This was my scatterbrain attempt to write about Vim without going all Vyy 2j p on you. please leave a review if you like this show :)

Top comments (2)

Collapse
 
amaurybsouza profile image
Amaury Borges Souza

Thanks for your tips, certainly added a lot!

Collapse
 
waju profile image
Abolarin Olanrewaju Olabode

Thanks Amaury, I'm glad you found this helpful.