❌

Reading view

There are new articles available, click to refresh the page.

NeoVim Too Complex? Try Helix as Your First Modal Editor

Helix

Helix is a modal text editor that operates much like Vim or Neovim. While switching from a GUI like VSCode takes some practice, mastering a terminal editor truly boosts your daily productivity.

Starting with Helix is a smooth experience if you have never used modal editors before. The default settings are intuitive, provided you are familiar with your keyboard layout.

You can avoid the hassle of learning a specific programming language just to configure your workspace. Helix delivers a complete and powerful experience right after you install it.

In my opinion, I suggest Helix if you want the Neovim vibe without the massive time investment. It includes modern tools like language server protocols and tree sitter support by default.

🚧
Helix does not have a plugin system at the moment.

Let's look at how you can get started with Helix as your very first modal text editor.

Installing Helix

Helix is available in the official repositories for several Linux distributions, like Arch Linux, Fedora, and Ubuntu. To install it on Arch Linux, use the command:

sudo pacman -S helix

If you are a Fedora user, install the editor with:

sudo dnf install helix

Ubuntu 26.04 LTS and above also includes Helix in its official repositories. You can install it using:

sudo apt install hx
πŸ“‹
In Ubuntu, the command name is hx and not helix.

For all other users, pre-built binaries are available in the official Helix GitHub repository. You can follow the official documentation to complete the installation of these binaries.

Modes in Helix

Helix is a modal editor. It means Helix has different modes with dedicated purposes.

Without having an understanding of the modes, it is hard to grasp how the editor works. So, let's see them one by one.

πŸ’‘
Unlike Vim, Helix follows a select β†’ action model. You always highlight text first, then perform an operation on it. If something feels backwards coming from Vim, this is likely why.

The Normal Mode

Normal mode is the default state in most modal text editors, where you perform all text manipulations.

Whenever you are elsewhere in the editor, simply press the ESC key to return to this home base. Unlike a traditional editor where you are always in a typing state, modal editors use this mode as a starting point.

For example, you can scroll down a couple of lines by pressing j while in normal mode. You can also remove a character under the cursor by pressing d.

You cannot type any text while you are in this Normal mode. To start typing, you must enter insert mode by pressing i while the editor is in its normal state.

The Insert Mode

Insert mode is the state where you actually type your text. Most traditional GUI editors, like VSCode, have this mode only where all text actions are carried out with the help of keyboard and mouse.

While in insert mode, you generally focus on entering text rather than deleting or copying it. You can still use the arrow keys to move the cursor around in both normal and insert modes.

Whenever you finish typing, simply press ESC to return to normal mode.

πŸ’‘
Some other text actions are supported in Insert mode, which takes help of the CTRL and ALT key. Take a look at the documentation for these commands in insert mode.

Select Mode

Select mode is the equivalent of Visual mode in Vim and is used specifically for highlighting text. You enter this mode by pressing v while in the Normal mode.

The character under your cursor is automatically selected as soon as you enter this mode. You then use navigation keys to extend that selection across your text.

For example, pressing l will extend the selection to the next character, and pressing it again adds the third. You cannot type any new text while you are in this state.

In my experience, combining this with movement shortcuts is incredibly powerful. For instance, I can press v followed by ge to instantly select everything from my cursor to the last line.

You can even press the END key to include the entire last line in your selection. This allows you to highlight massive blocks of text with just a few keystrokes.

Once your selection is finished, use the Normal mode keys to perform an action.

🚧
In Select mode, you can directly apply operators like d, y, c on your selection. No need to press Escape first. The operator acts on the selection and drops you back into Normal mode.

Pressing d will delete the entire highlighted block, while y will copy it for later use.

Other modes of purpose

The above three are the main modes in Helix. But there are some more modes that you may come across.

Command Mode

When you press : in normal mode, you enter the command mode. Here, you can enter supported commands.

Some important operations, like saving a file, quitting the editor, etc., are performed in the command mode.

To save the current file, and quit the editor:

:wq

Helix offers a lot of commands that you can use. Its official documentation on commands has listed it more efficiently.

Picker Mode

Picker mode is triggered by pressing the Space key in normal mode. It is a fuzzy finder interface, where you can invoke a file picker, buffer picker, etc.

If you know Neovim, this picker mode can be a minimal close equivalent of the Telescope plugin.

For example, we can use Space + f to open a file picker.

Also, if I select a block of text and press Space + Shift + c, then you can block comment that section, and so on.

0:00
/0:21

Comment code in Helix

Helix shows the actions

For supplementary modes like picker mode, Helix shows what to press next in a neat pop up.

When you press space, you can see that a pop-up comes up that says all keys and their uses, so that you can read and follow.

Another one I suggest you try is press the g key and read all the subkeys and their functions.

Press the g key to get some interesting actions in Helix
Pressing the g key

Access the tutor

Helix has an interactive tutorial available to get you started, like the Vim tutor.

Open a terminal and run the command:

helix --tutor

This will take you to a text, which you will read and perform actions as described.

A beginner should complete this tutorial since it gives you a lot of day-to-day shortcut practice inside a sample text.

Essential Keybindings

Helix works flawlessly right out of the box. You do not need any configuration files to make any part of the editor work in the beginning.

But, since it depends on keybindings, before going to other areas, let's see some essential shortcuts to get you started.

Shortcuts to move around the text in Normal mode.

Description Shortcuts
Move one character left/bottom/top/right h/j/k/l
Move to the start of the next word w
Move to the start of the next word (punctuations included) W
Move back to the start of the word b
Move back to the start of the word (punctuation included) B
Move to the end of the next word e
Move to the end of the next word (punctuations included) E
Move to the last line of the text ge
Move to the first line of the text gg
Move to the nth line <n>G
Move to the start of the line HOME
Move to the end of the line END
Move page up PgUp
Move page down PgDn

Shortcuts to change the text in Normal Mode

Description Shortcut
Insert before cursor (Enter insert mode) i
Insert after cursor a
Insert at the beginning of the line I
Insert at the end of a line (append) A
Open a new line below cursor and enter insert mode o
Open a new line above cursor and enter insert mode O
Replace character under cursor r<character>
Delete/cut character under cursor (or selection) d
Yank (copy) selection y
Paste selection p
Paste before cursor P
Yank (copy) to a named register a "<a>y
Paste from a named register a "<a>p
Undo a change u
Redo a change U
πŸ’‘
Always use registers to yank texts. This way, it is easy to confirm where a copied text is and easier to paste later.
🚧
The deletion shortcut d actually cuts the selected word and stored. So, if you have some texts yanked, and then deleted some other text, the deleted text will be the one pasted when you press p. So, use registers for copying important text.

Other routine shortcuts

Description Shortcut Mode
Search for a pattern in the text /<search term> Normal
Select next search match n Selection
Select previous search match Shift + n Selection
Run the command in a shell :!<command> Normal
Run the command and add its output to a line :r !<command> Normal

You can refer to the official keymap documentation for a lot more keyboard shortcuts across modes for specific use cases.

Create a config file

Helix doesn't need a user-written config file to work since it comes with many usable defaults. Still, changing away from defaults needs a config file.

Helix uses the TOML configuration file, located at ~/.config/helix/config.toml.

First, create the directory if it does not exist.

mkdir -p ~/.config/helix/

Now, create a file inside this directory like:

touch ~/.config/helix/config.toml

A different theme

Helix comes with a lot of themes preinstalled, and you don't want to create a long config for it.

Open Helix in a terminal:

helix

Inside Helix, in Normal mode, enter :theme, press a space, and press the TAB key.

You can see that themes begin to show preview. Press TAB to scroll through the live preview of themes. When you spot a theme of your choice, note the name of the theme and press Enter.

πŸ“‹
If you have downloaded the Helix binary, then set of themes are in the runtime folder. Make sure you placed it properly as the documentation say.

Upon pressing the enter key, the theme will be applied to the current session.

To make it permanent, you need to add one line to the Helix config file.

Edit the config file with your favorite text editor.

helix ~/.config/helix/config.toml

And add the line

theme = "theme-name"

For example,

theme = "tokyonight"

Language support

Helix comes with Language Server Protocol Support preset, so there is no need to worry about configuring the LSP.

Still, you need to setup the language server though.

I am using Arch Linux in this example, and in Arch Linux, most of the language server you need are available in the official repository.

To set up CSS support, install the vscode-css-language-server

sudo pacman -S vscode-css-languageserver

Helix will spot this , and you can start working on CSS files from your next start.

0:00
/0:52

CSS Language Completion in Helix

To set up Rust support, install the rust-analyzer package:

sudo pacman -S rust-analyzer

Refer to the Language support page in the official documentation to know what package needs to be setup to get the language support working.

Multiple Cursors

Helix supports multiple cursors out of the box. You can duplicate your cursor downward by pressing Shift + c in Normal mode.

0:00
/0:22

Multiple Cursors in Helix

This lets you edit several lines at once. If you end up with multiple cursors by accident, press , to collapse back to a single cursor.

Wrapping Up

Helix is a decent modal editor, that offers most of the modern features you would expect in the convenience of an easier learning curve.

I won't suggest replacing Neovim or Vim with Helix if you have mastered those editors. But, if you are into modal editing, or terminal-based text editing in general, Helix is the best place to start.

Will you use Helix for all your coding purposes? Or you have another editor that meets all your needs? Do mention in the comments.

This Overlooked Linux mv Option Replaces Three Commands With One

mv exchange

Every Linux user has done the three-step dance at least once. You want to swap two files, so you move the first one to a temporary name, move the second one into its place, and then move the temporary file back.

Ever felt that this is a bit... clumsy? And for a moment, one of your files simply doesn't exist. That doesn't feel right!

Since version 9.5, GNU coreutils has a better way: mv --exchange.

In this article, I'll show you what it does, how to check if your system has it, where it actually helps, and the mistake I made the first time I used it on directories.

The old way: three moves and a temporary name

Let's say you have two configuration files, nginx.conf and nginx.conf.new, and you want the new one to take the place of the old one while keeping the old one around.

The classic approach looks like this with the mv command:

mv nginx.conf nginx.conf.tmp
mv nginx.conf.new nginx.conf
mv nginx.conf.tmp nginx.conf.new

There are two problems here:

  • There is a gap. Between the first and second command, nginx.conf doesn't exist. If a service reads it at that exact moment, it finds nothing (and trust me, one day that will happen).
  • It can fail halfway. If the second command fails, you are left with a temporary file and a half-finished swap to clean up by hand.

The exchange option does this in a single command:

mv --exchange nginx.conf nginx.conf.new

Swap files with mv --exchange

The --exchange option tells mv to swap the two paths in a single operation. On Linux, it uses the kernel's renameat2() system call with the RENAME_EXCHANGE flag, so the swap is atomic: at any moment, both names exist and point to a file.

Check if your mv supports it

First, check your coreutils version:

mv --version

On my machine, running NixOS, I get:

mv (GNU coreutils) 9.11

You need version 9.5 or newer. Careful here: version numbers are not decimals. They are compared part by part, so 9.11 (nine point eleven) is newer than 9.5. You can also check whether the option is listed in the help:

mv --help | grep exchange

If this prints nothing, your mv doesn't have the option yet. I'll talk about which distributions ship it later in this article.

Swap two files

Let's create two small files to test:

echo "config A" > a.conf
echo "config B" > b.conf

Now swap them:

mv --exchange a.conf b.conf

Check the result:

cat a.conf b.conf
config B
config A

That's it. The contents traded places in one command, and no temporary file was involved.

Swapping two files with mv --exchange in the terminal

Swap two directories (and the mistake I made)

It works for directories too, which is where it really shines. But the first time I tried it, it failed:

mkdir release-old release-new
touch release-old/v1 release-new/v2
mv --exchange release-old release-new
mv: cannot exchange 'release-old' and 'release-new/release-old': Unknown error -1

Look at the second path in the error: release-new/release-old. When the last argument is an existing directory, mv assumes you want to move things into it, just like a regular mv. So it tried to swap release-old with a path inside release-new that doesn't exist.

The fix is the -T (--no-target-directory) option, which tells mv to treat the last argument as a plain name instead of a destination folder:

mv -T --exchange release-old release-new
ls release-old release-new
release-new:
v1

release-old:
v2

Now the whole directory trees were swapped, no matter how many files they contain, because only the names changed.

Where it actually helps

Here are a few situations where I find mv --exchange useful:

  • Rolling out a new configuration. Swap the new config into place and keep the old one under the other name, ready for a quick rollback with the same command.
  • Switching release directories. If you deploy a new version of a site into a separate folder, you can swap it with the live folder in one step (remember the -T).
  • Undoing a swap. Running the same command again swaps the files back.

Limitations you should know

mv --exchange is not magic, and a few things can trip you up.

Both paths must be on the same filesystem

The swap only works when both files live on the same filesystem. If you try to exchange a file on one filesystem with a file in a tmpfs mount like /dev/shm, the kernel refuses the operation:

mv --exchange b.conf /dev/shm/x.conf
mv: cannot exchange 'b.conf' and '/dev/shm/x.conf': Unknown error -1

The message is not very helpful (it is the same "Unknown error -1" we saw in the directory mistake above), so it's worth knowing the real reason: the kernel can't swap names across two different filesystems.

Regular mv gets around this by copying the file and deleting the original, but that can't be done atomically, so --exchange doesn't even try.

mv --exchange failing when the files are on different filesystems

The filesystem must support it

The underlying system call needs filesystem support. Common Linux filesystems such as ext4, Btrfs, XFS and tmpfs support it.

Conclusion

mv --exchange is one of those small additions that removes a whole category of fiddly, error-prone shell work. If you are on a recent distribution like NixOS, Fedora or Debian 13, it is already on your system.

Next time you reach for a temporary file name to swap two things, try mv --exchange instead. Just remember to add -T when you swap directories.

✍️
Igor Giamoniano is a developer and teacher from SΓ£o Paulo, Brazil. He contributes to the Brazilian Portuguese translation of the Linux kernel documentation and runs Coisa de Dev, where he teaches Linux and programming to a Brazilian audience. You can find his open source work on GitHub.
❌