What Is Neovim?
Not everyone is familiar with Neovim, so let’s start with a brief introduction. Neovim is a fork of the popular text editor Vim, which is known for its speed, efficiency, and extensibility.
The most significant difference between Neovim and other editors is that it has a completely different approach to text editing. Neovim relies on so-called vim-motions, which are a set of commands that allow you to navigate, select, and manipulate text without ever touching the mouse. Neovim introduces four main modes: Normal, Insert, Visual, and Command. Typically editors have only Insert mode and Selection mode which work at the same time.
Vim motions is an amazing feature that can significantly speed up text editing. However, it requires some time to get used to it, especially if you are coming from an editor like Xcode.
To give you an idea what it means, here is a simple example. Let’s say you want to delete the current line in Xcode. You would probably use the mouse to select the line, then press cmd + x
to cut it or backspace
to delete it. In Neovim, you can do the same thing with just one command: dd
.
Another example is let’s say deleting everything within the nearest brackets. In Xcode, you would have to manually select the text, while in Neovim you can do it with dib
or cib
if you want to start typing right away.
If you want to see the end game of vim motions, level 999999, check out this video:
Two Simple Steps to go from IDE to Vim.
And here you will find a quick introduction to Neovim: Vim As Your Editor.
Why?
There are many reasons why you might want to switch from Xcode to Neovim. If you professionally work with code, you will sooner or later realize that Xcode is not the best tool for the job. There are many things missing, but the worst is that there is no way to extend it. Of course, there are some so-called “plugins” but almost nobody creates them because they are so limited. You have to pray that Apple will add one day the feature you are looking for.
On the other hand, Neovim is probably the most extensible text editor out there. You can customize it to your needs, add new features, and even create your own plugins.
You could have thought: “ok, but what’s the difference between Neovim and VSCode? It also offers thousands of plugins.”
The difference is that Neovim allows you to extend the environment without creating the whole plugin and the knowledge on how to do that. You just need to know the basics of Lua language (which is very easy to learn) and you can right away customize whatever you want directly in your config.
You can quickly search the help without even leaving Neovim, and find out how to get or set things that you want.
If you become more proficient with Neovim, you can even change the behavior of plugins by modifying their internals or by just subscribing to their events.
Vim Motions Are The New Game
Once you learn how to use vim-motions, you will never want to go back to traditional text editors. They are so powerful that you can do almost anything with them. You can navigate through the text, select it, delete, copy, and even create macros with just a few keystrokes.
What’s even more important, they will boost your daily fun with coding. You will feel like a wizard who can manipulate the text in any way he wants. You will jump from one file to another, delete lines, change words, and reformat the code within seconds.
You will start thinking about how can you make it more efficient, how to edit it faster, how to navigate through this file in a more efficient way… Writing code will become a fun game. You will start enjoying it more than ever before.
And you will learn every day something new about this editor that will blow your mind because it has so many great features. Even writing this text in Neovim, I’m using for the first time gqq
that wraps lines to a specific width when using Markdown. Recently discovered feature.
NOTE: you can enable Vim Mode in Xcode (Editor menu). It doesn’t provide all motions, but it’s good enough to start getting familiar with it.
Shortcuts Like No Other
At first, you may think that it’s not possible to remember all these shortcuts. But you will quickly realize that it’s not that hard. Most things are very intuitive. All shortcuts are trying to describe the action using an abbreviation.
For example d
stands for delete, c
for change, y
for yank (copy), v
for visual.
If you want to delete a word you just press dw
(delete word). If you want to delete what’s inside the brackets you press dib
(delete inside brackets). If you want to delete everything until ,
you press dt,
(delete ’til comma).
Mouse Is Deprecated
Once you start using Neovim, you will quickly realize that you don’t need a mouse anymore. You can do everything with just a keyboard. You can open files, navigate through them, search for text, jump between windows, projects, errors, run command line tools, and much more.
Of course, it takes some time to get used to it, but it’s totally within your reach.
Terminal Is Not Your Enemy
You may think that we are not in ’90s to use a terminal for coding. But you will quickly learn that this an advantage rather than a burden. Once you configure it, it looks great and you can use it for almost anything.
During your journey with Neovim, you will learn many great terminal tools that will make your life easier. You will understand the importance of fuzzy finders, multiplexers, jq
, bat
, lazygit
, and many more.
Even the tmux
itself will give you magic powers. You may think it’s just a tool to create tabs and splits, but it’s not. Imagine you can create multiple sessions for each project. You can have one session for the backend, one for the frontend. You can have 20 projects open and switch between them in a blink of an eye without killing your MacBook. How fast can you do that in Xcode?
You can restart your computer and restore these 20 projects and the whole setup in just one second.
Resource Consumption
You can open a big iOS project in Neovim and use maybe about 50 MB of RAM. The project will open in 200ms, with ready auto-complete, running Copilot, and already highlighted syntax. You can open 10 projects at the same time and your computer will not even notice it.
On the other hand, you’ve got Xcode, which will eat all your RAM, at least a couple of gigabytes per project and will be indexing files and doing other things for the next 5 minutes slowing down your computer, search, and everything. Assuming that you are lucky enough to already use Apple Silicon, because if you are on Intel, you can go for a coffee and come back when it’s ready.
Versatility
Nowadays, technology is changing rapidly. You have to be able to adapt to new tools and environments. Today you are working as a native iOS developer, tomorrow you may be working on a backend in Go, or become a cross-platform developer using Flutter.
On top of that, usually, you need to edit multiple file types like JSON, YAML, plist, etc. If you are familiar only with Xcode, you probably don’t even know that you can have linter for YAML, JSON, or even Markdown.
You don’t have to open YAML in one editor, JSON in another, and Markdown in the third. Now you can have all in Neovim, even side by side, and each file will provide automatically all features like syntax highlighting, linting, formatting, and more.
What’s most important, you will have the same shortcuts, adjustments, and plugins for all file types. You will not have to remember different shortcuts for different editors.
Imagine, that you want to use Kotlin Multiplatform in your project. With Neovim you can open two files side by side and have in both autocompletion and syntax highlighting.
Otherwise, you would have to open Android Studio for Kotlin and Xcode for Swift. And then you can go shopping while waiting for them to start.
Mindset
Using Neovim will completely change your mindset on how you approach coding and daily tasks. You will start to think more about efficiency, automation, and optimization. You will start thinking about how to make your life easier, how to make your config cleaner, and how to make your work more enjoyable. You will no longer accept that things must stay as they are. You will become the master of your tools, not the other way around.
If you buy a new computer, or even if you switch to another operating system, you will simply copy your config and you are ready to go. You will have the same environment, the same shortcuts, the same plugins, the same everything.
Text Is Everything
In Neovim, you will see that with just a text you can do almost anything. You can create a new, interesting UI, show animations, provide interactive elements, etc.
In this environment, everything is just a buffer with text. Which makes your experience, extremely consistent. For example, let’s say that you are seeing a list of unit tests, a tree. You know that you can use everything like in a normal text file. You can search, you can copy, jump, set marks, etc.
Almost every place in Neovim will give you consistent behavior, which is another huge advantage and something unique to this editor.
Customize Everything
You can change any behavior you want. You detect when a file with a specific suffix is opened and automatically generate a skeleton, split the window, and perform any setup you want.
You want to use SwiftFormat on every save of the file? Easy, just subscribe to the event, and run the command.
You want to jump between errors in the project? Easy, just add a keybinding to navigate through LSP errors.
You want to find a place where test class is declared and highlight it with a different color? Easy, just use tree-sitter, write a simple query, and set a desired highlight.
You want to add some custom operations on the current line? Just write a simple Lua function to get the current line, perform some operations, and replace it back. You can do it in your config with just a couple of lines, without knowing how to create a plugin.
You want to center the current line in the middle of the screen after you jump between search results? Easy, just map the next search and append extra zz
command to it.
You want to find something in json structure? Just select text, run command mode and type !jq YOUR_QUERY
, you will see the result in the current buffer.
Imagine that Xcode provides you a class that exposes all elements of the UI and you can manipulate them. This is how it works in Neovim. You’ve got access to vim.api
and you can do whatever you like with the editor.
The Xcodebuild.nvim Plugin
To prove that you can do anything with Neovim, a short story.
I wanted to start coding in Swift for iOS using Neovim, it wasn’t built-in, Apple is not making it easy to switch from Xcode, but I created a plugin that allows you to develop apps for any Apple platform in Neovim.
You can build, debug, run tests, see code coverage, and even modify xcodeproj
file or debug on physical devices. I just started working on this plugin with basic Lua knowledge and basic Neovim knowledge.
Now, I almost don’t use Xcode at all. Of course, there are some things that are still required to be done in Xcode, but most of the coding can be done in Neovim.
If you are interested in this plugin, you can check it out here: xcodebuild.nvim
Bonus: Copilot
If you are a fan of Copilot, you can use it in Neovim. Copilot has native support for Neovim and each suggestion appear as a “ghost text”. It extremely boosts productivity, because you can see the suggestions in the context of your code and it doesn’t cause context switching or distraction like pop-ups in Xcode.
Final Words
Remember, the choice of IDE is a very personal thing. You should use the tool that makes you the most productive and happy. If you are happy with Xcode, that’s great. But if you are not, give Neovim a try. It may be the best decision you ever made.
It will require from you some time to get used to it, but it’s worth it.
Don’t jump straight to Neovim. First, you must learn the basics of Vim motions. Otherwise, you may end up overwhelmed. You can enable Vim mode in Xcode, and start using it.
Once you feel comfortable with that, you can start using Neovim. First, see some tutorials from popular YouTubers, and gradually use it in your daily work.
After you feel comfortable with Neovim, vim motions, and basic Lua, you can start migrating your development to Neovim.
PS
There is no way to tell you everything on why Neovim is great in one article. It offers so many features that you will discover over time. It’s like a treasure hunt, where you find new gems every day.
Neovim truly changed my daily work and taught me so many new and exciting things, I can’t imagine not using it anymore.
What’s Next
Below you will find some helpful links:
- xcodebuild.nvim – my plugin, you will need it to develop for Apple platforms in Neovim
- ThePrimeagen – wizard of Neovim, you can learn a lot from him
- Configuring terminal and Neovim
- Another Neovim course
- Kickstarter.nvim – good config to start with and built based on that
- tmux introduction