Why You Should At Least Try Vim Once

Vim, or NeoVim, is the text editor that I am sure almost every tech savvy person must have heard of. Though only few people use it on daily basis. I don't blame them. It can be intimidating, hard at first. That hard that some people don't even know how to exit Vim. Though don't worry, I am here to help.

In this post, I will highlight some native features of Vim which I believe, that other command line editors and IDEs lack. Expect maybe Emacs which has most of them but with different keybindings and philosophy.

This isn't a comprehensive tutorial. Vim has lots of useful features that it would be impossible to cover it in a single post. If you need a comprehensive tutorial then refer to official documentation or run vimtutor command.

Table of Contents


Basics

Vim keybindings are all case-sensitive, and follow this structure[int] + verb + object.

i Enter insert mode.

A Jump to one character ahead of the end of the line and enter insert mode.

:! Run external command.

:r! Run external command and paste output into the current cursor position.

:h keyword Browse documentation for the keyword.

:q Exit Vim.



Editing

~ Switch case of a single character.

A Jump to enter end of line and enter insert mode.

c Delete a single character and enter insert mode

x Delete a single character.

C-a Increase the number at current position by one.

C-x Decrease the number at current position by one.


Spell Checking

:set spell Turn on spell check.

z= Show suggestions.


Multiple Windows

C-w h/j/k/l Navigate through windows, in left, down, up, right direction.

C-w s Split current window.

C-w o Close all other windows.

:vsplit filename Open the specified file in a vertical split.

:split filename Open the specified file in a horizontal split.


Registers

qX Record a macro at register X.

@X Play the macro X.

"X Paste the content of the register X.


Examples

3jA Move three lines downwards till the last non-empty character of that line and then enter insert mode.

ci{ Delete a function body and enter insert mode.


Too overwhelming? Remember, it doesn't have to be. You don't have to learn all of these keybindings at once. You can just learn basic things mentioned in Navigation section to get started. Just open any plain text file, or a one with source code in it, to get started. It wont take more than five minutes. If you like it, which I am sure you will, you can continue using it, otherwise you can just stop. At least you wont have to regret in future that you never tried it.

I highly recommend starting with vanilla Vim, or Neovim, instead of pre-configured distributions like LunarVim, LazyVim as they might be too overwhelming and confusing.