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:
| Command | Shortcut | Description |
|---|---|---|
| :quit | :q | Close the current view |
| :buffer-close | :bc | Close the current buffer |
| :buffer-next | :bn | Go to next buffer |
| :buffer-previous | :bp | Go to previous buffer |
| :write | :w | Write changes to disk (save file) |
| :update | :u | Save file changes if file was modified |
| :reload | :rl | Discard file changes and reload it. |
| :new | :n | Create a new scratch buffer |
| :format | :fmt | Format 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.
| Command | Shortcut | Description |
|---|---|---|
| Horizontal Movement | ||
| left | h | left one char |
| right | l | right one char |
gh | go to beginning of line | |
gl | go to end of line | |
w | Move to start of next word | |
W | Move to start of next WORD (ignore punctuation) | |
e | Move to end of next word | |
E | Move to end of next word (ignore punctuation) | |
b | Move to start of previous word | |
B | Move to start of previous word (ignore punctuation) | |
| Vertical Movement | ||
| up | k | Move up |
| down | j | Move down |
| goto | G | Go to line number <n> |
| pg up | Ctrl-b | Page up (back) |
| pg down | Ctrl-d | Page down (forward) |
| 1/2 up | Ctrl-u | Move 1/2 page up |
| 1/2 down | Ctrl-d | Move 1/2 page down |
Ctrl-i | Jump forward in jump list - 1 | |
Ctrl-o | Jump backward in jump list | |
Ctrl-s | Save current selection to jump list | |
| Selections | ||
t | Find and select until next occurrence of a character | |
f | Find and select to next occurrence of a character | |
T | Find and select until previous occurrence of a character | |
F | Find 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.
| Command | Shortcut | Description |
|---|---|---|
<space>f | open file picker | |
<space>b | show open buffers | |
<space>j | open jump list - 1 | |
:bc | close active buffer | |
:gn | go to next buffer | |
:gp | go to previous buffer | |
:bn | go to next buffer | |
:bp | go to previous buffer | |
:bco | close other buffers | |
<space>w | open 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.
- Go to the
~/.config/helixfolder - Make a themes folder if it doesn’t exist.
mkdir themes. - Move into the themes folder
cd themes. - Create a new theme file for your transparent theme
touch gruvbox_transparent.toml. - Edit the new theme file and add the following lines:
inherits = "gruvbox"
"ui.background" = {}
- Save the file, restart helix to see your transparent theme.
joy to the world echo “hello world” | sed -e “s/<./\U&/g”