DEV Community

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

Posted on • Originally published at rockyourcode.com on

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

Top comments (0)