I have always been torn between text editors and IDEs when writing code. Text editors often lack some features that have to be complemented by plugins, while IDEs often get too complicated and in your way, which can be dangerous if you start relying on some features that you don't fully understand.
I started using vim a long time ago, and came to like its modal nature (one mode to insert text, one mode to select text, one mode to modify the selection). However, without many plugins, it was not really easy to use as a code editor, because you didn't get much out of it (for instance, there is no way to jump to the definition of a function under the cursor by default). When you start to dive into the available plugins, you can get lost easily, and for the frugal and lazy user I tend to be, this was too much of a hassle.
Something I enjoyed with vim was the idea of making sentences to act on
the text. For instance, with the cursor under the first letter of a word in
normal mode, you can replace it by typing cw
, which literally stands for
"change word". The flip side of this is that you cannot visualize the block
of text you're going to impact. In the simple cw
example, it's easy, but
when you start working on lines or paragraphs, it becomes much more difficult.
A few years back, I heard about Kakoune, an alternative to vim which worked by reverting the order of the actions: you would first select the block of text to work on, then act upon it. This was a great way of dealing with text! However, much like vim, it was a text editor at heart, not so much a code editor unless you were ready to spend quite a lot of time to customize it.
Then, last year, I heard about Helix. It uses metaphors similar to Kakoune to handle text selection, but it also comes "batteries included", which means you don't have to spend a lot of time customizing it to squeeze a lot out of it.
An important feature of Helix is its support of the Language Server
Protocol, which means that, much like VS Code, you can navigate code
bases pretty easily without having to do much apart from installing the
support library for the programming languages of your choice. In my case,
as a Python developer, it means installing the python3-pylsp
package and
I'm good to go. To check what capabilities Helix has activated, you can run
hx --health
which displays a health report containing, among other things,
the current level of support for many programming languages.
Here are a few things I use very often when working with Helix:
- To select a line, I press
x
. To select multiple ones, I can prefix it with a number (3x
, like in vim), or I just keep pressingx
until everything I need is selected. An alternative way is to use the selection mode by pressingv
and moving the cursor around. gd
goes to the definition of the function under the cursor. This is very handy to see quickly what a given function is doing. To come back, you can pressCtrl+o
to go back one step "outside" of your navigation history (Ctrl+i
allows you to navigate in the opposite direction).- If I want to quickly rename all the occurrences of a text in the file, I
press
%
to select everything, thens
to search for the text (validating this with theEnter
key). This creates selection blocks of all the occurrences. I can then pressc
to "change" that text into something else. This is basically making use of the multi-selection feature of Helix. - To quickly open a file, I press the
Space
key to enter the Space mode, thenf
to select the File picker. When you pressSpace
, Helix actually shows you a little panel with all the available options, which is handy to get to know them (it's the same for the Matching mode for instance, when you select a word and pressm
). - To find all the occurrences of a given text in every files of the code base,
I use the Global search options by pressing
Space
and/
. This is useful to see where a function is being called, for instance. - To quickly comment or uncomment the selected code, I press
Ctrl-c
.
I highly recommend going through the tutorial (by running hx --tutor
)
to learn the basics of Helix and get to learn some of its specific features.
Finally, even though Helix defaults are pretty good, it is still highly customizable. Here are some of the changes I use:
# Lovely theme which works better than the default one with rulers (see below)
theme = "catppuccin_frappe"
[editor]
# Show currently open buffers, only when more than one exists.
# This provides a line of "buffer tabs" at the top of the screen
bufferline = "multiple"
text-width = 80
rulers = [80]
# I find the auto-completion pop-up panel a bit too much "in your face", so
# I deactivated it for the moment
auto-completion = false
[keys.normal]
# Alt-, and Alt-. to go to previous/next buffer
"A-," = "goto_previous_buffer"
"A-." = "goto_next_buffer"
# Deselect the last selected line. This is useful when you pressed x too many
# times...
X = ["extend_line_up", "extend_to_line_bounds"]
# To mimic vim's shortcut to go to the bottom of a file
G = "goto_file_end"
[editor.lsp]
# Disable automatically popups of signature parameter help that take up quite
# a lot of space.
auto-signature-help = false
I highly recommend this editor. The documentation is rather comprehensive, and the community is very nice and always ready to help, so give it a try!