Efficient Text Selection with Emacs Key Bindings - Emacs Essentials #3

preview_player
Показать описание
In this video, we'll learn how to efficiently select text using Emacs' built-in key bindings! We cover the "mark," the region, and the various ways we can use those to select text. I'll also tell you about the "mark ring" and how it can be a very quick way to navigate back to previous locations you visited in the buffers you are editing!

We cover the following topics:

- 0:00 Intro
- 0:36 What will we learn?
- 1:17 What is the "mark"?
- 2:55 Creating Regions
- 11:57 Specialized Marking Commands
- 17:24 Remember Your Place with the Mark Ring
- 22:44 The Global Mark Ring
- 25:51 What's next?

If you enjoy this series, please consider becoming a sponsor on GitHub or Patreon:

Follow me on Twitter for more GNU Emacs and GNU Guix content!

Check out my other video series!

Music credits:

Рекомендации по теме
Комментарии
Автор

Another very useful thing is that emacs also has a ring for remembering the last whatever number or things you have cut or copied with C-w and M-w.
So when you use C-y to yank (paste), you get the most recent chunk of text, but then you can keep pressing M-y to cycle through all the other recent chunks of text in the ring.

Lea_D.
Автор

Your videos have really convinced me to switch to emacs. Once my exams are over, I'll go all evil mode. More on the lisp series though 👍

shubhampawar
Автор

From the Emacs manual: "Each time you set a mark, this is recorded in the global mark ring in addition to the current buffer’s own mark ring, if you have switched buffers since the previous mark setting. Hence, the global mark ring records a sequence of buffers that you have been in, and, for each buffer, a place where you set the mark. The length of the global mark ring is controlled by global-mark-ring-max, and is 16 by default."

The key phrase, I believe, is "if you have switched buffers since the previous mark setting." So, setting a mark in buffer A will set in global-mark-ring, switching to buffer B and setting mark will also record in global-mark-ring, but setting a second mark in buffer B will NOT set the second mark in the global-mark-ring as you haven't switched buffers. (It will of course, record the mark in the buffer B mark-ring.


I wish you had mentioned registers in this video though, as they can be more useful than marks, IMO. Basically the same as Vim's named registers, they can store text, position, rectangles, numbers, etc. It can be complicated, but if you know you want to temporarily store 2-5 positions in a file and jump between them, registers are more direct than the mark-ring as you don't have to cycle thru them. More than 2-5 though is a little cumbersome.

aehjr
Автор

Please keep making these videos — they’re SO helpful for an Emacs noob like me!

theears
Автор

Thanks for the video. I usually prefer to read then watch but you explain so many things, which are note straight forward.

BTW, while querying for the mark ring, I came across an another useful feature called "registers". It's also very useful because I can store a position, a number, a region etc. Particularly, if I store a position in a buffer using "C-x r SPC <key>", where key is a, b, or r, I can come jump to such position (including jumping to a buffer) by pressing "C-x r j <key>". It's even better! When a buffer with the stored position was associated with a file, the file was closed, and I claim the stored position, Emacs is going to ask to re-visit the file meaning it will re-open a file and jump to the position. AMAZING!!!

Celdorsc
Автор

In emacs, the page break mark is ^L (binary), as I understand. It is used in info pages and other documents. To mark page, you need to have that byte in the file, otherwise it will continue to the end of the file, and to the start of the file.

abarocio
Автор

Your idea of C-space as an evil mode leader key is really intriguing to me. I wonder if there are any trade-offs I should bear in mind?

I'm currently a Vim user but looking to hop across to emacs, and I use space as the leader key in Vim. I'm using vanilla Emacs for now without Evil to make sure I understand what's going on. I'm concerned that I might miss useful functionality in Emacs if I shoe horn in a Vim way of doing things.

robertkirby
Автор

I've seen the three videos in this playlist and didn't see you explain this type of command "C-u 7 command" or the equivalent "M 7 command", why didn't you explain it? It's not used much? Which playlist can I go on after this? thanks...

richardfrangie
Автор

The sexp and defun command work in more than just emacs lisp buffers. Most programming modes (and some others) define what those represent. mark-defun usually marks a function or method any programming language and mark-sexp usually an expression. Also C-M-SPC is also mark-sexp.

hmelman
Автор

I like how you did not mention transient mark mode, which is on by default since Emacs 23. I always found it confusing and questioned if I should change the default. I appreciate just the simple approach to how to use the mark ring with the default settings. I like this for a quick getting back to where I was and use bookmarks for specific positions I use on a regular basis such as dired buffers, org clock table, cheat sheet, etc.

mbarton
Автор

^L mark a new page.

Isn't C-x C-SPC just changing files, and then you use C-u C-SPC for going among the local mark ring.

C-x C-x exchange place of cursor and mark.

AndersJackson
Автор

How do you jump forward in the mark ring?

juliuskiesian
Автор

Hi. New to this channel. Did you do more episodes in this series? Cheers.

mgorn
Автор

Oh hi, Mark

Isnt this "The Room" reference? :D

azegaspa
Автор

You asked for things to potentially cover for newcomers: Perhaps buffer/file/window switching and the packages that can help with that (dark hole, I know).

(while I'm here; your 09:-ish PST livestream timing is awesome for folk in the EU and IND. Please be aware, though, that for the next few weeks you are bang in the middle of the IPL [the cricketing term, not the mainframe booting process 😄]. Check your visit stats and see if it has any effect)

auntiecarol
Автор

The global mark ring can hold multiple marks for buffers but if you create two in sequence in the same buffer the second one will replace the first, I believe.

karusster
Автор

Question: how do you unhide org emphasis markers when put cursor on it?

haiteng