File Creation and Editing

Command

Meaning

emacs

Text editor from Free Software Foundation.

vim

Text editor, extension of Unix vi.

look

Print dictionary words on standard output.

To make best use of the Terminal, you must become proficient with a text editor available from the command line. For editing the plain text files you’ll need for shell operations, word processors such as Microsoft Word and Apple’s TextEdit are not appropriate because they insert invisible text-formatting characters into the files.[8] Plus they are graphical applications that run only on the Mac’s monitor, so they won’t work for remote logins (for more information, see Running a Shell Remotely). The two major editors are Emacs from the Free Software Foundation, and vim, a successor to the Unix editor vi.[9] Teaching these editors fully is beyond the scope of this book, but both have online tutorials, and we list common operations in Table 2-1. To edit a file, run either:

emacs myfilevim myfile

If myfile doesn’t exist, it is created automatically the first time you save.

[8] Technically, you can use TextEdit if you save its file in the format “Plain Text.” If you don’t, other shell commands will not operate properly on these files.

[9] Another available editor is pico, which is simpler than Emacs and vim but more limited: see man pico for details.

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.