How to Learn Vim in 2020
Tags: vim, neovim, editor, codenewbie
Published: 2020-03-18 20:08:22

---
title: How to Learn Vim in 2020
published: true
description: How to learn Vim right now
tags: vim, neovim, editor, codenewbie
---
*Follow [@learnvim](https://twitter.com/learnvim) for more Vim tips and tricks!*

When I first discovered Vim, I thought it was an outdated editor that was unnecessarily hard to use. Until one day I saw my friend doing Vim magic. I thought that was the coolest thing I have ever seen. Fast forward several years, Vim is now my main editor.

*Is it worth learning Vim in 2020, where many are using modern editor like VSCode, Sublime, and Atom?*

**Definitely.**

I will show you how to get started learning Vim. Here are things that I will cover. You don't have to read this linearly.

*You may decide that Vim is not for you. That's totally fine. Vim, like other editors, is just a tool. At the end of the day, use whatever tool that lets you get the job done.*

# Why learn Vim

Vim is not easy to use initially. But Driving a car was not easy initially. Riding a bicycle was not easy initially. Programming was not easy initially. Many things are not easy initially. So why do we stop learning Vim because it was not easy initially?

If you are asking, "why should I learn Vim in 2020? There are many great text editors out there." Here are some advantages of using Vim:

- Lightweight.
- Challenging (for those who love challenges).
- Almost everywhere (if you ever need to SSH to server, you won't find an IDE, but you will almost always find Vim).
- Good integration with command line (with `!`, you can execute commands like `ls`, `curl`. You can also run `ex` commands with `:`).
- Rewarding and satisfying. (Understanding Vim grammar, customizing Vim, learning Vim Script, etc, unlock a whole new realm of possibilities. It is like playing video game where you could level up, acquire new skills, and combine them).
- Unique built-in features. (Time travel, macros, text-objects, dot command are built-in features that are almost unique to Vim).

Challenges:
- Hard to exit the first time.
- Steep learning curve (not as bad as you think).
- First time using it will cut productivity (learning always takes time. You don't have to start Vim cold. Keep your regular editor at work. Learn Vim at your time, on your own side project. Switch when you are ready).


# Learning Vim

In first part, I will show some practical steps to learn Vim from absolute beginner. In second part, I will share useful tips/tricks.

## Steps to Learn Vim


- ✅ Learn [how to exit Vim](https://stackoverflow.com/questions/11828270/how-do-i-exit-the-vim-editor).
- ✅ Go through `:vimtutor` (`:Tutor`).
- ✅ Learn the *most basic commands* to get started:

```
i (insert mode)
Esc (normal mode/ exit insert mode)
x (delete one character)
h/j/k/l (direction. Personally I would avoid arrow keys from the beginning)
:e {filename} (load document)
:w {filename} (save document)
:q (exit)
:q! (exit + ignore unsaved changes)
```

Next, learn slightly more advanced commands:

```
dd (cut a line)
yy (copy a line)
p (paste)
/{pattern} (search for text)
n (go to the next result)
:s/pattern/replacement (replace text)
```
- ✅ Learn Vim Grammar to "talk" to Vim.

  - [Mastering Vim Grammar](https://dev.to/iggredible/mastering-vim-grammar-1dfi)
  - [Learn to speak vim — verbs, nouns, and modifiers!](https://yanpritzker.com/learn-to-speak-vim-verbs-nouns-and-modifiers-d7bfed1f6b2d)
  - [Vim grammar](https://takac.github.io/2013/01/30/vim-grammar/)
  - [Vim as a language](https://benmccormick.org/2014/07/02/learning-vim-in-2014-vim-as-language)
  - [Mastering the Vim Language](https://www.youtube.com/watch?v=wlR5gYd6um0&t=1s)

- ✅ Learn navigation.
  - `:h motion.txt` / `:h navigation`
  - [Moving Around](https://vim.fandom.com/wiki/Moving_around)
  - [8 Essential Vim Editor Navigation Fundamentals](https://www.thegeekstuff.com/2009/03/8-essential-vim-editor-navigation-fundamentals/)
  - [Moving Around in Vim](https://dev.to/iggredible/vim-cheatsheet-to-move-around-in-a-file-plus-tips-to-use-them-bme)

- ✅ Learn Vim modes.
  - `:h vim-modes-intro`
  - [Modeless vs Modal Editors](https://unix.stackexchange.com/questions/57705/modeless-vs-modal-editors)
  - [Introduction to Vim Modes](https://dev.to/iggredible/introduction-to-vim-modes-1cp2)



- ✅ Learn text object.
  - `:h text-objects`

- ✅ Learn how to modify vimrc.
  - [Where is my vimrc file?](https://stackoverflow.com/questions/10921441/where-is-my-vimrc-file)
  - [Introduction To Vim Customization](https://www.linode.com/docs/tools-reference/tools/introduction-to-vim-customization/)

- ✅ Learn basic Command-line mode (ex) commands (first, learn search/replace).
  - `:h :`
  - [Using Vi/Vim: Ex and Ex-like Commands](https://www.sbf5.com/~cduan/technical/vi/vi-2.shtml)
  - [Search and Replace](https://vim.fandom.com/wiki/Search_and_replace)

- ✅ Learn the dot command.
  - `:h .`
  - [What can the dot command repeat, exactly?](https://stackoverflow.com/questions/12566235/what-can-the-dot-command-repeat-exactly)
  - [Why the dot (.) command is so useful in VIM?](https://stackoverflow.com/questions/7325052/why-the-dot-command-is-so-useful-in-vim)
  - [Use Vim's dot command to do repetitive tasks faster](https://dev.to/iggredible/vim-use-dot-command-to-save-keystrokes-1c96)

- ✅ Learn macros.
  - `:h q`
  - [An Intro to Vim Macros](https://hackernoon.com/an-intro-to-vim-macros-f690d8c3c3fd)
  - [The Power of Recursive Macros in Vim](https://jovicailic.org/2018/06/recursive-macros-in-vim/)
  - [Automate typing with Vim macros](https://dev.to/iggredible/automate-typing-with-vim-macros-4m9c)

- ✅ Learn something new everyday and apply it.
- ✅ Read (and reread) [Practical Vim](https://pragprog.com/book/dnvim2/practical-vim-second-edition) and/or [Mastering Vim Quickly](https://jovicailic.org/mastering-vim-quickly/).
- ✅ Do [Vimgolf](https://www.vimgolf.com/).
- ✅ Perpetual self learning.

These should be enough to get you started. There are many more features that I do not list above. You will learn them over time.

Do not feel like you have to know 100% of Vim features. You can get very fast and productive with limited knowledge. There may even be popular features that you will never use. *Use whatever features and workflow that helps you most.*

# Tips/Tricks to learn Vim

1. Learning Vim is learning a practical skill. You don't learn how to ride a bike by *reading a book on how to ride a bike*. You learn how to ride a bike by riding a bike. You are building muscle memory. The goal is to be able to do X without thinking. Learn only a few things each day and learn them well.
2. Don't copy paste someone else's `vimrc`. It will cloud you from seeing Vim's native ability. Start with blank `vimrc`. Know what every single line does. You will be surprised that you may not need that many plugins.
3. Learn [touch typing](https://blog.codinghorror.com/we-are-typists-first-programmers-second/).
4. When starting, force yourself to use `hjkl`. You can either add this in your vimrc:
```
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
```
or install [vim-hardtime](https://github.com/takac/vim-hardtime) plugin.


# Vim Resources
Below, I compiled some of the popular resources to learn Vim. 

## Books
Books I found extremely useful:

1. [Practical Vim](https://pragprog.com/book/dnvim/practical-vim)
2. [Mastering Vim](https://jovicailic.org/mastering-vim-quickly/)
3. [A Byte of Vim](https://vim.swaroopch.com/)
4. More list of books [here](https://iccf-holland.org/vim_books.html)

## Articles
"Must-read" Vim articles:
1. [Learn vim For the Last Time: A Tutorial and Primer](https://danielmiessler.com/study/vim/)
2. [Grokking Vi](https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118)
3. [Why I love Vim: It’s the lesser-known features that make it so amazing](https://www.freecodecamp.org/news/learn-linux-vim-basic-features-19134461ab85/)
4. [operator, the true power of Vim](https://whileimautomaton.net/2008/11/vimm3/operator)
5. [Coming Home to Vim](https://stevelosh.com/blog/2010/09/coming-home-to-vim/)
6. [Vim Anti-Patterns](https://sanctum.geek.nz/arabesque/vim-anti-patterns/)


## Misc Online Resources
Other online resources:
1. [Vim reddit](https://www.reddit.com/r/vim/) for vim discussions/tips/Q&A
2. [Vimcasts](http://vimcasts.org/) for tutorials
3. [Vimgolf](https://www.vimgolf.com/) for training
4. [OpenVim](https://www.openvim.com/)
5. [Vim adventures](https://vim-adventures.com/)
6. [Derek Wyatt Vim tutorials](http://derekwyatt.org/vim/tutorials/index.html)
7. [Learn Vimscript the Hard Way](https://learnvimscriptthehardway.stevelosh.com/)

## List of Plugins
*Once you get comfortable*, feel free to add plugins. Here is a *(opinionated)* list of plugins to make Vim more "IDE"-like:
1. Quick quote/parentheses: [vim-surround](https://github.com/tpope/vim-surround)
2. Search: [fzf.vim](https://github.com/junegunn/fzf.vim)
3. No-nonsense config: [vim-sensible](https://github.com/tpope/vim-sensible)
4. NERDTree: [nerdtree](https://github.com/preservim/nerdtree) (alternative: netrw, or its enhancement [vim-vinegar](https://github.com/tpope/vim-vinegar), [ranger](https://github.com/francoiscabrol/ranger.vim))
5. Emmet: [emmet-vim](https://github.com/mattn/emmet-vim)
6. tags: [vim-gutentags](https://github.com/ludovicchabant/vim-gutentags)
7. autocompletion: ([youcompleteme](https://github.com/ycm-core/YouCompleteMe), [coc.nvim](https://github.com/neoclide/coc.nvim), [deoplete](https://github.com/Shougo/deoplete.nvim))
8. language pack:[vim-polyglot](https://github.com/sheerun/vim-polyglot)
9. tmux-integration: [vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
10. commenting: [vim-commentary](https://github.com/tpope/vim-commentary), [tcomment](https://github.com/tomtom/tcomment_vim)
11. LSP support/ syntax: [ale](https://github.com/dense-analysis/ale)
12. Git: [vim-fugitive](https://github.com/tpope/vim-fugitive) (also [vim-gitgutter](https://github.com/airblade/vim-gitgutter))
13. Indent: [indentline](https://github.com/Yggdroot/indentLine)
14. Text-object: [vim-textobj-user](https://github.com/kana/vim-textobj-user)

# How to use `:help`

At some point, you will need to start using Vim's built-in `:help` on your quest to master Vim. 

Knowing how to use Vim's built-in help is useful.

## Autocomplete
Vim `help` lets you autocomplete with tab. If you want to learn more about Vim `colorscheme`, you can type `:h color` and press `<TAB>`. Vim will show you different options to choose from. You can navigate forward with `<TAB>` and back with `<SHIFT> + <TAB>`. 

## Jump to definition
While you are in help, sometimes you will see links (it has different color). If you put your cursor on link, you can jump to definition with `C-]`.

You can go toggle previous/current window with `C-o` and `C-i`.

## helpgrep

Vim has a lesser-known feature called `:helpgrep`. It does what it sounds like: grepping help. It search for phrases in all help section.

For example, if you want to look at everything related to "colorscheme", you can do `:helpgrep colorscheme"`. Vim searches for all "colorscheme" keywords and list them in Quickfix window (`:h quickfix`).

Some useful navigation:
1. List all helpgrep results with `:clist`
2. Go to next match with `:cnext`
3. Go to previous match with `:cprev`

# Conclusion

Is 2020 too late to learn Vim? No.

Do you have to learn Vim to be a better programmer? Absolutely not. I've seen much better programmer than me who does not use Vim.

Is Vim challenging? It takes a lifetime to become a Vim master (I am also still a Vim student). Vim is unlike other editors I have ever used. There is always something to be discovered. Vim is challenging. The fun kind of challenge.

In the end - *I will repeat this again* - use whatever best tool for the job. Maybe it is Vim for you, maybe it is VSCode, or maybe it is Notepad++ - or maybe it is all of them. It is good to be well-versed with multiple tools. 

Let's get things done.