It's About Time We Learn Vim

Intro

There's a high probability that you've ended up on this screen and did not know what to do.

Chances are, you tried Googling phrases like "exit text editor" and the like. You might have ultimately failed and ended up quitting your terminal. Just don't restart your computer! 🤣

Congratulations! You've just opened up a file in Vim.

So why do I have to spend time learning Vim when I have my trusty VSCode / Sublime Text / WebStorm / [insert another editor here] at my disposal and I am already used to using it?

- you might ask.

I'd say, for the past few days struggling and trying to grasp the idea of using Vim, its so-called modes, and all the good stuff, I believe it's one skill every developer should know and take time to learn - at least the basics - at some point in their careers like you know HTML and every-day terminal commands.

My Progress

vimtutor

I spent a few minutes dabbling around the internet reading about Vim but I found the information too overwhelming. So I started with the official vimtutor that comes with macOS and the majority of Linux distros out there.

To start, simply run vimtutor on your terminal and it should greet you with the following:

As repeatedly stated in the doc:

Do not try to memorize, learn by usage.

And you should take this advice seriously. The only way to get better at it is to keep using it.

Very Basic Setup

So I started to create my ~/.vimrc config with the following contents:

set number
set relativenumber
set autoindent
set hlsearch
set ignorecase
set smartcase
set mouse=a

It is expected to grow crazy once I get the hang of it. I'll be sharing my config when it makes more sense than this. 😅

Struggling

Yes, the learning curve is steep!

So I still keep VSCode (my default editor) at the back whenever I find myself sluggish at something previously trivial and built-in like:

  • Commenting out code
  • Running formatters like prettier
  • Snippets (tsrfce, rfcp, clg)
  • Code Completion
  • Auto Imports
  • Syntax Highlighting
  • File Explorer
  • and so on...

I even installed the Vim extension for VSCode. It's somehow effective, and I would recommend it. Other editors probably have the same type of extension or feature, like Sublime's Vintage Mode. But I still try my best to do Vim inside Vim.

Plugins

Probably another reason - aside from its keybindings - that keeps Vim relevant even in 2022 is its extensibility and the plethora of plugins available, plus the active community behind them.

There are a couple of plugin managers available. To name a few:

I settled for vim-plug. It's fast as far as I've used it. No complaints there.

So far, I have the following plugin config in my ~/.vimrc:

call plug#begin()
  Plug 'preservim/nerdtree'
  Plug 'ryanoasis/vim-devicons'
  Plug 'sheerun/vim-polyglot'
  Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
  Plug 'junegunn/fzf.vim'
  Plug 'scrooloose/syntastic'
  Plug 'airblade/vim-gitgutter'
  Plug 'vim-airline/vim-airline'
  Plug 'w0rp/ale'
plug#end()

My Vim setup now looks like this:

Pretty neat isn't it? I barely scratched the surface and the possiblities are endless.