Exploring one’s computer with Emacs

Goal

This note outlines how to use Emacs to navigate into one’s directories and files.

Where to start and how to get there

So you have started Emacs. Emacs is a program, and it runs at some starting place in your directories. Where? To answer this question, type:

C-x C-f

The answer is in the minibuffer, at the bottom, and most likely it isn’t where you want to be. To change that and get into your home directory, type (in the minibuffer):

~/. RET
Harald: So / is pronounced “slash”?
Alfrothul: And \ is pronounced “backslash”?
Brynja: Yes and yes. Also, /. is pronounced “slashdot”.
Harald: And that stuff matters why?
Brynja: Read the news.

i.e., the key ~ (which is pronounced “tilde”), followed by the key / (pronounced “slash”), followed by the key . (pronounced “dot”), followed by the enter key. The resulting buffer is that of your home directory in all its glory, sorted alphabetically: as indicated by the mode line, you are editing it in Dired mode (or, to be precise: in Dired mode by name). (If you prefer to view your home directory sorted with the most recent files first, type s: you are now editing your home directory in Dired mode by date. (Type s again to toggle the alphabetical order back.))

In this buffer, you can navigate up and down the directory structure with C-n and C-p (or alternatively with the up and down arrows).

To create a directory, type +, then the name of this directory, and then RET. (And to know more about the key bindings of this mode, type C-h B (i.e., C-h S-b).

Assuming you have already created a subdirectory named Courses, containing a subdirectory named 2018-2019, containing a subdirectory named Sem2, containing a subdirectory named Intro-to-CS, you can get there by typing:

C-x C-f ~/Courses/2018-2019/Sem2/Intro-to-CS/ RET

(Remember that hitting the tab key autocompletes.)

It is a good idea to create subdirectories named Week-01, Week-02, Week-03, etc.

The rest of this note assumes that you are in the directory ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-01/.

Food for thought

Keeping in mind that .. (pronounced “dot dot”), in the name of a directory, refers to the directory just above the current one, what are the directories denoted by the following names?

  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/.
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/..
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../.
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-01
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-01/
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-01/.
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-02
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-02/../Week-02
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../Week-02/../Week-02/../Week-02
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../..
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../.
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../..
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../../..
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../../../..
  • ~/Courses/2018-2019/Sem2/Intro-to-CS/Week-02/../../../../../..

Hint: for each of these names, type C-x, followed by C-f, followed by this name, followed by RET.

Harald: Gee, I wonder what happens if I type C-x C-f .. RET.
Brynja: Well, try it.

About editing with multiple windows

Reminder:

  • C-x 3 splits the current window into 2, vertically
  • C-x 2 splits the current window into 2, horizontally
  • C-x 1 selects the current window as being the only one in the frame
  • C-x 0 makes the current window disappear in the frame (it is not lost, witness C-x C-b)

Conclusion

You now are in control of where your files are located and where the Emacs process runs.

Harald: Man, there is everything in Emacs.
Alfrothul: Did you try M-x hanoi?
Loki: And M-x doctor?

Practical recommendation

Remap your CAPSLOCK key to behave like a control key and live better.

“Mad Eye” Moody: CONSTANT VIGILANCE!
Brynja: What he said.

Version

Created [14 Jan 2019]