Editors
NEdit
Don't have time or interest to learn a Unix editor? ...then nedit is for you.
nedit belongs to the family of WYSIWYG (What You See Is What You Get) editors.
Wysiwyg editors tend to be mouse-based and are easy to transition to if you have a stronger
history with Macintosh or Windows editors. You can add text wherever the cursor is positioned
and a swift hit of the delete key will remove any text that is highlighted. nedit
offers extensive customization, even to the point of establishing automatic backups. There is
a low- to no-learning curve with nedit. You can literally open a file and start
working immediately with this editor.
EmacsEmacs (pronounced ``ee-max'') is the most powerful of the native Unix editors.
Before the idea of Open Source software, most Unix users ended up having to learn either vi or
emacs. Neither program is particularly user-friendly,
but emacs is certainly more broad in its usefulness. For example,
emacs supports mouse based editing, multiple windows, and
understands the syntax of several high-level languages, like
TeX. Moreover, emacs has extensive online documentation,
including a tutorial which should make this section superfluous; when in emacs just
type h while holding down the control key.
If you take some time to learn the program, you will find it more
useful than vi in the long run.
Emacs Programemacs. This opens a separate
window that looks much like the sample Emacs window shown below. If you want to open an existing
file, or even an empty file, just include the file name on the command line:
emacs file1.txt
The name of the file is arbitrary.
If you are working remotely, the spawning of an external window may be problematic. If this is the case, you can startup emacs without generating an external window using:
emacs -nw file1.txt
Emacs Screen
emacs is an editor that wishes it were an
operating system. That menu also gives you access to the list of
Frames, which is what emacs calls windows. The
Tools menu lists various tools for manipulating your file in
high-powered ways.
Warning Unless you know what you are doing, avoid the Read Mail menu item in the Tools menu. This will allow you to read your email, but will save your mail in a file format indecipherable by any other known mail reader. Once in, this format, tedious human intervention is required to return your email to a more conventional format.
If you are editing a file in a complex language, for example TeX,
there will also be menus specific to that language. Do explore this
with a TeX file. You will be surprised at how well emacs
becomes an integrated environment for previewing and printing, as well
as editing, TeX.
Across the bottom of the screen is a black bar - the status bar. On
the left side of the status bar is the name of the file you are
editing. Next is the an indication of what sort of file emacs thinks
you are editing (see the discussion of major and minor modes in the
emacs online documentation for more on
this. Emacs understands TeX, HTML, C, and a host of other
languages besides plain text.)
Above the status bar is the edit pad - it contains the text of the file you are creating/editing.
Keyboard commands, the cornerstone of emacs' power, will appear in the command buffer, located below the status bar. This is one of the most important regions of the emacs window.
Emacs Commandsemacs commands use the mouse to select and move
regions of text, extending the basic X-windows facilities. For
these it is hard to beat the explanation in the online tutorial.
All other emacs commands are entered via
Control and Meta keys. For example, the
command to save a file is Control-x Control-s (also
written as C-x C-s). While holding down the
Control key with your left hand, tap the x
key (after a second or two, you will see C-x under the
status bar). Then, while holding down the Control key
with your left hand, tap the s key. While most keyboards
have a Control key, most don't have an explicitly labeled
Meta key. Often the Meta key is is the
Alt key, which can be held down, but hitting the
escape (labeled Esc) key briefly will always
work. For example, to type Meta-x (also written
M-x), you should either hold down the Alt key and
tap the x key, or, if this doesn't work, tap the
Esc key and then the x key.
C-h
emacs Help system
C-h t
C-h i
info documentation system
C-h a
C-b -or-
/ C-f -or-
M-b / M-f
C-p -or-
/ C-n -or-
M-a / M-e
C-v / M-v
M-> / M-<
DEL / C-d
M-DEL / M-d
C-x C-s
C-x C-f
C-x i
emacs:
C-x C-c
emacs permanently
C-z
emacs temporarily (type fg to resume
C-s
C-r
Esc
M-%
C-_
shift -)
C-g
emacs manual and the O'Reilly
Learning GNU Emacs book are available for
checkout in the library.
vi
vi (pronounced vee-eye - short for the word
visual) - was the first Unix full-screen editor. Most UNIX
users end up having to learn either vi or emacs.
Neither program is particularly user-friendly, but vi is
handy for quick editing sessions. Here is a brief lesson:
vi Programvi file1.txt
Sometimes, you may find yourself looking at a window which looks like:
vi by mistake. Don't
despair, all is not lost. Read on to find out how to quit, or even proceed productively.
vi:
There are several groups of commands, listed below. Most commands
will take a numerical prefix; for example, 7w means ``jump
ahead seven words'', and 3dd means ``delete the next three
lines''. Note that you cannot enter any text until you switch to
input mode. (This is not an exhaustive list of commands.)
h -or-
l -or-
j -or-
k -or-
w
b
nG
$
^
G
x
dw
dd
D
r char
cw word
i
a
I
A
o
O
R text
yy
dd
p
P
:3,5s/foo/bar/g
g this would only replace the
first occurrence of foo on each line.
:1,$s/foo/bar/g
:3,5s/$/xyz/
:1,$s/^/xyz/
:w
:wq
:q
:q!
vi (without saving changes), even though you
have changes to save
:e foo
u
.
/text
?text
n
/ or ? search
Return key (called Enter on some keyboards)
at the end of every line.
To switch back to command mode, press: Esc (escape).
Warning One of the most common errors in vi is
to type a command while still in input mode. If you do this, the
command will show up in the text! Remember, to type a command you
must first return to command mode by pressing the Esc
key.
vi editor
book are available for checkout in the library.