Helix Cheat Sheet

I am developing master of the Helix text editor. This document is notes relating to wrapping my head around some major paradigm shifts in learning a unique editor and in no way replaces the Helix documentation.

With vim-like-editors, there are so many ways to do things, it is overwhelming.

  • Be prepared to dedicate some time to get to know the editor.
  • Start with the basic movement commands so you can at least move around.
  • Then as you encounter situations where you think, “It would be nice if…”, there is probably a way to do it. Stop and add that new set of keystrokes to your arsenal.

There are four primary editor modes in helix: command, normal, insert, and select. The mode is indicated in the lower left of the statusline at the bottom of the screen. The modes you see are: “INS”: insert mode; “SEL”: select mode; “NOR”: normal mode. Command mode doesn’t have a status indicator since these commands are executed directly.

Command Modes

Command mode gives you access to many commands that are built into Helix. Use the : colon key to begin a command. Note: this only works if you are in normal or select mode.

The Helix documentation divides these commands into two groups; Typable and Static. Typable commands are the ones that I think of as being true command mode commands. The second group of static commands are basically commands that have been assigned keystrokes.

Typable Commands Static Commands

The typable commands primarily deal with files, buffers, and the clipboard. In short, things that interact with the underlying operating system.

Some essential typable commands include:

CommandShortcutDescription
:quit:qClose the current view
:buffer-close:bcClose the current buffer
:buffer-next:bnGo to next buffer
:buffer-previous:bpGo to previous buffer
:write:wWrite changes to disk (save file)
:update:uSave file changes if file was modified
:reload:rlDiscard file changes and reload it.
:new:nCreate a new scratch buffer
:format:fmtFormat the file using the external formatter
:theme—Change the editor theme
:tutor—Open the tutorial

Movement

Moving Around

Some keystrokes (e.g. W, E, B) ignore punctuation marks. These are useful when working with code and you want to include parenthesis and other characters in the movement selection. Coming from a non-vim-like editor means learning a new way of navigating your document that takes some getting used to. Going through the :tutor helps get you acclimated with this.

CommandShortcutDescription
Horizontal Movement
lefthleft one char
rightlright one char
ghgo to beginning of line
glgo to end of line
wMove to start of next word
WMove to start of next WORD (ignore punctuation)
eMove to end of next word
EMove to end of next word (ignore punctuation)
bMove to start of previous word
BMove to start of previous word (ignore punctuation)
Vertical Movement
upkMove up
downjMove down
gotoGGo to line number <n>
pg upCtrl-bPage up (back)
pg downCtrl-dPage down (forward)
1/2 upCtrl-uMove 1/2 page up
1/2 downCtrl-dMove 1/2 page down
Ctrl-iJump forward in jump list - 1
Ctrl-oJump backward in jump list
Ctrl-sSave current selection to jump list
Selections
tFind and select until next occurrence of a character
fFind and select to next occurrence of a character
TFind and select until previous occurrence of a character
FFind and select to previous occurrence of a character

On top of that, there is an entire g menu with lots of go to commands (in normal mode, press g to get the menu to pop open).

Buffers and Windows

Working with buffers is similar to having tabs. The additional open buffers appear on a buffer line at the top of the screen. If you always want to see the bufferline at the top of the screen, add bufferline = "always" to the [editor] section of your config.toml file.

Windows are when you split the screen into multiple panes. When you have multiple windows open, switching buffers will display the newly selected buffer in int current window.

CommandShortcutDescription
<space>fopen file picker
<space>bshow open buffers
<space>jopen jump list - 1
:bcclose active buffer
:gngo to next buffer
:gpgo to previous buffer
:bngo to next buffer
:bpgo to previous buffer
:bcoclose other buffers
<space>wopen window pop up menu

Normal Mode

Return to normal mode by pressing the escape key.

Insert Mode

Go into insert mode by pressing the i key.

Challenges

How to Copy Text to the System Clipboard

How to Title Case a String of Text

Here is a title case example

:echo %sh{python3 -c print("%{selection}".title())}

Interact with the Command Line

Thanks to this Luke Pighetti YouTube Short for the examples.

Run any shell command using :sh. The result of the command will appear in a pop-up that floats around with your cursor. To dismiss the pop-up, just press esc. Super useful for getting some reference information on screen. I don’t know of any way to interact with the pop-up, other than scrolling.

:sh git add .
:sh ls

The :insert-output command inserts the result of the command into your document. A shortcut for running :insert-output is to use !.

:insert-output date
:insert-output date -u +'%Y%m%d'

The :pipe command takes selected text, runs it through a shell command, and replaces it with the output of the command. Here is a JSON example that can be selected and reformatted with the jq utility. A shortcut for the :pipe command is the pipe symbol |.

{ "foo": "bar", "baz": [1, 2, 3, 4] }
:pipe jq
:pipe jq -c

How to Make the Editor Background Transparent

To create a transparent background for an existing them in helix based on one of the existing themes is quite easy. In order for this to work, you will need to set a transparency for your terminal first. Then we create a new theme file that simply ignores the background value for that theme.

  1. Go to the ~/.config/helix folder
  2. Make a themes folder if it doesn’t exist. mkdir themes.
  3. Move into the themes folder cd themes.
  4. Create a new theme file for your transparent theme touch gruvbox_transparent.toml.
  5. Edit the new theme file and add the following lines:
inherits = "gruvbox"
"ui.background" = {}
  1. Save the file, restart helix to see your transparent theme.

joy to the world echo “hello world” | sed -e “s/<./\U&/g”