Vim for People Who Use Visual Studio Code (Full Article)
Tags: vim, learning, programming, webdev
Published: 2019-09-24 18:10:34

---
title: Vim for People Who Use Visual Studio Code (Full Article)
published: true
tags: Vim,Learning,Programming,Web Development
canonical_url: https://medium.com/javarevisited/vim-for-people-who-use-visual-studio-code-643f12ba6039
cover_image: https://www.freecodecamp.org/news/content/images/2019/09/vimvsvscode.png
---

Hot tips to bring the awesomeness of Visual Studio Code to Vim.

### Front-Matter

I want to start by saying, this is not an editor-shame article. You can use whatever text editor you want. It really doesn’t matter. I’m only writing this because I found a level of productivity in Vim that I haven’t had in any of the editors I used before (Sublime Text, Atom or VSCode).

If you’ve heard about Vim, and want to try it out, I hope this article can provide a bit of familiarity you’d find from VSCode.

![Vim for People Who Use Visual Studio Code](https://media.giphy.com/media/5b26kbDYzsqGartaXz/giphy-downsized-large.gif)<figcaption>Keanu Believes in you. I believe in you.</figcaption>


### Why Vim?

There are lots of reasons to use Vim, so here’s a few of mine.

#### Keep your hands at 10 and 2

![Vim for People Who Use Visual Studio Code](https://media.giphy.com/media/11Qm8y698eYC8U/giphy.gif)


When you are solely using the keyboard, there is going to be an inherent speed boost just from not having to physically move your hands. And hey, maybe you’re a black belt in mouse movement, and you can move back in forth with a speed invisible to the naked eye. For the rest of us simple humans, it takes time.

Let’s do some quick math.

![Vim for People Who Use Visual Studio Code](https://media.giphy.com/media/Fh28yu3oxWRlm/giphy.gif)<figcaption>Keanu Believes in you. I believe in you.</figcaption>


It takes 600ms to move my hand from the “home keys” to the mouse. On average, for sake of argument, I do that once a minute while I’m writing [code](https://www.java67.com/2018/06/21-websites-to-learn-how-to-code-for.html). Whether that be to scroll, navigate to a new file, or something similar.

600 (wasted time in ms) x 60 (times per hour) x 5 (hours I am actually coding) = 180,000ms wasted =

> 3. Minutes. Every. Day.

Yeah, okay, maybe that doesn’t sound so bad, but, those 3 minutes could be spent writing a function, or [refactoring code](http://www.java67.com/2016/02/5-books-to-improve-coding-skills-of.html), not flailing your hand about like your Harry Potter!

#### Speed
![Vim for People Who Use Visual Studio Code](https://media.giphy.com/media/4wEFKQgMGLlqU/source.gif)<figcaption>Okay, so maybe 65 isn’t really that fast anymore, but hey, this was 1994!</figcaption>

My favorite quote that describes what it’s like to code in VIM:

> “Code at the speed of thought”

Vim is built around the idea that you are directly communicating with your computer. You tell it what you want, and it does it for you. The biggest eye-opener for me was this little tidbit:

To delete everything in between two objects (parentheses, quotes, etc), it's as simple as:

`di'`



![Vim for People Who Use Visual Studio Code](https://www.freecodecamp.org/news/content/images/2019/09/Hnet.com-image.gif)<figcaption>Computer: Delete, inside, single-quotes.</figcaption>


That’s just the surface of amazing shorthand things you can do with Vim.

#### I’m a real programmer!
![](https://media.giphy.com/media/v5OtzSjwSu3w4/giphy.gif)

Part of the journey of learning VIM is exposing yourself to how UNIX works. I’m under the impression that the more you expose yourself to things like bash, the [better programmer](https://javarevisited.blogspot.com/2014/01/10-tips-to-improve-programming-skill-become-better-programmer.html) you are going to be.

Chances are, you have a pretty sweet command line setup. Wouldn’t it be nice if your code editor and your command line worked in concert?

#### How do you exit Vim?

Probability is high that you’ve ever edited a file on a Linux server, and couldn’t figure out how to exit the file. Let’s say, for example, changing an SSH key on Digital Ocean. If you know VIM…you don’t have to worry about that!

#### The real reason I switched to Vim

Honesty time. The real catalyst for wanting to switch to Vim was watching Kyle Mathews (creator of Gatsby.js) using it during a demo.

![](https://media.giphy.com/media/UUypRspZCaF94uKasd/source.gif)<figcaption>Ya caught me.</figcaption>

### VS Code Features and their equivalents

Convinced? Cool, here’s some tools!

#### Plugin System

Vim by itself is pretty barebones. In order to add plugins, we have to have a mechanism to manage them. Enter Plug:

[**junegunn/vim-plug**](https://github.com/junegunn/vim-plug)

> Note: There are a few plugin managers out there. I landed on Plug for no particular reason. I like it, and I’ve had no issues with it. FYI, as far as I can tell, Vundle isn't regularly maintained anymore.

#### File Search

There has been a bunch of solutions for file searching over the years, as indicated by the multitude of answers in forums. I tried a couple of different ones, but landed on this combination:

[Fuzzy Finder(fzf)](https://github.com/junegunn/fzf) + [Ripgre](https://github.com/BurntSushi/ripgrep)p

<!--kg-card-begin: image-->

![Vim for People Who Use Visual Studio Code](https://www.freecodecamp.org/news/content/images/2019/09/fzf.gif)<figcaption>Fuzzy search for "theme"</figcaption>

<!--kg-card-end: image-->

Fzf is a really well built/maintained fuzzy search that works in both the command line and vim.

> Note: You may see Ag(Silver searcher) in a lot of articles, however the Ag related vim plugin is no longer maintained, so its suggested to use RipGrep.

#### Intellisense

The auto-completion system (Intellisense) in VSCode is arguably it’s best feature. Lucky for us, it’s been ported over to Vim!

[**neoclide/coc.nvim**](https://github.com/neoclide/coc.nvim)

<!--kg-card-begin: image-->

![Vim for People Who Use Visual Studio Code](https://www.freecodecamp.org/news/content/images/2019/09/CoC.gif)<figcaption>autocompletion for importing a function written in another file in React</figcaption>

<!--kg-card-end: image-->

CoC has its own extension system, that mirrors that of VSCodes. It's easy to use and well documented (the most important part).

> Note: You may see some old articles talking about YouCompleteMe, but as far as I can tell, that isn’t maintained anymore.

#### File System Explorer

VSCode, like most modern text editors, comes with a file explorer. Vim’s native `netrw` is alright, and I’ve seen quite a few articles saying you don’t need anything else, like [here](https://shapeshed.com/vim-netrw/). However, I find NERDTree is too useful to not use.

[**scrooloose/nerdtree**](https://github.com/scrooloose/nerdtree)

#### Git integration

I gotta be honest here, I do most of my git stuff straight in Iterm. However, VSCode has an incredibly nice Git Diff split screen. To get that level of git integration, check out this plugin:

[**tpope/vim-fugitive**](https://github.com/tpope/vim-fugitive)

<!--kg-card-begin: image-->

![Vim for People Who Use Visual Studio Code](https://www.freecodecamp.org/news/content/images/2019/09/gitdiff.gif)

<!--kg-card-end: image-->
### Additional plugins that you may want

This is some of the stuff I used in Visual Studio Code, that I wanted to bring into Vim.

#### Autocomplete Brackets

This nice little package will auto close those pesky brackets.

[**jiangmiao/auto-pairs**](https://github.com/jiangmiao/auto-pairs)

#### File Icons

This will add icons to stuff like NERDTree.

[**ryanoasis/vim-devicons**](https://github.com/ryanoasis/vim-devicons)

#### Prettier

Wouldn’t you know it, but the official prettier team has a vim plugin. How nice! Also, incredibly simple to set up.

[**prettier/vim-prettier**](https://github.com/prettier/vim-prettier)

Get it to work on autosave, check out [this article](https://www.dailysmarty.com/posts/how-to-setup-prettier-with-vim).

#### Snippets

Wouldn’t you know it, using the Conquer of Completion, you can import VSCode snippets!

Check this out to show you how to do that:

[**neoclide/coc.nvim**](https://github.com/neoclide/coc.nvim/wiki/Using-snippets)

Here is the React snippets package I’m using.

[**xabikos/vscode-react**](https://github.com/xabikos/vscode-react)

#### Additional Stuff

THE home for Vim plugins is Vim Awesome.

[**Vim Awesome**](https://vimawesome.com/)

Great place to watch people use Vim:

[**Vimcasts - Free screencasts about the text editor Vim**](http://vimcasts.org/)

### Dotfiles

I have a few remapped keys to make things easier. Check out my dotfiles for all those.

[**DarthOstrich/dotfiles**](https://github.com/DarthOstrich/dotfiles)

### Final Thoughts

#### My Journey

I solely use Vim now, after spending about a year to learn it. Initially, I was using it just for my personal projects, because my productivity level was low. I had to keep stopping to look up how to do something. However, I dropped VSCode completely about 4 months ago, and I don’t plan on going back.

#### It takes discipline

Learning Vim can seem daunting, and frankly, it is. It requires self-imposed discipline. However, doesn’t everything in development? There is no tool/language/framework I’ve ever learned that didn’t require some level of [deliberate practice](http://www.calnewport.com/blog/2011/12/28/how-i-used-deliberate-practice-to-destroy-my-computer-science-final/).

Vim is a lifestyle choice. It will take a while to get used to it, and it WILL be frustrating at times. However, if you stick to it, I guarantee it’ll improve your workflow. If you have any additional tips or questions, please drop them below. As always, happy coding!

![](https://media.giphy.com/media/hv4TC2Ide8rDoXy0iK/source.gif)

# Want more tips?
I've got a newsletter that you might like. I share web dev tips and tricks as well as stories about what it's like being a freelancer in Los Angeles. Check it out [here](https://digitalnutt.substack.com/p/coming-soon?r=34slo&utm_campaign=post&utm_medium=web&utm_source=copy)

## Additional Resources for learning

[**Mastering Vim Quickly — Jovica Ilic**](https://jovicailic.org/mastering-vim-quickly/)

[**8 Vim Tricks That Will Take You From Beginner to Expert**](https://medium.com/swlh/8-vim-tricks-that-will-take-you-from-beginner-to-expert-817ff4870245)

## References

[**Switching to Vim**](http://brendandawes.com/blog/vim)

[**10 simple Linux tips which save 50% of my time in the command line**](https://dev.to/javinpaul/10-simple-linux-tips-which-save-50-of-my-time-in-the-command-line-4moo)