Skip to content

Instantly share code, notes, and snippets.

@kwmiebach
Created April 16, 2022 11:16
Show Gist options
  • Save kwmiebach/42646450c4220b4aebad862bb7b65685 to your computer and use it in GitHub Desktop.
Save kwmiebach/42646450c4220b4aebad862bb7b65685 to your computer and use it in GitHub Desktop.
helix-editor tutor
_ _ __ __
| | | | _ \ \ / /
| |_| | ___ | | (_) \ \/ /
| _ | / _ \ | | _ ) (
| | | | | __/ | | | | / /\ \
|_| |_| \___| |_| |_| /_/ \_\
A post-modern modal text editor.
_________________________________________________________________
Welcome to the Helix editor! Helix is different from editors
you might be used to in that it is modal, meaning that it has
different modes for editing text. The primary modes you will
use are Normal mode and Insert mode. While in Normal mode, the
keys you press won't actually type text. Instead, they will
perform various actions with the text. This allows for more
efficient editing. This tutor will teach you how you can make
use of Helix's modal editing features. To begin, ensure your
caps-lock key is not pressed and hold the j key until you reach
the first lesson.
=================================================================
= BASIC CURSOR MOVEMENT =
=================================================================
k * h is on the left
← h l → * l is on the right
j * j looks like a down arrow
The cursor can be moved using the h, j, k, l keys, as shown
above. The cursor/arrow keys will also work, but it is faster
to use the hjkl keys as they are closer to the other keys you
will be using. Try moving around to get a feel for hjkl.
Once you're ready, hold j to continue to the next lesson.
=================================================================
= EXITING HELIX =
=================================================================
1. Press the : key to enter command mode. Your cursor will
move to the bottom of the screen.
2. Type q or quit and press <ENTER> to exit Helix.
Note: The quit command will fail if there are unsaved changes.
To force quit and DISCARD these changes, use q! or quit!.
You will learn how to save files later.
To exit command mode without entering a command, press <ESC>.
Now, move on to the next lesson.
=================================================================
= DELETION =
=================================================================
Press the d key to delete the character under the cursor.
1. Move the cursor to the line below marked -->.
2. Move the cursor to each extra character, and press d to
delete it.
--> Thhiss senttencee haass exxtra charracterss.
Once the sentence is correct, move on to the next lesson.
=================================================================
= INSERT MODE =
=================================================================
Press the i key to enter Insert mode.
1. Move the cursor to the line below marked -->.
2. Move to a place in the line which is missing text and press
i to enter Insert mode. Keys you press will now type text.
3. Enter the missing text.
4. Press <ESC> to exit Insert mode and return to Normal mode.
5. Repeat until the line matches the line below it.
--> Th stce misg so.
This sentence is missing some text.
Note: If you want to move the cursor while in Insert mode,
you may use the arrow keys instead of exiting and
reentering Insert mode.
Note: The status bar will display your current mode.
Notice that when you press i, 'NOR' changes to 'INS'.
=================================================================
= MORE ON INSERT MODE =
=================================================================
As you saw, you can press i to enter Insert mode at the current
position of the cursor. There are a few other ways you can
enter Insert mode at different locations.
Common examples of insertion commands include:
i - Insert before the selection.
a - Insert after the selection. (a means 'append')
I - Insert at the start of the line.
A - Insert at the end of the line.
1. Move to anywhere in the line below marked -->.
2. Press A (<SHIFT> + a), your cursor will move to the end of
the line and you will be able to type.
3. Type the text necessary to match the line below.
--> This sentence is miss
This sentence is missing some text.
=================================================================
= SAVING A FILE =
=================================================================
Use :w/:write to save a file.
1. Exit Helix using :q! as explained before, or open a new
terminal.
2. Open a file in Helix by running: hx FILENAME
3. Make some edits to the file.
4. Press the : key to enter command mode.
5. Type w or write, and press <ENTER> to save the file.
You can also use wq or write-quit to save and exit.
Note: You can optionally enter a filepath after the w/write
command in order to save to that path.
Note: If there are any unsaved changes to a file, a plus [+]
will appear next to the file name in the status bar.
=================================================================
= RECAP =
=================================================================
* Use the h,j,k,l keys to move the cursor.
* Press : to enter command mode.
* The q/quit and q!/quit! commands will exit Helix. The
former fails when there are unsaved changes. The latter
discards them.
* The w/write command will save the file.
* The wq/write-quit command will do both.
* Press d to delete the character at the cursor.
* Press i to enter Insert mode and type text. Press <ESC> to
return to Normal mode.
=================================================================
= MOTIONS AND SELECTIONS =
=================================================================
Press w to select forward until the next word.
The d key doesn't actually delete the character at the cursor,
it deletes all selected text. Your cursor is like a
single-character selection.
1. Move the cursor to the line below marked -->.
2. Move to the beginning of a word that needs to be deleted.
3. Press w to select until the beginning of the next word.
4. Press d to delete the selection.
5. Repeat for all extra words in the line.
--> This sentence pencil has vacuum extra words in the it.
=================================================================
= MORE ON MOTIONS =
=================================================================
As you saw, pressing w moves the cursor forward until the start
of the next word, selecting the text traversed. This is useful
for moving around text and for selecting text to operate on.
Some common motions include:
w - Move forward to before the beginning of the next word.
e - Move forward to the end of the current word.
b - Move backward to the beginning of the current word.
The w,e,b motions also have counterparts - W,E,B - which
traverse WORDS instead of words. WORDS are only separated by
whitespace, whereas words can be separated by other characters
in addition to whitespace.
All of these motions select the text they traverse.
=================================================================
= THE CHANGE COMMAND =
=================================================================
Press c to change the current selection.
The change command deletes the current selection and enters
Insert mode, so it is a very common shorthand for di.
1. Move the cursor to the line below marked -->.
2. Move to the start of an incorrect word and press w to
select it.
3. Press c to delete the word and enter Insert mode.
4. Type the correct word.
5. Repeat until the line matches the line below it.
--> This paper has heavy words behind it.
This sentence has incorrect words in it.
=================================================================
= COUNTS WITH MOTIONS =
=================================================================
Type a number before a motion to repeat it that many times.
1. Move the cursor to the line below marked -->.
2. Type 2w to move 2 words forward.
3. Type 3e to move to the end of the third word forward.
4. Type 2b to move 2 words backwards
5. Try the above with different numbers.
--> This is just a line with words you can move around in.
=================================================================
= SELECTING LINES =
=================================================================
Press x to select a whole line. Press again to select the next.
1. Move the cursor to the second line below marked -->.
2. Press x to select the line, and d to delete it.
3. Move to the fourth line.
4. Press x twice or type 2x to select 2 lines, and d to delete.
--> 1) Roses are red,
--> 2) Mud is fun,
--> 3) Violets are blue,
--> 4) I have a car,
--> 5) Clocks tell time,
--> 6) Sugar is sweet,
--> 7) And so are you.
=================================================================
= UNDOING =
=================================================================
Type u to undo. Type U to redo.
1. Move the cursor to the line below marked -->.
2. Move to the first error, and press d to delete it.
3. Type u to undo your deletion.
4. Fix all the errors on the line.
5. Type u several times to undo your fixes.
6. Type U (<SHIFT> + u) several times to redo your fixes.
--> Fiix the errors on thhis line and reeplace them witth undo.
=================================================================
= RECAP =
=================================================================
* Press w to select forward until the next word.
* Press e to select to the end of the current word.
* Press b to select backward to the start of the current word.
* Use uppercase counterparts, W,E,B, to traverse WORDS.
* Typing d deletes the entire selection, so you can delete a
word forward by typing wd.
* Press c to delete the selection and enter Insert mode.
* Press a number before a motion to repeat it that many times.
* Press x to select the entire current line. Press x again to
select the next line.
* Press u to undo. Press U to redo.
=================================================================
= MULTIPLE CURSORS =
=================================================================
Type C to duplicate the cursor to the next line.
1. Move the cursor to the first line below marked -->.
2. Type C to duplicate the cursor to the next line. Keys you
press will now affect both cursors.
3. Use Insert mode to correct the lines. The two cursors will
fix both lines simultaneously.
4. Type , to remove the second cursor.
--> Fix th two nes at same ime.
--> Fix th two nes at same ime.
Fix these two lines at the same time.
Note: You can use alt-C to do the same above the cursor.
=================================================================
= THE SELECT COMMAND =
=================================================================
Type s to select matches in the selection.
1. Move the cursor to the line below marked -->.
2. Press x to select the line.
3. Press s. A prompt will appear.
4. Type 'apples' and press <ENTER>. Both occurrences of
'apples' in the line will be selected.
5. You can now press c and change 'apples' to something else,
like 'oranges'.
6. Type , to remove the second cursor.
--> I like to eat apples since my favorite fruit is apples.
=================================================================
= SELECTING VIA REGEX =
=================================================================
The select command selects regular expressions, not just exact
matches, allowing you to target more complex patterns.
1. Move the cursor to the line below marked -->.
2. Select the line with x and then press s.
3. Enter ' +' to select any amount of consecutive spaces >1.
4. Press c and change the matches to single spaces.
--> This sentence has some extra spaces.
Note: If you want to perform find-and-replace, the select
command is the way to do it. Select the text you want
to replace in — type % to select the whole file — and
then perform the steps explained above.
=================================================================
= COLLAPSING SELECTIONS =
=================================================================
Type ; to collapse selections to single cursors.
Sometimes, you want to deselect without having to move the
cursor(s). This can be done using the ; key.
1. Move the cursor to the line below marked -->.
2. Use the motions you have learned to move around the line,
and try using ; to deselect the text after it is selected
by the motions.
--> This is an error-free line with words to move around in.
=================================================================
= SELECTING TO A CHARACTER =
=================================================================
Select up to, and including a character with f, followed by that
character. Select backwards to a character with F (uppercase).
The f stands for 'find'.
1. Move the cursor to the line below marked -->. Make sure your
cursor is put just after the arrow.
2. press f, followed by the character you want to select
to, in this case a square bracket: [.
3. press d to delete your selection, breaking the sentence free
of the square brackets
4. go to the very end of the line and repeat again with uppercase
F. Remember this time you're selecting to a closing ].
--> -----[This sentence is surrounded in square brackets, free me!]-----
Note: Unlike vim, helix doesn't limit this command to just one
line. It'll just search for that character in the file.
=================================================================
= SELECTING TIL' A CHARACTER =
=================================================================
Select up to, but NOT including ('til) a character with t. Select backwards
until a character with uppercase T
1. Move the cursor to the line below marked -->.
2. press t and then A to select until A.
3. press d to delete the dashes.
4. Go to the line end, and repeat with T. Only
this time you're searching for an 's'
--> -----A sentence surrounded in dashes-----
Note: Unlike vim, helix doesn't limit this command to just one
line. It'll just search for that character in the file.
=================================================================
= RECAP =
=================================================================
* Press C to copy the selection on the line below and Alt-C for
above.
* Press s to select all instances of a regex pattern inside
the current selection.
* Press semicolon ( ; ) to collapse
* Press f / F to extend selection up to & including a character.
* press t / T to extend selection until a character.
=================================================================
= COPYING AND PASTING TEXT =
=================================================================
Press y to yank (copy) the selection to the clipboard.
Press p to paste the yanked selection after the cursor.
Press uppercase P to paste the yanked selection *before*
the cursor.
1. Move the cursor to the line below marked -->.
2. press w to select "banana" and y to yank it.
3. move between "2" and "3" and press p to paste.
4. Repeat between "3" and "4"
--> 1 banana 2 3 4
Note: Whenever you delete (d) or change (c) text, helix will
copy the deleted/changed text to the clipboard, you can
avoid this with alt-d and alt-c respectively.
Note: Helix doesn't share the system clipboard by default.
Press space-Y and space-P to yank/paste to/from
your computers main clipboard
=================================================================
= SWITCHING CASE =
=================================================================
Press ~ to switch the case (capitalised-ness) of all selected
letters - or just the one under the cursor.
1. Move the cursor to the line below marked -->.
2. Select each wrongly capitalised or un-capitalised letter
and press ~ over them
(remember, the first letter *should* be capitalised)
--> thIs sENtencE hAs MIS-cApitalIsed leTTerS.
=================================================================
= SETTING CASE =
=================================================================
Press ` (above tab key on most keyboards) to set all selected
letters to lowercase.
1. Move the cursor to the line below marked -->.
2. press x to select the line.
3. press ` to change it to all lowercase
--> this SENTENCE SHOULD all be in LOWERCASE!
Note: Conversely, alt-` changes all selected letter to uppercase.
=================================================================
= MACROS =
=================================================================
Macros are just a way to record a set of actions that you want
to repeat.
Press Q to start recording a macro, you should see a poup at
the bottom of your screen. Press Q again to stop recording.
Press q to repeat your recorded macro.
1. Move the cursor to the first line below marked -->.
2. Press Q to start recording.
3. Enter insert mode and type some text.
4. Exit insert and press Q again to stop recording
5. Move to the line below and press q to repeat the macro.
-->
-->
=================================================================
= RECAP =
=================================================================
* Press y to yank (copy) text and p to paste
* Press space-Y and space-P to yank/paste on the system
clipboard
* Press ~ to alternate case of selected letters
* press ` and alt-` to set the case of selected layers to
upper and lower respectively
* Press Q to record and stop recording a macro
* Press q to repeat the recorded macro
=================================================================
= USING THE JUMPLIST =
=================================================================
Helix can keep track of "jumps" which are big movements, like
jumping to the definition of a function in code. It stores
these in what's called the jumplist.
Press C-s (ctrl-s) to manually save your current position to
the jumplist.
Press C-i and C-o to move forward and backwards in the jumplist
respectively.
1. Press C-s somewhere.
2. Move far away in the file.
3. Press C-o (just once!) to come back to where you saved.
=================================================================
= SEARCHING IN FILE =
=================================================================
Press / to search forward in file, enter to confirm search.
Press n to go to the next search match.
Press N to go to the previous search match.
1. Press / and type in a common word, like 'banana'.
2. Press enter to confirm the search.
3. press n and N to cycle through the matches.
Like select mode, searching also supports regex!
Note: To search backwards, press ? (shift-/).
=================================================================
= RECAP =
=================================================================
* Press C-s to save position to the jumplist.
* Press C-i and C-o to go forward and backward in the jumplist.
* Press / to search forward in file, and ? to search backwards.
* Press n and N to cycle through search matches.
=================================================================
= JOINING LINES =
=================================================================
Press J to join lines in selection.
This is a lesser used command, but is sometimes quite handy!
1. Move the cursor to the line below marked -->.
2. press x three times to select the other lines.
3. press J to join the lines together.
--> This line sentence
is spilling over
onto other lines.
=================================================================
= INDENTING LINES =
=================================================================
Press > to indent a line and < to unindent it
1. Move the cursor to the line below marked -->.
2. indent/unindent the lines with < and >, until they are uniform.
--> These lines
are indented
very poorly.
--> These lines
are indented
much better.
=================================================================
= OPENING LINES =
=================================================================
Press o to add a newline and insert below the cursor.
Press O to add a newline and insert above the cursor.
1. Move the cursor to the line below marked -->.
2. Press o to open a line below and type your answer.
--> What is the best editor?
https://github.com/helix-editor/helix/blob/d90fbe2123389eba458abced302c3b9822f11ac2/runtime/tutor.txt
=================================================================
= RECAP =
=================================================================
* Press J to join lines within selection.
* Press > and < to indent and unindent selected lines.
* Press o and O to open lines
=================================================================
This tutorial is still a work-in-progress.
More sections are planned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment