Surviving Helix
This page is for getting things done in Helix, the editor on the CS 70 server. It is not a tour of everything Helix can do, and it will not try to turn you into a fast typist. It covers the parts you need to edit a file, save it, and get out again.
You do not need to become good at Helix to do well in CS 70. Helix can be driven by an expert at high speed with no hands leaving the keyboard. You are welcome to become that person; the course does not ask you to.
Two things that are true right away
Your mouse works. Click to put the cursor somewhere. Drag to select. The scroll wheel scrolls.
Your arrow keys work. Up, down, left, right, all as you would expect.
That is enough to move around any file on the server. Everything else on this page is about typing, saving and leaving.
I heard Helix is one of those editors where you can't type and you can't get out and everyone laughs at you.
That reputation belongs to a different editor, and it is thirty years old.
You will not be trapped: there is a way out, it is on this page, and it takes two keystrokes.
Meh. Why can't I just use something normal?
When it comes to editors, “normal” is a matter of taste. Helix is a modern editor that is designed to be easy to use and easy to learn. Terminal-based editors are a good choice when accessing remote servers, which is why it is the editor on the CS 70 server.
I like
vim.
But
emacshas MORE features!
And
nanois simple and easy to use.
People can argue about which editor is best, but it's good to train yourself to be flexible.
Opening a file
hx main.cpp
If the compiler has just told you the problem is on line 42, you can go straight there:
hx main.cpp:42
Helix opens with the file on screen and a status line along the bottom. The left of the status line shows the current mode, which is the one idea on this page worth understanding.
Modes: the thing that surprises people
Helix starts in normal mode, shown as NOR at the bottom left. In normal
mode, the letter keys are commands, not text. Pressing d does not type a
d; it deletes something.
To type text, press i. The mode indicator changes to INS, and now the
keyboard behaves the way you expect it to.
To stop typing text, press Escape. The indicator goes back to NOR.
That is the whole thing. i to type, Escape to stop.
What if I forget which mode I'm in and start typing?
Look at the bottom left. If it says
INSyou are typing text; if it saysNORyou are issuing commands. If you have typed nonsense by accident, pressEscapeand thenuto undo it — see below.
This seems like a lot of ceremony to type a semicolon.
It is one extra key at the start and one at the end. That is genuinely all it costs you.
Undo
Press Escape first to get back to normal mode, then press u.
Press u again to undo more. Each press goes back one step.
Saving and quitting
These all start with a colon, typed in normal mode. Press Escape first if
you are not sure which mode you are in. Type the colon, then the word, then
Enter.
| What you want | Type |
|---|---|
| Save | :w |
| Quit | :q |
| Save and quit | :wq |
| Quit and throw away my changes | :q! |
If you try to quit with unsaved changes, Helix will refuse and tell you so along the bottom of the screen:
'quit': 1 unsaved buffer remaining: ["main.cpp"]
This is not an error you have caused, and nothing is broken. Helix is asking
you to choose. Either save and quit with :wq, or discard your changes with
:q!.
The status line also shows [+] next to the filename whenever the file has
changes you have not saved yet.
If you are lost, do this
- Press
Escape. This gets you out of any mode you did not mean to enter. - Look at the bottom left. It should say
NOR. - If you have made a mess, press
uuntil it looks right again. - If it is beyond saving, type
:q!and pressEnter. That leaves without writing anything, so the file on disk is exactly as it was when you opened it.
Step 4 always works. Nothing you do inside the editor can damage the file on disk until you save it.
So the worst case is that I lose the typing I just did?
Yes. That is the worst case.
One more idea, if you want it
In normal mode, the cursor is not really a point — it is a selection, one character wide by default, which is why the character under the cursor looks highlighted.
That is why d deletes: it deletes the selection. Select more, and d
deletes more. It is the whole design of the editor in one sentence — you
choose the thing first, and then say what to do with it — and it is the main
way Helix differs from editors you may have read about.
You can ignore this entirely and still finish the course.
Going further
Helix has a built-in tutorial. On the server, run:
hx --tutor
It is self-paced, and nothing in CS 70 requires you to finish it.
And if I just want to be left alone with my mouse and my arrow keys?
Then you now know everything you need.
ito type,Escapeto stop,:wto save,:qto leave.
This page is a first draft, written the night before the site went live. The keystrokes on it were checked against the version of Helix actually installed on the CS 70 server (helix 25.07.1). If something here does not match what you see, please tell an instructor or grutor — that is a bug in this page, not a mistake on your part.
(When logged in, completion status appears here.)