DEV Community

Cover image for How to Transform Vim to a Complete IDE?
Daniil Sitdikov
Daniil Sitdikov

Posted on

How to Transform Vim to a Complete IDE?

Introduction

Recently, fate forced me to work on my old personal MacBook from 2015. Over the years of development, I've got used to powerful IDEs, such as IntelliJ IDEA, but my laptop couldn't handle it anymore. Having three projects open simultaneously made their development practically impossible. Everything was very laggy. I also noticed the same problems in VSCode. In frustration, I decided to take a radical approach and try out the classic Vim.

classic vim

After working in classic Vim for 30 minutes, I realized that this method might be too harsh for me. A lot has to be done through the terminal: finding the necessary files, making edits, running the linter separately. Additionally, to work comfortably, you need to know a lot of commands. But at least there were no lags anymore. Still, in 2023, I'd at least like to see:

  1. Syntax highlighting
  2. Linter and Prettier
  3. Fuzzy search across the entire project and the current file
  4. Tips to speed up the writing process
  5. Visual navigation

So, my choice fell on NeoVim. Essentially, it's a significantly reworked and improved Vim. It retains almost all of its functionality, but at the same time, it adds rich expansion capabilities. One of the key features is the support for the Language Server Protocol, which allows for syntax highlighting, adding linters, and providing suggestions similar to VSCode. All of this has enabled developers to create a large number of plugins, replicating the functionality of the IDEs we are accustomed to these days.

And here's what I got:
nvim

It uses only 170-250 MB of RAM!

Ready-made packages

The quickest and easiest way to start is to use a pre-made setup. Here are a few great well-known options to choose from:

  1. https://www.lunarvim.org/
  2. https://www.lazyvim.org/
  3. https://astronvim.com/
  4. https://nvchad.com/
  5. https://spacevim.org/

Personally, I use LunarVim. It's quick and easy to install, and it has good documentation. There are many more here: https://github.com/topics/neovim-config.

An important note: most likely, the standard terminal won't be enough for full-fledged work. On MacOS, I switched to iTerm.

How to use it?

So, I've downloaded and installed it, what's next?
opened file via nvim

There's a nuance here. Everything is controlled by keys, and only sometimes by the mouse. Almost any build has a project search, code hints, file explorer, and code hints.

There are numerous plugins available. For instance, this is a Copilot implementation: https://github.com/zbirenbaum/copilot-cmp. Or prettier: https://github.com/MunifTanjim/prettier.nvim. You might need just edit your configuration file.

Cheat sheet

Here's a short list of commands that will help you quickly get the hang of it and start playing around:

Navigation:

  1. Open file explorer on the left: Space + e
  2. Go to the file reference: g + mouse click

Search

  1. All-available menu: :Telescope
  2. Fuzzy search for files: Space + f
  3. Search within the file itself: Space + s + t

What's needed the most

  1. Copy the selected: y
  2. Paste: Ctrl + V
  3. Edit mode: i, default mode: Esc
  4. Save file: :w
  5. Quit: :q

By default, most of nvim packages have WhichKey plugin which shows popup with available commands. For instance, you press space or g and what for a second:

which key example

Add more terminals at the bottom

You can attach terminals using:

:ToggleTerm size=8 direction=horizontal

But I personally prefer adding them using native terminal’s functionality. For instance, iTerms can attach several terminal sessions to the current window.

split terminals

Learning native Vim commands

If you want to become thoroughly familiar with the commands of Vim and remember them forever, there is a browser game that can help you achieve this: https://vim-adventures.com.

And this comprehensive guide: https://github.com/iggredible/Learn-Vim

Git

You can also work conveniently with git from the terminal. For this, you can install LazyGit:

LazyGit window

Quick cheat-sheet for the essentials:

  1. Add files to staged changes: just a mouse click on files and folders
  2. Discard changes: d. It can be applied for lines and for files.
  3. Git pull: p
  4. Commit changes: c
  5. Git push: P

Conclusion

I am impressed by how enthusiasts have managed to implement such complex features from modern IDEs inside the terminal using minimal resources. Personally, I find it to be a great choice when you have limited resources on your laptop or when you need to navigate through system files and make edits. It's also a great idea to set it up on a remote server. However, when I switched back to the powerful laptop, I stopped using it as a main IDE. Thank you phil9l for sharing with me such amazing approach and inspiring to write this article!

Top comments (9)

Collapse
 
dadyasasha profile image
Alex Pushkarev

Nice article, thanks!

Collapse
 
dadyasasha profile image
Alex Pushkarev

Also this Vim cheetsheat may be useful: dev.to/dadyasasha/vim-cheatsheet-4e35

Collapse
 
dsitdikov profile image
Daniil Sitdikov

Wow, thank you! :) I bookmarked

Collapse
 
chiragagg5k profile image
Chirag Aggarwal

I personally use and love Lunarvim. I tried configuring my own Neovim, but it just takes too much time and is just never going to be as polished as what i found Lunarvim to be. Great article 💯

Collapse
 
dsitdikov profile image
Daniil Sitdikov

Yeeah, i haven't even tried to configure it from scratch, tbh :D Too much work to do. Thank you so much!

Collapse
 
raguay profile image
Richard Guay

I tried Lunarvim, but I found LazyVim to be much easier to maintain and expand. But, the nice thing is that everyone can choose what works best for them. Most IDEs force you to do things their way.

Collapse
 
dsitdikov profile image
Daniil Sitdikov • Edited

Great! Exactly. I think, this is the second competitive advantage, after small resource consumption.

Collapse
 
v0i4 profile image
antonio vasconcellos

Nice article man, LunarVim is awesome!

Collapse
 
dsitdikov profile image
Daniil Sitdikov

Thank you! 100% :)