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.
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.
Helix editor: Make HTTP requests and insert JSON
Rajasegar Chandran ・ Jul 9 '23
: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.
: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
: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.
I have written an other post showing how to use lazygit with Helix to manage your git repositories using the :sh
command.
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.
Top comments (6)
Thank you for your article. I have seen scroll in small pop-up window which is showed after command
:sh ls
. How can I move the cursor inside this small pop-up window? Is it possible to do it with keyboard without mouse?Not the cursor, but we can scroll in that window down and up with Ctrl-d and Ctrl-u, just in case :)
I don't think it is possible to move the cursor in to the popup window, I tried
That's so useful! I have a question: How to append a substring to piped text before passing it to a script? I tried this:
:pipe echo $(cat) "(new substring)" | ./script.js
but I got this error:Syntax error: "(" unexpected
.How to send the result of :sh to a new buffer?
you can create a custom keybinding like this: