Skip to content

Recipes

Includes common solutions to some problems.

Git Integration

Helix comes with basic git integration such as the ability to see which files have been modified on the gutters, and acting on git hunks as text objects. But a more comprehensive git integration can be desired, which is understandable.

Lazygit is the most popular git TUI and you can smoothly integrate it with Helix with the following keymap:

helix/config.toml
[keys.normal]
C-g = [
":write-all",
":new",
":insert-output lazygit",
":buffer-close!",
":redraw",
":reload-all"
]

Explanation

  1. write-all: save all buffers so that the changes can be shown in lazygit and committed right away
  2. new: create new empty buffer
  3. insert-output lazygit: runs the lazygit command and inserts it’s output into the new buffer
  4. When you exit lazygit, buffer-close! will kill the previously empty buffer, sending you back to where you were previously.
  5. redraw is necessary to re-render the UI to show the buffers
  6. reload-all because if e.g. you commit everything, helix will still show the symbols indicating that lines were changed / deleted on the left of the line numbers. This will prevent that

Remap Caps Lock to Escape

The Esc key is quite far away from the home row on most keyboards. Due to this fact, many people remap Caps Lock to Esc.

To do this, follow instructions for your operating system.

You can use keyd, which is a modern alternative to xmodmap compatible with Wayland and XOrg.

  1. Install keyd using your system’s package manager

  2. Start the keyd daemon:

    Terminal window
    sudo systemctl enable keyd
  3. Place the following in /etc/keyd/default.conf

    Terminal window
    [ids]
    *
    [main]
    # Maps capslock to escape when pressed and control when held.
    capslock = overload(control, esc)
    # Remaps the escape key to capslock
    esc = capslock
  4. Run sudo keyd reload to reload the config set.

Project-wide Search and Replace

In helix, you can perform search-and-replace in a file by using % to select the whole file and then s to match a regex against the file, placing cursors on each match.

But what if you want to perform a project-wide search and replace? Helix currently doesn’t provide that functionality, but there is an external tool called scooter which was created exactly for this purpose. Check it out!

Integrated Terminal

At the moment, there’s no way to open a terminal from within Helix. Despite that, many users prefer using Ctrl + z which puts the current process to sleep.

When you run this command from inside Helix, it will be put to sleep. You’ll be able to access the terminal again, browse files, and do everything else you usually do.

Once you need to return back to Helix, you can type fg in the terminal which will bring Helix back from sleep and resume it exactly where you left it. You can use this to run background processes while using Helix, and other shell commands.

More intuitive x and X motions

Some people prefer to remap x and X motions from the defaults:

helix/config.toml
x = "extend_line_below"
X = "extend_to_line_bounds"

To the following:

helix/config.toml
x = "select_line_below"
X = "select_line_above"

Due to the fact that they may find it more natural to have x and X perform opposite motions, similar to other motions in Helix.

Currently some people want this to become the default.