The Minibuffer
When you issue an M-x or C-x command that requires some parameter, emacs
will display the command in the minibuffer at the bottom of the screen,
and move the cursor there, waiting for your input of the parameter.
A D V E R T I S E M E N T
In some
cases, emacs will offer a default value for that parameter. If the
default is OK, just hit the Return key; otherwise, use the Delete key or the
Backspace key (might be different on different terminals; try it out) to
partially or completely erase the default, and type in the parameter.
Loading Files
As mentioned earlier, the command C-x C-f will prompt you for a file name,
create a new buffer, and load the file into that new buffer. Here are some more
details, illustrated with an actual example.
I typed C-x C-f. Emacs responded by displaying the following message
in the minibuffer:
I was currently in the directory indicated, i.e. tmp/tmp. I knew that the
file I wanted began with the string `Sum', but didn't remember the rest, so I
took advantage of emacs's name completion feature: I hit the Space
bar, resulting in emacs creating and displaying a buffer named
*Completions*,
with contents
Possible completions are:
Sum Sum.c
Sum.lst Sum.mas
Sum.out Sum.sym
which was a list of all files in that directory whose names began with `Sum'.
I saw that the file I wanted was Sum.mas, so I typed `.m' and then hit the Space
bar, so that the minibuffer now looked like
Find file: ~/tmp/tmp/Sum.mas
That is what I wanted, so I hit the Return key, and emacs then loaded
the file.
If I had wanted to switch to another directory, I could have backspaced in
the minibuffer, erasing part or all of the path displayed there.
Note that this is useful not just if you have forgotten a file name, but also
to save typing.
Windows
As mentioned before, a very nice feature of emacs is the ability to
split a given buffer into two or more windows, enabling one to view more than
one piece of a file at a time. Here are the main commands:
C-x 2 split current window into two windows
C-x o move cursor to the other window
C-x 1 unsplit, i.e. change back to having just one window on
this buffer
C-x 0 move cursor to the other window and make that one fill
the screen (same as C-x o followed by C-x 1)
C-x ^ make current window larger (and other window smaller)
For example, suppose I currently just have one window on my WC.c buffer in
the example above. If I type C-x 2, the result will be:
/* introductory C program */
/* implements (a subset of) the Unix wc command -- reports character,
word and line counts; in this version, the "file" is read from the
standard input, since we have not covered C file manipulation yet,
/* introductory C program */
/* implements (a subset of) the Unix wc command -- reports character,
word and line counts; in this version, the "file" is read from the
standard input, since we have not covered C file manipulation yet,
but of course a real file can be read by using the Unix `<' redirection
Now I can scroll the two windows independently. For example, suppose I want
one window to show the function WordCount(), and the other window to show the
call to that function.
What I can do is use the vi search command `/' to look for the string `WordCount',
and thus position the two windows as desired:
int WordCount()
{ int I,NBlanks = 0;
for (I = 0; I < LineLength; I++)
if (Line[I] == ' ') NBlanks++;
/* ordinarily the number of words is NBlanks+1, except in the case
in which the line is empty, i.e. consists only of the end-of-line
character */
Line[LineLength++] = C;
if (C == 10) break;
}
NChars += LineLength;
NWords += WordCount();
NLines++;
return 0;
}
|