DEV Community

Cover image for TIL: Insert Macros for the Helix Editor
Sophia Brandt
Sophia Brandt

Posted on • Originally published at rockyourcode.com on

1

TIL: Insert Macros for the Helix Editor

I’ve been using the Helix editor for two weeks now as my daily driver in my personal coding projects.

Helix is a modern terminal text editor that’s quite capable as a tool for writing code.

A Kakoune / Neovim inspired editor, written in Rust.

Features

  • Vim-like modal editing
  • Multiple selections
  • Built-in language server support
  • Smart, incremental syntax highlighting and code editing via tree-sitter

After some initial bumps in the road due to my Vim muscle memory, I have grown quite fond of Helix. For my pet projects (TypeScript) it works well.

The language server support is great. It offers me the convenience I am used to from other editors (IntelliJ) - auto-complete functionality, hover information and so forth.

Helix is not a fully-fledged IDE, but it doesn’t aim to be one. It is supposed to be an alternative to Kakoune or Vim/NeoVim.

Insert Macros

My NeoVim config sports an “insert macro” for the fat arrow (=>). When I type ‘hsr’ in insert mode, the editor automatically replaces these three characters with a fat arrow (hashrocket).

Here is how the key mapping looks in Vim:

# custom/keymappings.vim
inoremap hsr =>

Enter fullscreen mode Exit fullscreen mode

And the same config in lua (NeoVim):

vim.api.nvim_set_keymap('i', 'hsr', '=>', { silent = true, noremap = true }),

Enter fullscreen mode Exit fullscreen mode

This can also be achieved in Helix:

# ~/.config/helix/config.toml
h = { s = { r = ["normal_mode", ":insert-output echo '=>'", "collapse_selection", "insert_at_line_end"] } }

Enter fullscreen mode Exit fullscreen mode

Links

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more