Helix Editor: A Software Engineer's Guide to a Modern Modal Text Editor
Imagine an editor that takes the best ideas from Vim and Kakoune, then rebuilds them with modern sensibilities using the power of Rust. That's Helix in a nutshell!
Here's how it can be incredibly useful for a software engineer
Modal Editing, Reimagined (Vim users, listen up!)
If you're familiar with Vim's modal editing, you'll feel right at home with Helix, but with a twist. Instead of the traditional "verb + noun" sequence, Helix uses a "selection + action" model. You first select what you want to operate on, and then you apply an action. This might seem subtle, but it's incredibly intuitive and often feels more natural. It's like directly manipulating your code. This can lead to fewer keystrokes and a more fluid editing experience once you get the hang of it.
Built-in Language Server Protocol (LSP) Support
This is a huge one for software engineers. Helix comes with fantastic, out-of-the-box LSP support. This means you get features like
Intelligent Autocompletion
As you type, Helix suggests relevant code snippets, function names, and variables based on your project's context.
Go-to Definition
Quickly jump to the definition of a function, class, or variable, even if it's in another file.
Find References
Easily see where a function or variable is being used throughout your codebase.
Diagnostics (Errors & Warnings)
Helix highlights errors and warnings in real-time, helping you catch issues early.
Refactoring
Some LSP features allow for quick refactoring operations.
This native LSP integration significantly reduces the need for complex plugin configurations often found in other editors, letting you focus more on coding and less on tooling.
Multiple Selections as a Core Feature (Kakoune influence)
Kakoune popularized the idea of multiple selections as a primary editing mechanism, and Helix embraces this beautifully. Instead of tedious copy-pasting or complex regular expression searches for repetitive edits, you can select multiple occurrences of text and edit them all simultaneously. This is incredibly powerful for refactoring, changing variable names across a file, or applying similar edits in several places at once.
Tree-sitter Integration for Syntax Highlighting and Structural Editing
Helix leverages Tree-sitter, a parsing library that provides a more robust and accurate understanding of your code's structure than traditional regex-based syntax highlighters. This means
Superior Syntax Highlighting
More accurate and semantic highlighting, making your code easier to read.
Structural Selection
You can select entire functions, blocks, or expressions with a single command, making it much easier to move, delete, or modify code blocks. This is a game-changer for code organization.
Modal and Opinionated
Helix has strong opinions about how an editor should work, and this can be a good thing. It reduces decision fatigue and encourages a consistent workflow. While it might take a little getting used to, the consistency often pays off in terms of efficiency.
Fast and Resource-Efficient (Thanks, Rust!)
Being written in Rust, Helix is blazingly fast and has a small memory footprint. This means a smooth and responsive editing experience, even with large files or complex projects, which is always a plus for developers.
Installing Helix is generally straightforward. Here are the common methods
This is by far the easiest method for macOS users.
Open your Terminal.
Run the following command
brew install helix
That's it! Helix should now be installed.
If you have Rust and cargo installed, you can build Helix from source.
Install Rust and Cargo
If you don't have them, you can install rustup (the Rust toolchain installer) by running
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the on-screen instructions. You might need to restart your terminal or source your ~/.bashrc (or ~/.zshrc) file afterwards.
Install necessary dependencies (example for Debian/Ubuntu)
sudo apt install pkg-config libxcb1-dev libxkbcommon-dev
(Dependencies might vary slightly for other Linux distributions.)
Clone the Helix repository
git clone https://github.com/helix-editor/helix
cd helix
Build and install Helix
cargo install --path helix-term --locked
This will compile Helix and install it to your ~/.cargo/bin directory. Make sure this directory is in your PATH environment variable.
Using scoop (recommended for Windows users)
Open PowerShell.
If you don't have Scoop, install it
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Only needed once
irm get.scoop.sh | iex
Install Helix
scoop install helix
Building from source on Windows
Similar to Linux, you'll need Rust and Cargo installed, along with appropriate build tools (like those from Visual Studio Community Edition). The process is more involved than using Scoop.
Once installed, you can open a file with Helix by simply typing hx <filename> in your terminal
hx my_code.rs
Here are some fundamental commands to get you started
Insert Mode (i or a)
Press i to enter insert mode before the current selection.
Press a to enter insert mode after the current selection.
Type your code.
Press <Esc> to exit insert mode and return to normal mode.
Normal Mode (default mode after starting or after pressing <Esc>)
This is where you navigate and perform actions.
Saving (:w)
Press : to enter command mode.
Type w and press Enter.
Quitting (:q)
Press : to enter command mode.
Type q and press Enter.
To quit without saving, use :q!.
Basic Navigation
h, j, k, l
Move left, down, up, right.
w
Move to the start of the next word.
b
Move to the start of the previous word.
e
Move to the end of the current word.
gg
Go to the beginning of the file.
G
Go to the end of the file.
{line_number}gg or {line_number}G
Go to a specific line number.
Selections (the Helix way!)
w, b, e
Select a word (e.g., press w to select the current word).
L
Select the current line.
x
Extend selection by one character.
s
Select the current selection. This is a bit unique. If you have a word selected and press s, it will select the entire word again. If nothing is selected, s will select the current character.
alt-i + ( or [ or { or ' or "
Select the content inside the matching delimiters.
alt-a + ( or [ or { or ' or "
Select the content including the matching delimiters.
_ (underscore)
Select line contents (excluding leading/trailing whitespace).
Actions
Once you have a selection, you can perform an action
d
Delete selection.
c
Change selection (delete and enter insert mode).
y
Yank (copy) selection.
p
Paste after selection.
P
Paste before selection.
~
Toggle case of selection.
J
Join lines (if you have multiple lines selected).
Multiple Selections
alt-s
Select the next occurrence of the current selection. Pressing it repeatedly will select more occurrences.
alt-S
Select all occurrences of the current selection.
Once you have multiple selections, any action you perform (like c for change or d for delete) will apply to all of them!
Tree-sitter Selections (very powerful!)
(
Select the current node in the abstract syntax tree.
)
Select the parent node.
[
Select the next sibling node.
_
Select the previous sibling node.
This is just a tiny glimpse! Helix has a very comprehensive help system you can access by typing :h.
Let's imagine you have a simple Rust file named src/main.rs
fn main() {
println!("Hello, world!");
let mut greeting = "Hello";
let recipient = "Rustaceans";
println!("{}, {}!", greeting, recipient);
// Let's add a new line here
let message = format!("{} to all the {}", greeting, recipient);
println!("{}", message);
}
Here's a small workflow in Helix
Open the file
hx src/main.rs
Navigate to the println! macro on line 3
Type 3gg (or 3G).
Change "world" to "Helix"
Position your cursor on "world".
Press w to select the word "world".
Press c (change).
Type Helix.
Press <Esc> to exit insert mode.
Your code now looks like
println!("Hello, Helix!");
Rename greeting to salutation using multiple selections
Position your cursor on greeting on line 4.
Press w to select greeting.
Press alt-S (Shift + Alt + S) to select all occurrences of greeting in the file. You should now see greeting highlighted on lines 4, 6, and 9.
Press c (change).
Type salutation.
Press <Esc> to exit insert mode.
Now your code looks like
fn main() {
println!("Hello, Helix!");
let mut salutation = "Hello";
let recipient = "Rustaceans";
println!("{}, {}!", salutation, recipient);
// Let's add a new line here
let message = format!("{} to all the {}", salutation, recipient);
println!("{}", message);
}
Delete the comment line
Move your cursor to the line with // Let's add a new line here.
Press L to select the entire line.
Press d to delete it.
Save and Quit
Press :
Type wq and press Enter. (This saves and quits)
This is just a basic example, but it demonstrates the core "selection + action" paradigm and the power of multiple selections.
Helix's configuration is done via a TOML file, typically ~/.config/helix/config.toml (or AppData\Roaming\helix\config.toml on Windows). You can configure keybindings, themes, LSP settings, and more.
A simple config.toml might look like this
theme = "tokyonight_night"
[editor]
line-number = "relative"
true-colors = true
# ... more editor settings
[editor.cursor-shape]
normal = "block"
insert = "bar"
select = "underline"
[editor.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'
"'" = "'"
'`' = '`'
[keys.normal]
# Custom keybinding example: map Ctrl-s to save
"C-s" = ":w"