Text Editor
edit is the full-screen text editor built into Harucom.
Use it to write Ruby scripts and to change settings files.
Contents
- Starting the Editor
- Reading the Screen
- Key Bindings
- Saving
- Quitting
- Syntax Highlighting and Auto Indent
Starting the Editor
At the IRB prompt, type edit followed by the name of the file to edit.
irb> edit hello.rb
A file that does not exist yet is created. An existing one is opened as it is.
The editor also starts without a file name. In that case you name the file when you save it.
irb> edit
After moving with cd, a plain file name opens a file in that directory.
A path from / works too.
irb> edit /app/hello.rb
Reading the Screen
The status bar at the top shows the file name and the cursor position.
hello.rb [+] 12:5
[+] means there are changes you have not saved yet.
Without a file name, the status bar shows [untitled].
Key Bindings
| Key | Action |
|---|---|
| → / ↑ / ← / ↓ | Move the cursor |
| Home / End | Jump to beginning / end of line |
| PageUp / PageDown | Page scroll |
| Backspace | Delete the character before the cursor |
| Delete | Delete the character at the cursor |
| Enter | Insert a new line |
| Ctrl-S | Save |
| Ctrl-Q | Quit |
| Ctrl-Z | Undo |
| Ctrl-Y | Redo |
Saving
Ctrl-S saves the file.
When the file has no name yet, the editor asks for one. Esc cancels the save.
Quitting
Ctrl-Q quits and returns you to IRB.
With unsaved changes, the editor asks first.
Unsaved changes. Quit? (y/n):
y quits without saving and n returns to editing.
Syntax Highlighting and Auto Indent
When the file name ends in .rb, the editor helps with writing Ruby.
Syntax Highlighting
Strings, keywords, comments, and numbers are colored,
which makes a missing end or an unclosed string easy to spot.
Auto Indent
A newline after def, if, or do is indented for you.
Typing end or else moves that line back to where it belongs on its own.
def greet(name)
puts "Hello, #{name}!"
end
Related Pages
- Japanese Input — Japanese can be typed in the editor too
- Commands — file handling with
cat,cp, and the rest - File I/O — where files live and how to run scripts
- Getting Started — writing your first program