src/content/post/leaving-neovim-for-zed.mdx 16.9 K raw
1
---
2
title: "Leaving Neovim for Zed"
3
publishDate: "16 Aug 2024"
4
description: "A journey through text editors and how I landed on Zed after years of Neovim"
5
tags: ["programming", "developer tools", "neovim"]
6
ogImage: "../../assets/blog-images/leaving-neovim-for-zed.png"
7
atUri: "at://did:plc:ia2zdnhjaokf5lazhxrmj6eu/site.standard.document/3mdzvurqlyn2v"
8
---
9
10
![header image](../../assets/blog-images/leaving-neovim-for-zed.png)
11
12
I think every developer has their own text editor journey and how they landed on the tool they use today. Perhaps I'm a geek but I love those stories. I have a great appreciation for developer tools and the work that goes into them. This post is for the other geeks out there that also care, and I hope my journey and perspective can prompt others to experiment and try developer tools outside their comfort zones. You never know what you might land on and how much you might enjoy it!
13
14
My text editor journey starts with a faint memory of Atom. I was learning the true fundamentals of HTML CSS and Javascript, and I honestly can't tell you how I landed on Atom as a text editor. I do remember using it for a few weeks, and I kept seeing other people use or mention VSCode, so of course I gave it a shot and used it for a while. However this didn't last long. At the time my wife needed my laptop for her photo editing job, so I used my brother's old Macbook that was holding on for dear life. VSCode's Electron build started taking a noticeable toll on performance, and by chance I also discovered Vim around the same time.
15
16
Immediately I was mesmerized by the speed and powers demonstrated by The Primeagen's early videos. I was already a keyboard maximalist from [previous jobs](/posts/why-i-learned-vim) where I learned speed = productivity, so it was a no brainer that I had to learn it. Started with the basic motions and Vim tutor, and I had the advantage that I was just learning programming on the side instead of doing it full time. Within a few weeks I was in Vim consistently, writing and learning to code. The tweaking of my Vim RC eventually led to discovering Neovim thanks to [chris@machine](https://www.youtube.com/@chrisatmachine) and his early videos.
17
18
For the next several years I stuck with Neovim and I loved it, and I owe a mass amount of my productivity to it. There were countless hours spent configuring it like many of us do. I eventually got to a point where I didn't adjust my config much, but that soon didn't matter.
19
20
## What Changed
21
22
Every now and then I would update a plugin in Neovim and everything would break, and I would have to spend time fixing it instead of getting work done. This resulted in slimming down my config more and more, but there was still so much that went into making all the basics work. I stuck with it because it was still better than using VSCode, which I did try for a two week sprint to see if it could be any better. It was also key to a [terminal based workflow](/posts/a-terminal-based-workflow) that other editors couldn't really match.
23
24
The sentiment started to shift again not too long ago as I started working in some really large code bases, and boy Neovim was struggling. I would have random hang ups, frozen screens, stuff that just drove me nuts when productivity was king. I tried switching to other terminal emulators too such as Alacritty and Wezterm but it didn’t help much.
25
26
This is when Zed came back into my sights. I heard about it months before and even gave it a shot back then, but didn't stick with it because it wasn't a terminal workflow. However it boasted as being fast, and I decided it was worth another shot. Two months later and I've been daily driving it since. I wasn't sure if it would really hold up, but I can say now it has been an amazing experience and I don't see myself going back.
27
28
## My Experience with Zed
29
30
In order to understand why I eventually settled on Zed we'll look at my general experience with it so far and how I made it work for me.
31
32
### It Just Works
33
34
One of the biggest things that has stood out to me using Zed so far is how “everything just works.” There are so many features of an IDE or text editor that people take for granted until they have to set it up themselves in something lower level like Neovim. LSP (language server protocol) is certainly one of them. If you’re not familiar it’s the hints or errors that show up while you’re writing up your code, giving you deep insights to your repo on a language level. When you setup LSP in Neovim it’s a lot of work, and sometimes it can be a bit harder to figure out why it might be bugging out. However it does give you way more control and the option to do a lot of customization. With Zed LSP just works. There are configurations you can make to edit some things, but as a whole it just zips out of the box. There are already keybindings for things like “show definition”, “go to definition”, or even code actions. The only downside is outside of an extension you can’t use your own LSP that’s installed on your machine, but there’s always a pretty large language support that I haven’t had this issue yet.
35
36
![LSP demo](../../assets/blog-images/lsp-demo.png)
37
38
Another piece that’s related to LSP is completions. This is when you’re typing some code and get suggestions for auto completions that quickly fill the rest of the code out. LSPs usually have great auto-completion because they’re aware of the patterns used in that language. Just to be clear we’re not talking about Copilot yet, this is just completions for snippets and LSP. Once again with Zed it just works out of the box, unlike Neovim which ends up requiring several plugins to make it work right.
39
40
<video
41
  autoPlay
42
  muted
43
  loop
44
  playsinline
45
  className="aspect-video w-full"
46
  src="/blog-images/completions.mp4"
47
></video>
48
49
Finally there’s Git integrations. What normally required multiple plugins in Neovim is again ready out of the box with Zed, including feature like toggling Git Blame, viewing diffs, and gutter symbols showing the status of edited lines.
50
51
<video
52
  autoPlay
53
  muted
54
  loop
55
  playsinline
56
  className="aspect-video w-full"
57
  src="/blog-images/git-integrations.mp4"
58
></video>
59
60
If I had to make a crude comparison, it’s similar to Linux and Apple. Linux will give you far more control over every piece of your software and hardware at the cost of spending time to configure it. Apple will give you less control but it will likely run smoother.
61
62
### Speed
63
64
Of course one of the biggest reasons I gave Zed a shot was speed, and boy it was worth it. It is noticeably snappy, handles larger codebases like a champ, and I haven’t experienced any lag so far. Normally I wouldn’t recommend building most things in Rust, but this app kinda makes me reconsider. There are so many developer tools written in Rust and perhaps that’s one of its biggest boasts. The team at Zed have really outdone themselves as this app; its truly a work of art.
65
66
Could I possibly make neovim faster by adjusting my config? Perhaps, but in the end it’s more time down the drain that I could have used writing code and being productive. For productivity nerds like me I believe there is a delicate scale: how much time I spend automating a task vs how much time the task would have taken without automation. In this case the benefits aren’t worth the cost when there’s a tool like Zed that will do just fine.
67
68
### Vim Mode
69
70
While in the middle of my time with Neovim I came across other frustrated Neovim users that found themselves spending too much time fixing issues in Neovim to the point they switched to VSCode. Of course I had a few moments like this myself and I wondered if I had missed something. At this point I had a much faster computer, so I figured I would give it another shot. Of course I downloaded the Vim plugin as the Vim keybindings are worth learning no matter what text editor you use, and it was incredibly disappointing. Nothing had ever felt so buggy and jagged, and it remained one of the big reasons I couldn't stick with VSCode. I was back in Neovim within a week or two.
71
72
When I was considering Zed again I read [a blog post](https://registerspill.thorstenball.com/p/from-vim-to-zed) about the custom Vim mode built into Zed. This was not a third party plugin; this was a labor of love from the developers building Zed. They've made it clear that they don't plan to port absolutely everything to Zed, but they have done a fantastic job supporting the important stuff that makes the editor an S-tier experience.
73
74
I'll likely get into this further into the post, but the way you can structure keybindings for Vim mode in Zed is fantastic. The structure allows for your typical VScode style config, but with the ability to scope a keybinding to a Vim mode is such a huge win for Neovim users. For instance, I can cheat my way into using a leader key when in normal mode and get things like `space d` to see diagnostics, or `space t` to open a full window terminal. It's a pattern many Vim users will appreciate and I wish there was more docs for it as I've had to figure some of it out myself.
75
76
Beyond keybindings all the other stuff you would expect in Vim motions are here, with of course a few obscure ones slowly being added release by release. Some of them take a unique approach by using some of Zed’s built in features as a replacement for what Vim would normally use, like search and replace for example. Generally you would have to do a Vim command to search for a word and replace it, and those commands still do what you expect, but it brings up Zed’s Multibuffer view when doing a project wide search. You get Vim mode but it’s still Zed and it’s unique feature set.
77
78
### AI Stuff
79
80
When it comes to AI features I think Zed provides some great built in tools. I will disclose that I'm not a big user of AI within the text editor (a topic for another blog post), so there might be things you're looking for compared to Cursor that I can't speak to. With that said it does have Copilot built in which is probably what most people want to know.
81
82
Zed also features an assistant panel where you can access several AI models via API, including OpenAI, Ollama, and Anthropic. Just requires a few lines of config to get started.
83
84
<video
85
  autoPlay
86
  muted
87
  loop
88
  playsinline
89
  className="aspect-video w-full"
90
  src="/blog-images/assistant-panel.mp4"
91
></video>
92
93
One feature that I think is particularly nice is the inline assistant, where you can select some lines of code and use `ctrl-enter` to trigger a request to be made to your code via the AI assistance configuration mentioned previously. If you like the results then you can confirm and keep coding.
94
95
<video
96
  autoPlay
97
  muted
98
  loop
99
  playsinline
100
  className="aspect-video w-full"
101
  src="/blog-images/inline-assistant.mp4"
102
></video>
103
104
### Zed ≠ Neovim
105
106
You can probably gather so far that I’m a huge Zed fan, however I will say it’s not a 1/1 replacement to Neovim. What makes Neovim so special is that it’s native to the terminal. Whenever I need to edit a configuration file for an app or just edit something really quickly while I’m already navigating in a terminal, nothing beats the convenience of whipping out Neovim. Opening Zed for every single file like that would get exhausting, but for longer term sessions or projects it’s perfect. If you compare to motorcycles, Neovim is my dirt bike and Zed is my cruiser.
107
108
## Making Zed Work for A Neovim User
109
110
While Zed can't truly be a drop in replacement of Neovim, there are a lot of small configurations that really help improve the experience and make it familiar to a Neovim/Vim user.
111
112
### Vim Mode & Keybindings
113
114
First one is obvious, turn on Vim mode. Zed has a great [docs page](https://zed.dev/docs/vim) with loads of extra info, some default Vim bindings, and some extra configs available to make it work for you. By far my favorite piece that I mentioned earlier is the ability to do key bindings based on Vim modes. Here's some examples:
115
116
```json keymap.json
117
[
118
  {
119
    "context": "Editor && VimControl && !VimWaiting && !menu",
120
    "bindings": {
121
      "space b": "editor::ToggleGitBlame",
122
      "shift-k": "editor::Hover",
123
      "space l f": "editor::Format",
124
      "space d": "diagnostics::Deploy",
125
      "space f f": "file_finder::Toggle",
126
      "space o": "tab_switcher::Toggle",
127
      "space e": "workspace::ToggleLeftDock",
128
      "space /": "workspace::NewSearch",
129
      "n": "search::SelectNextMatch",
130
      "shift-n": "search::SelectPrevMatch",
131
      "space t": "workspace::NewCenterTerminal",
132
      "g b": "editor::ToggleComments",
133
      "+ +": "workspace::Save",
134
      "space c": "pane::CloseActiveItem"
135
    }
136
  },
137
  {
138
    "context": "Editor && vim_mode == visual && !VimWaiting && !VimObject",
139
    "bindings": {
140
      "shift-j": "editor::MoveLineDown",
141
      "shift-k": "editor::MoveLineUp"
142
    }
143
  }
144
]
145
```
146
147
Most of these are pretty self explanatory, but the key is that the first set is in "Normal" mode, while the next set is "Visual." There's also small improvements or shortcuts they provide in the docs like this set of key bindings that allows you to switch panes similar to how most people have Neovim setup.
148
149
```json keymap.json
150
[
151
  {
152
    "context": "Dock || Terminal || Editor",
153
    "bindings": {
154
      "ctrl-h": ["workspace::ActivatePaneInDirection", "Left"],
155
      "ctrl-l": ["workspace::ActivatePaneInDirection", "Right"],
156
      "ctrl-k": ["workspace::ActivatePaneInDirection", "Up"],
157
      "ctrl-j": ["workspace::ActivatePaneInDirection", "Down"]
158
    }
159
  }
160
]
161
```
162
163
Something else I would recommend to anyone who is trying to migrate from Vim/Neovim to Zed is checking out the [default Vim keymap](https://github.com/zed-industries/zed/blob/340a1d145ed15e39a4a27afc5a189851308fb91d/assets/keymaps/vim.json#L4). There's so much there that acts as a helpful reference of what's supported and what you may want to adjust!
164
165
### Reduced UI
166
167
Zed already has a pretty nice minimal UI, but I prefer something closer to my Neovim setup. Thankfully Zed offers these options, such as disabling the tab bar, scroll bar, reduced toolbar, and relative line numbers
168
169
```json settings.json
170
{
171
  "cursor_blink": false,
172
  "relative_line_numbers": true,
173
  "scrollbar": {
174
    "show": "never"
175
  },
176
  "vertical_scroll_margin": 0,
177
  "tab_bar": {
178
    "show": false
179
  },
180
  "toolbar": {
181
    "breadcrumbs": true,
182
    "quick_actions": false
183
  }
184
}
185
```
186
187
![Zed settings](../../assets/blog-images/zed-settings.png)
188
189
### Plugin Replacements
190
191
Since I don't use the tab bar I wanted something similar to Telescope to navigate between buffers or files, and thankfully there is an option for that! This key binding will show currently open all buffers, which is separate from the file finder.
192
193
```json keymap.json
194
{
195
  "context": "Editor && VimControl && !VimWaiting && !menu",
196
  "bindings": {
197
    "space o": "tab_switcher::Toggle"
198
  }
199
}
200
```
201
202
<video
203
  autoPlay
204
  muted
205
  loop
206
  playsinline
207
  className="aspect-video w-full"
208
  src="/blog-images/tab-switcher.mp4"
209
></video>
210
211
Speaking of Telescope, one big replacement is project wide search. While Zed doesn't have a fuzzy find feature, the project wide search is excellent. It will show all results in a multibuffer view which is pretty slick, and allows you to jump between that view and the buffer itself pretty easily.
212
213
<video
214
  autoPlay
215
  muted
216
  loop
217
  playsinline
218
  className="aspect-video w-full"
219
  src="/blog-images/project-search.mp4"
220
></video>
221
222
The terminal toggle is pretty similar to something like VSCode but there are some other hidden ways to get a better terminal experience. One of them is a shortcut to toggle the bottom terminal to be full screen, but even better is opening a terminal as a buffer in the main editing view.
223
224
```json
225
{
226
  "context": "Editor && VimControl && !VimWaiting && !menu",
227
  "bindings": {
228
    "space t": "workspace::NewCenterTerminal"
229
  }
230
}
231
```
232
233
<video
234
  autoPlay
235
  muted
236
  loop
237
  playsinline
238
  className="aspect-video w-full"
239
  src="/blog-images/center-terminal.mp4"
240
></video>
241
242
One of the big things I had to leave behind was Tmux and switching projects. While it isn't a perfect replacement, Zed has a "switch projects" feature which works really well and makes it pretty easy to switch contexts. You just won't get the exact same control and layout setup that you can get with Tmux
243
244
```json
245
{
246
  "context": "Workspace",
247
  "bindings": {
248
    "cmd-k": [
249
      "projects::OpenRecent",
250
      {
251
        "create_new_window": false
252
      }
253
    ]
254
  }
255
}
256
```
257
258
<video
259
  autoPlay
260
  muted
261
  loop
262
  playsinline
263
  className="aspect-video w-full"
264
  src="/blog-images/switch-projects.mp4"
265
></video>
266
267
## Should You Use Zed?
268
269
If you’re still on the fence of trying Zed I would say it’s at least worth giving it a shot for a few days. In my experience so far it’s a unique and capable text editor, but ultimately I vouch for anything that makes you more productive. That might end up being VS Code or Jetbrains or hell maybe even EMacs. Do what’s best for you, but don’t be too stubborn to try something new.
270
271
Edit: Thank you for all the love on this post! If you want to see my full settings and keymaps I have them linked below for your convenience.
272
273
[settings.json](https://sipp.stevedylan.dev/s/AfQ6gyKPF7)
274
275
[keymap.json](https://sipp.stevedylan.dev/s/05l9VQyh92)