Most important commands in Helix
Tags: productivity, editors, helix
Published: 2023-07-24 06:41:58

In this post, we are going to take a look at the most important commands in the Helix editor. We also take a deep dive with examples on how to use these commands and make Helix an hyper-extensible editor.

## :insert-output
The `:insert-output` command is used in Helix to run a shell command and inserting the output before each selection in the buffer.

You can invoke the `:insert-output` either going to the command mode by typing `:` and typing the command or you can simply use the key mapping `!` exclamation mark.

Here in this example we are inserting the output of the `date` command before the selected text using the `:insert-output` command.


![Insert output append output](https://github.com/rajasegar/dev-to-assets/blob/main/insert-output-append-output.gif?raw=true)

I have already written an another post showing how to make use of the `:insert-output` command to make HTTP requests and insert JSON in the Helix buffer.

{% embed https://dev.to/rajasegar/helix-editor-make-http-requests-and-insert-json-3agf %}


## :append-output
The `:append-output` command is used to run a shell command and appending the output after each selection.

You can invoke the `:append-output` either going to the command mode by typing `:` and typing the command or you can simply use the key mapping `Alt-!`, Alt key with exclamation mark.


Here in this example we are inserting the output of the `date` command after the selected text using the `:append-output` command.


![Insert output append output](https://github.com/rajasegar/dev-to-assets/blob/main/insert-output-append-output.gif?raw=true)


## :pipe
The `:pipe` command is used to pipe each selection to the shell command and replacing the selection with the resulting output of the command.

Let's say for example you want to format/beautify a JSON value in Helix, you just select the whole string and use the `:pipe` command or the shortcut key `|` to beautify the string into a proper JSON structure using a tool called [jq](https://jqlang.github.io/jq/)

![pipe command](https://github.com/rajasegar/dev-to-assets/blob/main/pipe-command.gif?raw=true)

## :pipe-to
The `:pipe-to` command in Helix is used to pipe each selection to the shell command, ignoring output.

You can invoke the `:pipe-to` either going to the command mode by typing `:` and typing the command or you can simply use the key mapping `Alt-|`, Alt key with pipe symbol.

This could be useful when you use Helix in conjunction with a REPL open in another terminal. To quickly send commands from Helix to the REPL you can pipe the editor selection into your terminal.

## :run-shell-command or :sh
This command is used to run a shell command inside Helix. Let's say you quickly want to check the list of files in your current directory, you can run the `ls` command inside Helix itself.

![run shell command](https://github.com/rajasegar/dev-to-assets/blob/main/run-shell-command.gif?raw=true)

I have written an other post showing how to use lazygit with Helix to manage your git repositories using the `:sh` command.

{% embed https://dev.to/rajasegar/helix-tmux-and-lazygit-7nj %}

Hope you enjoyed this post and learnt more about these commands in Helix. Please share your thoughts and other ways how you can use these commands to extend Helix in the comments section.