Skip to content

Basics

To get started check out the installation instructions in order to follow along with the tutorial.

Opening a file

Create a new text file and open it with Helix by running hx file.txt. This is what you’ll see:

    1                           
    ~                           
 NOR   file.txt      1 sel  1:1 
Loaded 1 file.                  

Notice the NOR in the bottom-left corner, this indicates that you are currently in Normal mode. In this mode, typing letters like e and n won’t insert them as text, but rather have specific commands which we will explore later.

To actually insert some text, press i, which is the command to get into Insert mode, indicated by the INS in the bottom-left corner. In this mode, the letters you type will be inserted directly into the document.

Try it out by writing Hello helix!.

    1  Hello helix!             
    ~                           
 INS   file.txt [+] 1 sel  1:13 
                                

To get back into Normal mode press Esc. This will change the color of your cursor and you will see NOR again, indicating that you are in normal mode now.

Movement

To move your cursor you could use arrow keys, both in Normal and Insert modes:

  • move cursor up
  • move cursor down
  • moves cursor right
  • moves cursor left

However, this isn’t encouraged due to the fact that hand will be doing a lot of back-and-forth movement between the arrow keys and the keyboard.

Instead, it is recommended to rest your fingers on the “home row”, which is comprised of the row of keys a s d f g h j k l.

Instead of stretching to reach the arrow keys, use normal mode and h, j, k and l to move your cursor:

  • h: moves cursor 1 character to the left.
  • j: moves cursor 1 line above.
  • k: moves cursor 1 line below.
  • l: moves cursor 1 character to the right.

Try holding down h and l to move horizontally across the text you just wrote!

Paste

We only have one line of text, so let’s duplicate it several times. Type:

  • x, which will select the entire line.
  • y, which will yank (copy) the selection to clipboard.
  • p, which will paste the contents of the selection after the cursor.

Spam p a few times to create several lines.

    1  Hello helix!             
    2  Hello helix!             
    3  Hello helix!             
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 NOR   file.txt [+]  1 sel  3:8 
                                

Now you can try using the h, j, k and l motions to traverse the text!

Word-based Movement

Let’s say we want to replace one of the helix words with world. To do this, place your cursor on one of the h letters:

    1  Hello helix!             
    2  Hello helix!             
    3  Hello helix!             
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 NOR   file.txt [+]  1 sel  3:7 
                                

e is a motion which moves to the end of the current word. Type e and it will move your cursor to the end of the helix.

It doesn’t just move your cursor there, though. The entire helix word becomes highlighted:

    1  Hello helix!             
    2  Hello helix!             
    3  Hello helix!             
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 NOR   file.txt [+] 1 sel  3:11 
                                

If we now press b, which moves to the beginning of the current word, it’ll move us back to where we just were.

Try this out a few times, press e and then b to select various sections of the text. If you want to remove your selection press ;.

Let’s highlight our helix word again:

    1  Hello helix!             
    2  Hello helix!             
    3  Hello helix!             
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 NOR   file.txt [+] 1 sel  3:11 
                                

Selection-first Approach

Helix’s philosophy is that each action will act on a selection.

Every time text is modified (an action), you will fully anticipate the result — because you can clearly see the area of text which is highlighted, and thus will be modified.

For example, we currently have the word helix selected. To change it to world, press c,

    1  Hello helix!             
    2  Hello helix!             
    3  Hello !                  
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 INS   file.txt [+]  1 sel  3:7 
                                

c removes the contents of the current selection and places us in Insert mode, where you can then write your new word. Exit back to Normal mode by pressing esc.

    1  Hello helix!             
    2  Hello helix!             
    3  Hello world!             
    4  Hello helix!             
    5  Hello helix!             
    ~                           
 NOR   file.txt [+] 1 sel  3:12 
                                

Delete

The d command deletes the current selection and copies what has been deleted into a clipboard.

Let’s test it out by doing the following:

  1. Select the line we just changed with x.

        1  Hello helix!             
        2  Hello helix!             
        3  Hello world!             
        4  Hello helix!             
        5  Hello helix!             
        ~                           
     NOR   file.txt [+] 1 sel  3:13 
                                    
    
  2. d to delete this line.

        1  Hello helix!             
        2  Hello helix!             
        3  Hello helix!             
        4  Hello helix!             
        ~                           
                                    
     NOR   file.txt [+]  1 sel  3:1 
                                    
    
  3. Spam p a few times to create some duplicates.

        4  Hello world!             
        5  Hello world!             
        6  Hello world!             
        7  Hello helix!             
        ~                           
                                    
     NOR   file.txt [+] 1 sel  6:13 
                                    
    

Let’s remove all of our previous Hello helix! by doing the following for each Hello helix! line:

  1. Select the line with x.
  2. d to delete it.

Now we have something like this:

    1  Hello world!             
    2  Hello world!             
    3  Hello world!             
    ~                           
                                
                                
 NOR   file.txt [+]  1 sel  2:1 
                                

Undo and Redo

What if we made a mistake, and want to go back? The u command will undo our most recent action. It’s similar to Ctrl + z in other editors.

Try pressing down u a few times to get to our previous state, before we made all those modifications:

    3  Hello helix!             
    4  Hello world!             
    5  Hello world!             
    6  Hello helix!             
    ~                           
                                
 NOR   file.txt [+] 1 sel  5:13 
                                

U is similar to Ctrl + Shift + z in other editors. It will undo the last undo. It’s the inverse of u.

Press U until we get back to our most recent state:

    1  Hello world!             
    2  Hello world!             
    3  Hello world!             
    ~                           
                                
                                
 NOR   file.txt [+]  1 sel  1:1 
Already at newest change        

Checkpoint

Feel free to make modifications to your file using the commands we have learned so far:

  • h, j, k and l moves 1 character left, down, up and right.
  • i enters Insert mode.
  • esc enters Normal mode.
  • x selects the entire line.
  • y yanks the selection.
  • p pastes the recently copied selection.
  • e selects and moves to the end of the current word.
  • b selects and moves to the beginning of the current word.
  • ; removes the extra selection.
  • d deletes the current selection, without exiting Normal mode.
  • c changes the current selection, by deleting it and entering Insert mode.
  • u will undo the most recent change.
  • U will undo the most recent undo.

Once you are happy with your modifications, enter Normal mode and type :.

: enters command mode, which has commands you type out.

  • :w will write the current file.
  • :q will quit the current file.
  • :q! will quit without saving.
  • :wq will both write and quit.
┌──────────────────────────────┐
│ Write changes to disk and    │
│ close the current view.      │
│ Accepts an optional path     │
└──────────────────────────────┘
write-quit-all                  
write-quit-all!                 
:wq                             

More Commands

Let’s try out more Helix commands! Open the file again with hx file.txt. Select the entire file by pressing %

    1  Hello world!             
    2  Hello world!             
    3  Hello world!             
    ~                           
                                
                                
 NOR   file.txt [+] 1 sel  3:13 
                                

Now, delete the selection with d.

    ~                           
                                
                                
                                
                                
                                
 NOR   file.txt [+]  1 sel  1:1 
                                

Goto Word

Using b to go to the beginning of the word and e to go to the end is useful if you are already at the word you want. But if you are far away, a very powerful command is goto wordgw.

    1  aue atates asll          
    2  ard ape anouds alll      
    3  aje ahn afll             
    4  add abe clouds aall      
    5  acd aee agon aill        
    6  akd ame aoon aqll        
 NOR   file.txt [+] 1 sel  4:13 
                 gw             

gw will create two letters at the start of every word in sight. When you type those two letters, you instantly jump to the specified word.

Let’s say we want to jump to the plates word. The first two characters have been replaced by at and highlighted. If we write at, we will highlight that word!

    1  The plates will          
    2  and the clouds will      
    3  The sun will             
    4  and the clouds will      
    5  and the moon will        
    6  and the moon will        
 NOR   file.txt [+] 1 sel  1:10 
                                

Replace

You can also replace a selection with contents of a register.

  1. Select the moon word by using gw and yank it with y.
  2. Select the sun word and replace it with moon with R.

Go to the first line by using gg.

To search for a word, use / command. Type will which is going to highlight the next will keyword, and then Enter ↵ to select it.

Since there are several wills in the text, you can cycle between them:

  • n cycles to the next match.
  • N cycles to the previous match.

More ways to enter Insert Mode

Select the clouds word using gw. If you press i, you will go into insert mode at the beginning of the selection. There are also 5 more ways to enter Insert mode:

  • a for append go into insert mode at the end of the selection
  • I go into insert mode at the beginning of the current line
  • A to append at the end of the current line
  • o add a newline below and go into insert mode
  • O add a newline above and go into insert mode

Try all of them out!

Registers

Helix has a concept called registers, which is like having many clipboards at once.

To interact with them, prefix yank and delete commands with a and then the name of the register.

For example, the contents of the system clipboard are stored inside the + register.

  1. Paste the following content into the file with “+p:

    The plates will
    and the clouds will
    The sun will
    and the moon will
  2. Navigate to the last line by using ge for goto end.

        1  The plates will          
        2  and the clouds will      
        3  The sun will             
        4  and the moon will        
        ~                           
                                    
     NOR   file.txt [+]  1 sel  4:2 
                                    
    
  3. Select the last line with x and then yank it with y.

        1  The plates will          
        2  and the clouds will      
        3  The sun will             
        4  and the moon will        
        ~                           
                                    
     NOR   file.txt [+] 1 sel  4:18 
    yanked 1 selection to register "
    
  4. Navigate to the second line by using 2gg.

  5. Select the second line by using x and then yank into into the e register with “ey.

        1  The plates will          
        2  and the clouds will      
        3  The sun will             
        4  and the moon will        
        ~                           
                                    
     NOR   file.txt [+] 1 sel  2:20 
    yanked 1 selection to register e
    
  6. Navigate to the third line by using 3gg.

  7. Paste what we copied previously by using p.

        1  The plates will          
        2  and the clouds will      
        3  The sun will             
        4  and the moon will        
        5  and the moon will        
        ~                           
     NOR   file.txt [+] 1 sel  4:18 
                                    
    

Notice how we haven’t pasted the 2nd line’s contents, but rather the last lines’? Because we yanked the 2nd line’s contents into the e register. To paste from it, use “ep.

  • signals to the editor that we are going to use a register.
  • e uses the e register.
  • p pastes contents of the e register.
    1  The plates will          
    2  and the clouds will      
    3  The sun will             
    4  and the moon will        
    5  and the clouds will      
    6  and the moon will        
 NOR   file.txt [+] 1 sel  5:20 
                                

Take note of the fact that when we press p, it pastes the contents of the register after the line. To paste before, we undo with u and use P to paste before.

    1  The plates will          
    2  and the clouds will      
    3  The sun will             
    4  and the clouds will      
    5  and the moon will        
    6  and the moon will        
 NOR   file.txt [+] 1 sel  4:20 
                                

Move to characters

You can also search for individual characters by using t, which stands for till.

  1. Copy the text below

    Twilight fades; stars—whispering, bold—
    "Hope," they hum; yet shadows unfold...
    Life? A riddle—endless! Who'll dare,
    to seek; to dream: to wander—where?
  2. Select the entire file with %

  3. Override the selection by using Space + R.

Go to the first line with gg and use t; to go to the next semicolon. Repeat this several several times.

To move in the opposite direction, use T; to the previous semicolon.

Using t and T motions will move your cursor to just before the next or the previous occurrence of the character.

For example, te to go to the next e. T” to go to just before the previous double-quote.

The f for find is similar to t, but instead it places your cursor at the occurrence of the character. Try using f; several times. F goes the opposite way.

Counts

Each motion also accepts an optional count, which defaults to 1 if you don’t provide it.

  • For example, use 2f; which would be the same as f;f;.
  • Or 7b which would be the same as bbbbbbb.

Currently the text is fairly short, but we can fix that. Select everything with %, yank y and then paste it 100 times with 100p. This will create a very big file.

We can use these commands to scroll large chunks of text at once:

  • Ctrl + d to scroll down half a page
  • Ctrl + u to scroll up half a page

Next steps

Now you know the basics of movement in Helix, it’s time to learn about the more advanced features Helix provides.