Notes on switching to Helix from vim - Julia Evans

Notes on switching to Helix from vim - Julia Evans

Julia Evans

Hello! Earlier this summer I was talking to a friend about how much Ilove using fish, andhow I love that I don’t have to configure it. They said that they feel the sameway about the helix text editor, and so I decidedto give it a try.

I’ve been using it for 3 months now and here are a few notes.

why helix: language servers

I think what motivated me to try Helix is that I’ve been trying to get a workinglanguage server setup (so I can do things like “go to definition”) and gettinga setup that feels good in Vim or Neovim just felt like too much work.

After using Vim/Neovim for 20 years, I’ve tried both “build my own customconfiguration from scratch” and “use someone else’s pre-buld configurationsystem” and even though I love Vim I was excited about having things just workwithout having to work on my configuration at all.

Helix comes with built in language server support, and it feels niceto be able to do things like “rename this symbol” in any language.

the search is great

One of my favourite things about Helix is the search! If I’m searching all thefiles in my repository for a string, it lets me scroll through the potentialmatching files and see the full context of the match, like this:

For comparison, here’s what the vim ripgrep plugin I’ve been using looks like:

There’s no context for what else is around that line.

the quick reference is nice

One thing I like about Helix is that when I press g, I get a little help popuptelling me places I can go. I really appreciate this because I don’t often usethe “go to definition” or “go to reference” feature and I often forget thekeyboard shortcut.

some vim -> helix translations

  • Helix doesn’t have marks like ma, 'a, instead I’ve been using Ctrl+O andCtrl+I to go back (or forward) to the last cursor locarion
  • I think Helix does have macros, but I’ve been using multiple cursors in everycase that I would have previously used a macro. I like multiple cursors a lotmore than writing macros all the time. If I want to batch change something inthe document, my workflow is to press % (to highlight everything), then sto select (with a regex) the things I want to change, then I can just editall of them as needed.
  • Helix doesn’t have tabs, instead it has a nice buffer switcher (b)I can use to switch to the buffer I want

some helix annoyances

Here’s everything that’s annoyed me about Helix so far.

  • I like the way Helix’s :reflow works much less than howvim reflows text with gq. It doesn’t work as well with lists. (github issue)
  • If I’m making a Markdown list, pressing “enter” at the end of a list itemwon’t continue the list. There’s a partial workaroundfor bulleted lists but I don’t know one for numbered lists.
  • No persistent undo yet: in vim I could use anundofile sothat I could undo changes even after quitting. Helix doesn’t have that feature yet.(github PR)
  • Helix doesn’t autoreload files after they change on disk, I have to run:reload-all (:ra) to manually reload them. Not a big deal.
  • Sometimes it crashes: every week or so there’s a segfault and the editorcrashes. Someone mentioned that this might have something to do withthe fact that I edit a lot of Markdown, not sure.This doesn’t bother me that much though, I can just reopen it.

The “markdown list” and reflowing issues come up a lot for me because I spenda lot of time editing Markdown lists, but I keep using Helix anyway so I guessthey can’t be making me that mad.

switching was easier than I thought

I was worried that relearning 20 years of Vim muscle memory would be really hard.

It turned out to be easier than I expected, I started using Helix on avacation for a little low-stakes coding project I was doing on the side andafter a week or two it didn’t feel so disorienting anymore. I think it might behard to switch back and forth between Vim and Helix, but I haven’t needed to useVim recently so I don’t know if that’ll ever become an issue for me.

The first time I tried Helix I tried to force it to use keybindings that weremore similar to Vim and that did not work for me. Just learning the “Helix way”was a lot easier.

There are still some things that throw me off: for example w in vim and w inHelix don’t have the same idea of what a “word” is (the Helix one includes thespace after the word, the Vim one doesn’t).

using a terminal-based text editor

For many years I’d mostly been using a GUI version of vim/neovim, so switchingto actually using an editor in the terminal was a bit of an adjustment.

I ended up deciding on:

  1. Every project gets its own terminal window, and all of the tabs in thatwindow (mostly) have the same working directory
  2. I make my Helix tab the first tab in the terminal window

It works pretty well, I might actually like it better than my previous workflow.

my configuration

I appreciate that my configuration is really simple, compared to my neovimconfiguration which is hundreds of lines. It’s mostly just 4 keyboardshortcuts.

theme = "solarized_light"[editor]# Sync clipboard with system clipboarddefault-yank-register = "+"[keys.normal]# I didn't like that Ctrl+C was the default "toggle comments" shortcut"#" = "toggle_comments"# I didn't feel like learning a different way# to go to the beginning/end of a line so# I remapped ^ and $"^" = "goto_first_nonwhitespace""$" = "goto_line_end"[keys.select]"^" = "goto_first_nonwhitespace""$" = "goto_line_end"[keys.normal.space]# I write a lot of text so I need to constantly reflow,# and missed vim's `gq` shortcutl = ":reflow"

There’s a separate languages.toml configuration where I set some languagepreferences, like turning off autoformatting.For example, here’s my Python configuration:

[[language]]name = "python"formatter = { command = "black", args = ["--stdin-filename", "%{buffer_name}", "-"] }language-servers = ["pyright"]auto-format = false

we’ll see how it goes

Three months is not that long, and it’s possible that I’ll decide to go backto Vim at some point. For example, I wrote a post about switching tonix a while back butafter maybe 8 months I switched back to Homebrew (though I’m still using NixOSto manage one little server, and I’m still satisfied with that).


本文章由 flowerss 抓取自RSS,版权归源站点所有。

查看原文:Notes on switching to Helix from vim - Julia Evans

Report Page