ProgrammingText EditorProductivity

Neovim is Essential

Neovim Logo
Author: Ariel Frischer|May 14, 2024|
9 min read

Introduction

Over the last 6+ years of my programming journey, I've come to understand that Neovim is the most productive tool I've used. Neovim is a lightweight editor that runs in the terminal. At first, it traps unsuspecting victims from exiting, but sooner or later, you won't want to leave. Neovim is a fork of the popular vim repository, it has widespread adoption, and it has special "vim" bindings that make text editing and navigation easy, ergonomic, and effective.

You can navigate to the beginning of each word with the w key, or the end of each word with e - these are called vim motions. Vim commands + motions allow for effective code editing for example d is the deletion command paired with w will delete the word under the cursor. Neovim is keyboard-centric it saves so many keypresses and so using the mouse is discouraged and truly unnecessary. Once the vim bindings are ingrained in your head, you're able to swiftly edit code at the speed of thought.


Yes, the transition from regular editors like VSCode is not easy or straightforward but was 1000% worth it. I find myself preferring to edit text everywhere with vim, whether in the browser or in the command line. Both are now possible with software like firenvim and "vi" mode for zsh. It's so much faster that I actually feel uncomfortable going back to the "normal" way of text editing.

There is a learning curve, not just with the bindings but also with setting up language servers, plugins, etc. I wouldn't say it's a super steep learning curve; it's more of an easy-medium difficulty. It took me about two weeks to become productive with vim bindings and start efficiency editing code. Initially, FlashDevelop was my first go-to editor back in the day, followed by VSCode. VSCode was great it had built-in language support, syntax highlighting, debugger, extensions etc... However, it wasn't until I stumbled upon a YouTube channel, probably ThePrimeagen, that I saw Neovim in action and had that "Aha" moment. The way he navigated through files and edited code was like watching a master pianist at work. I knew right away that Neovim would be an invaluable tool for any programmer.

If you're just starting out and would like to learn vim bindings without needed all the neovim configuration you can try out VSCode with the Neovim extension. Alternatively, you can use preconfigured neovim setups listed lower in this article. Although VSCode is an excellent beginner friendly editor, it is not as fast or lightweight as Neovim and is a bloated electron app. For many reasons, it will never be as good as Neovim.

Why Neovim?

Customizability

Neovim's core architecture is unparalleled as it was designed with modularity and customization in mind. You can tweak it to create a coding environment that suits your workflow perfectly. I constantly create small lua functions and give them key bindings to solve any custom repetative tasks. The plugin ecosystem is insane in a good way, you can essentially get all the features you want and build them in modular fashion.

Efficiency and Speed

The efficiency and speed that Neovim provides are remarkable. The keyboard-centric design minimizes context switching and keystrokes, keeping you in the coding flow. The analogy of "gliding through a piece of paper with scissors" really encapsulates the experience. Once you get accustomed to the key bindings, the speed at which you can write, edit, navigate, and execute code is astounding.

At my last company there were constant incidents so an emphasis on quickly resolving them was invaluable. Neovim allowed me to manipulate code and lists of strings effortlessly which comes in clutch when resolving incidents. Need to dedup a list of strings? Do a visual highlight and run :sort u to dedup the list. Need to format a list in a specific way or do any repetative set of keystrokes? Use vim macros! Need to combine a bunch of lines into one paragraph, do a visual highlight and run :join or :j the shortcut for it. You can pipe terminal commands into neovim and manipulate the text as well. The control you get is unparalleled as your vim/terminal knowledge expands.

Community

Neovim boasts a vibrant and supportive community. The discussions on GitHub, Reddit, and other forums are immensely helpful. Whenever I faced an issue or needed help customizing my setup, a solution was just a post or a search away. Moreover, the community continually contributes to the rich plugin ecosystem, making Neovim ever-evolving.

Cross-platform and Extensible

Being cross-platform, Neovim is a versatile choice for teams working across different operating systems. Its extensibility is another strong point. I've integrated it with other tools and technologies, creating a seamless workflow regardless of the platform.

Modern Features

Neovim has embraced modern features like built-in LSP (Language Server Protocol), providing IDE-like features such as auto-completion, linting, and much more. It's like having the best of both worlds-the simplicity and speed of a text editor, with the robust features of an IDE.

The Neovim Plugin Ecosystem

The plugin ecosystem has exploded in the last few years thanks to neovims clever decision to use lua instead vimscript which was used for the older vim. Some of the most popular plugins include:

  • Telescope.nvim: Highly extendable fuzzy finder.
  • nvim-treesitter: Parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.
  • NerdTree: File system explorer for navigating the file system and opening files.
  • nvim-cmp: Completion engine plugin that aims to provide full support for LSP completion and offers powerful customizability.

Fuzzy finders, like telescope and fzf can jump to any token, symbol, buffer, module, or file in a project in a fast, sane, and intuitive manner. This is just the tip of the iceberg, checkout dotfyle for trending plugins. Installing + configuring packages manually is time intensive and not efficient this is where plugin managers come in clutch. The fastest current plugin manager seems to be Lazy.nvim nowadays but there are many to choose from: awesome-neovim#plugin-manager.

Pre-configured Neovim Repositories

For those who find the initial setup of Neovim daunting, there are pre-configured repositories available that can significantly ease the transition. Projects listed below offer ready-to-use configurations that come with a curated set of plugins and settings. These repositories are designed to provide a robust starting point, allowing you to experience the power of Neovim without the hassle of manual configuration. You can always customize these setups further to suit your specific needs.

  • Kickstart - A starting point for Neovim that is small, single-file, documented, and modular. This config is meant to be used as by YOU to begin your Neovim journey; remove the things you don't use and add what you miss.

  • LunarVim - LunarVim is a highly customizable Neovim distribution that aims to provide a good starting point for personal configuration with sensible defaults. It includes a variety of plugins for code completion, linting, and a user-friendly status line, among others.

  • AstroVim - AstroVim is a modern Neovim configuration aimed at providing a simple, out-of-the-box, fully functional Neovim setup. It focuses on minimalism and modularity, allowing users to easily add or remove features as needed.

  • NvChad - NvChad is a minimalistic Neovim setup that focuses on performance and aesthetics. It comes with a custom UI and a selection of plugins that are tailored for a smooth development workflow.

  • SpaceVim - SpaceVim is a community-driven vim distribution that seeks to manage collections of plugins in layers. It has a modal interface similar to spacemacs, focusing on providing features for multiple programming languages and an extensive set of plugins.

General Features

  • Easy to Customize: Neovim's API (Application Programming Interface) is well-documented, easy to find, and versioned, making it simple to extend and customize.
  • Works with Any Language: Neovim uses MessagePack for structured communication, allowing extensions to be written in any programming language.
  • Safe and Efficient Plugins: Remote plugins run as separate processes, ensuring they are safe and do not slow down Neovim.
  • Embed Neovim Anywhere: You can embed Neovim in GUIs, IDEs, and web browsers, using it as an editor or script host.
  • Easy Lua Plugins: Creating plugins in Lua is as straightforward as creating them in Vimscript. You can even write your configuration in a file called init.lua.
  • Better Syntax Highlighting: Neovim's parsing engine produces an Abstract Syntax Tree (AST), enabling faster and more accurate syntax highlighting, code navigation, refactoring, and text manipulation.
  • Built-in Language Server Protocol (LSP) Client: Neovim includes an LSP client for advanced code inspection and refactoring, such as going to definitions, finding references, and formatting code.
  • Great Default Settings: Neovim comes with strong default settings that work well out of the box.
  • Consistency: Neovim works the same way on all platforms with one build type and one command.
  • Modern Terminal Features: Neovim supports modern terminal features like cursor styling, focus events, and bracketed paste.
  • Built-in Terminal Emulator: Neovim includes a terminal emulator, allowing you to run terminal commands directly within the editor.

Last Remarks

Everything I've listed here is just an introduction, neovim has so many built-in features I'm still learning new and exciting features after 6+ years of usage. Neovim has profoundly impacted my career as a Software Engineer and makes coding enoyable. The flexibility, efficiency, and productivity gains should make it a compelling choice for any developer. I encourage up and coming software engineers and/or writers to just try Neovim and enjoy your new supertool. Its not just an editor, its a game changer, and for me - it is absolutely essential.

References