edit
edit: a simple text editor, after nano.
Synopsis
edit [file]
Description
edit is a full-screen text editor, in the style of nano. It shows a title bar (with the file’s name, and Modified once it has changed), the text, a status line, and two lines of shortcuts.
It opens file if it exists, and says [ New File ] if not; with no file it starts an empty buffer, and asks for a name when it is written out.
Typing inserts text at the cursor; Tab inserts two spaces. A line too long for the terminal scrolls sideways on the cursor’s line, with a $ where it goes on past either edge.
edit runs on the terminal’s alternate screen with the tty in raw mode, and puts both back however it ends.
Keys
- Arrow keys, Home, End
- Move the cursor. Left and Right go on to the next or the previous line.
- PageUp, PageDown, ^Y, ^V
- Move a screen up or down.
- ^A, ^E
- Go to the start or the end of the line.
- Enter
- Split the line at the cursor.
- Backspace, Delete
- Erase the character before or under the cursor, joining lines at either end.
- ^K
- Cut the cursor’s line. Cuts one after another go together.
- ^U
- Paste the lines last cut, above the cursor’s line.
- ^W
- Search for text (case matters), from the cursor on, wrapping round at the end. An empty answer searches for the last text again.
- ^C
- Show the cursor’s position: line, column, and how far through the file.
- ^O
- Write the file out, asking for its name (the current one is offered).
- ^X
- Exit. With unsaved changes it asks whether to save them first: Y saves (and exits only if that worked), N throws them away, and ^C cancels.
At a question on the status line, Enter answers it, Backspace erases, and ^C or Escape cancels.
Exit status
0 when it exits normally, including at the end of its input; 1 if file exists but cannot be read.
Notes
A file is written with a new line after its last line; a carriage return at the end of a line is dropped when the file is read. There is no undo, no syntax highlighting, and no mouse support.
See also
less(1), cat(1), stty(1)