💾 Archived View for lantashifiles.com › gemlog › entries › 2024-07-01.gmi captured on 2024-08-25 at 00:26:08. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-07-09)

-=-=-=-=-=-=-

Emacs Fun - Split Window

Summary

I want to talk about different features of Emacs, such as programming Lisp, running the built-in apps (games, doctor, web browser), using a shell, and more.

I like to do my writing and programming in Emacs! All wood elves do, btw. It is a Sylvan tradition!

This first entry is about splitting windows, to be able to more efficiently work on documents. I'll mention a few more details (ex. saving a buffer) in this one as well.

Terminology

Parts of Emacs

Abbreviations

C = Cntr (Control key)

Meta = your meta key, usually Alt (sometimes Escape)

Keystrokes

Splitting Windows

By "splitting the window", I mean that in a single running instance of Emacs, you can have multiple windows open tiled in the single Emacs instance. (see images below)

You would do this to have 2 separate documents open at the same time, or you could have the same document open, maybe to diffent locations in your document. You could be editing line 20 on the left window, and line 100 on the right. You would be looking at 2 different parts of the exact same document, and you can make change to both parts at once.

You can also have two separate windows, looking at two separate documents.

For example,

1. emacs doc1.gmi (open a document)

2. C-x 3 (open a new window to the right, same document will be displayed in both)

3. C-o (switch focus to the right window)

4. C-x C-f (Open a different existing file)

You then have two documents open, side by side.

Of course, you can always do this with:

emacs doc1.gmi doc2.gmi (opening 2 documents top-to-bottom)

Why edit the same file in two different Windows?

Emacs Windows, Same Document, Side-by-Side

There are a lot of reasons you might want to edit two different points in the same text simultaneously. For me, the reason is that I might be writing a particularly long scene. Let's say the scene is 1500 words. I might need to keep details, descriptions of characters, things like that synced in my text, but I want to be able to view two parts of the same document at once.

This problem grows if you use a single document for an entire chapter (or an entire book!). You might have 40,000, 50,000 words in your document! If you really need to reference one part of your document while writing another, then having the same document open in two, three, or more windows in Emacs might be the solution!

I really like being able to view different parts of the text I am working on opened side-by-side. Side-by-side is my preferred way of working, than top-over-bottom.

Why edit the same file in two different Windows?

Emacs Windows, Different Documents, Top-to-Bottom

The other use of multiple windows in Emacs is to edit separate documents!

When working on a story, I might want my actual text for a scene opened in one window, and the notes for the scene, or the plot, opened in other windows. The possibilities, the different types of documents opened at once, are endless.

Now, you might be asking, "Can't I just have 2 (or more) instances of Emacs opened with the documents I want to work on?

Yep, of course, assuming you are using a windowed environment and not just booting into the Terminal.

Is there an advantage two using two or more windows in a single Emacs frame to edit multiple documents at once? I say yes, since when use are using Emacs, all your opened documents for that effort are right there, visible at once. Also, you navigate between these documents using Emacs shortcuts, rather than having to Alt-Tab to them. And using this technique, your documents don't get lost behind each other.

That's my opinion, but I'm used to working this way. There's nothing wrong with using multiple instances of Emacs, or other applications, to do your work.

Coding!

I've mainly been describing using Emacs to work on writing, for example with stories or gemlog posts, etc. Emacs is also great for writing computer code, and having multiple windows open for editing that code can be very useful.

If you have a thousand line long class, it can be very help to view different parts of that file at the same time. Using Emacs windows makes that very easy! Or if you have two classes that interact with each other, having them opened side-by-side or top-to-bottom makes it a lot easier to conceptualize what you want to do, what you are working on.

Conclusion

So that is a brief introduction to using multiple windows in Emacs! This can be very useful for both writing, and programming, by letting you see and edit more information at the same time!

Links

Splitting Windows in Emacs

Lantashi Files, main section

Email: lantashi [at] protonmail [dot] com