(redirected from Homepage)

Strona domowa

Witam na mojej prywatnej stronie internetowej!

[If this is all Polish to you, click here: English]

Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.

Marcin ‘mbork’ Borkowski

2024-03-18 Follow mode

It is a fairly common opinion that a function should not be larger than your screen. The reality, though, is often different. And even if your functions are shorter, you may want to see more than one at a time. The problem is that our screen are usually not that high. (My laptop gives me 66 lines of text with normal font settings.) You can have an external monitor rotated vertically (I have that at work to see as much of the logs of the application I’m working on as possible), but Emacs gives us another solution – the Follow mode. If you split your window into two (or more) side-by-side windows (for example, using C-x 3) and say M-x follow-mode, the other window will start displaying the “next portion” of the current buffer – that is, its top line will be the line just below the bottom line of the current window. Whenever you scroll either window, the other window follows, so both windows always show two adjacent parts of the current buffer. What’s more, when you go to the bottom line of the current window and press C-n to get to the next line, Emacs automatically switches to the other window without scrolling. This means that the two windows combined will act as one big “virtual window”.

There is also the follow-delete-other-windows-and-split command, which does exactly whet it says on the tin.

It turns out that Follow mode is even better than that! It seems to automatically detect all windows showing the buffer with Follow mode enabled, so if you activate it first and split the window after that, it also works. And it is not restricted to two windows! Try hitting C-x 3 twice (to get three windows) and using Follow mode then – you’ll have three windows following each other. (By the way, if you start with a single window and press C-x 3 twice, you’ll end up with two windows occupying 25% of your Emacs frame’s width and one having 50%. You can remedy that with M-x balance windows. It is smart enough to work reasonably even if you have some windows split vertically and some horizontally. There is also M-x balance-windows-area, which resizes all windows so that their area is the same – try e.g. C-x 1 C-x 2 C-x 3 M-x balance-windows-area to see how it works!).

The last thing I’d like to mention in my paean about Follow mode is that when you want to view the file instead of editing it, it may be a good idea to also turn on Scroll lock mode, where keys used to move the point vertically (like the up and down arrows) scroll the buffer instead.

And that’s it for today – see you next time!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...