Emacs: search and replace basics

preview_player
Показать описание
Overview of the powerful tools Emacs has to search files, create a dynamic index of matches, search and replace, use grep and make editable grep buffers, match strings or regular expressions, etc.

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

good you are going back to basics for people who are quite new to emacs. However your tutorials are often very detailed and even more experienced users learn something new.

MoreChannelNoise
Автор

Thank you very much for another very helpful video, Prot!

Time stamps:

0:00 Introduction
1:20 Incremental Search forward with 'isearch-forward'
2:56 Incremental Search backward with 'isearch-backward'
3:50 Edit current search (M-e)
4:50 Different ways to exit isearch
7:07 Repeat last successful search (C-s C-s)
8:45 Regexp search (C-M-s)
11:08 The 'occur' command (M-s o)
14:54 Calling 'occur' from inside isearch (feed isearch-results into occur)
16:40 Configure search counter
18:40 Configure whitespace in isearch
21:18 Search and replace with 'query-replace' (M-S-%) and 'query-replace-regexp' (C-M-%)
25:14 Calling 'query-replace' on isearch results
26:02 Feeding 'isearch-regexp' results into 'query-replace' (C-M-% oder M-%) to rearrange text
30:17 Use 'occur' to perform replacements
33:30 Using keyboard macro in occur buffer
35:22 Using grep in Emacs (tool for searching file contents)
38:20 The 'wgrep' package (tool for editing grep buffers (C-x C-q))
40:38 The 'consult' package
41:20 The 'consult-line' command
43:11 The 'consult-outline' command (search for headings)
44:10 The 'consult-imenu' command (semantically relevant grouping of headings i.e. points of interest)
45:33 The 'consult-grep' command
48:02 The 'embark' package (perform context-sensitive actions)
48:48 Export results from 'consult-grep' to regular grep buffer with embark
50:13 The 'isearch-highlight-regexp' command (M-s h r): highlight specified regular expressions in current file
52:08 Unhighlight specified regular expressions (M-s h u)
52:26 Wrapping up

mcxds
Автор

I've been using Emacs for over 20 years, but it's easy to forget all of the functionality built into something fundamental like isearch. These videos of yours are fantastic reviews of the blocking and tackling of Emacs. Good job, Prot.

danieldoherty
Автор

It's also worth pointing out to beginners that, searching and other moving commands, set the buffer "mark" where you were before searching/moving.

The mark is like a second cursor which is set by some actions, and the space between the mark and the cursor (point) is known as the region. The region is like your selected text in other editors, but much more powerful.

Once you have searched, you can immediately enter a command that acts on the region, for example C-M-\, indent region. Or activate the region and replace occurrences. Or narrow the region. Or undo within the region (ignoring undo in other parts of the file). It's very flexible.

Another example: you paste some code. It automatically sets the mark where the cursor was before pasting. So you can go to the initial part where the code was pasted by just going to the previous mark using C-u C-SPC (every time the mark is set, it remembers the previous one). Or immediately indent the pasted code by pressing C-M-\ right after pasting.

And all of that is vanilla Emacs, out of the box!

georgH
Автор

Cool. Thanks vaery much 🙂 I can't imagine that searching have so many possibilities!

alexei
Автор

Your videos are awesome ... so inspiring. Thank you

seriousjan
Автор

I've finally understand why you have "#" whenever you invoke "consult-grep" 😅 now it makes sense to send pattern to grep and then after the second "#" to filter the results in the minibuffer.

I also liked the more advanced regexp example using groups. If you could do another video on common use cases for regexp's (groups, multiline etc.) that would be great.

Thanks for the awesome content! Sometimes the fundamentals are good enough!

peterpetersky
Автор

thanks for another video where i learned a lot :)

EdouardTavinor
Автор

very good video I learned a lot Thanks. One thing tho I use Emacs in Windows and can't find grep for windows so grep doesn't work in Emacs.

chuckyurek
Автор

Hei!
Thanks for the video!
Could you please share what font you are using in Emacs?

melancholy-engineering
Автор

maybe i'm not the target audience for these videos but im a bit disappointed you didn't touch on re-builder, is such a nice interface to be validated in real time if the regex you're crafting is matching the string(s) you want.

mksybr
Автор

I think this is what multiple cursors does but without the flexibility and complexity.

comproprasad
Автор

Hey Prot, First, thanks for putting together these videos. They are very educative. I use ivy and want to know which package you are using to show a preview of the font faces available for highlighting. Thanks for the help in advance.

chehrazin
Автор

so no need for lsp server this seems to give much better control

anneallison
Автор

Hi, is it possible to narrow by file in consult-grep ?

Also, consult-imenu for me shows a flattened list rather than a semantically separated list like you show. Am I missing some configuration somewhere ?

smalltimer
Автор

How I can replace some text in many files in differents folders?

alexei
Автор

I would love to see you add timestamps to your videos. I think a lot of your fans would benefit from a way to jump back and forth between sections as well as point others to a portion of your videos

GavinFreeborn
Автор

Oooooh I caught a moment where you deleted other windows, but only on one side of the screen. Caught that binding as ~C-x !~ and the function is That's a great binding, I'm using that.

willvaughn