add the old snippet md files
This commit is contained in:
parent
fc0dd204c7
commit
bcf8313a4b
110 changed files with 3048 additions and 0 deletions
67
old_snippets/emacs-replace-across-multiple-files.en.md
Normal file
67
old_snippets/emacs-replace-across-multiple-files.en.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
title: "emacs replace across multiple files"
|
||||
seo_description: "emacs tutorial on how to replace / edit across multiple files"
|
||||
date: 2021-11-28T18:49:21+01:00
|
||||
draft: false
|
||||
snippet_types:
|
||||
- emacs
|
||||
---
|
||||
|
||||
This week I was making some changes to a [hugo shortcode](https://gohugo.io/content-management/shortcodes/) I use on my personal
|
||||
site for videos.
|
||||
|
||||
Old one:
|
||||
|
||||
```
|
||||
{< video-with-caption
|
||||
remote_url="https://travisshears.com/image-service/videos/galtenberg-ski-tour/over_the_tree.webm"
|
||||
backup_url="https://travisshears.com/image-service/videos/galtenberg-ski-tour/over_the_tree.mp4"
|
||||
title="through the woods we go"
|
||||
>}
|
||||
```
|
||||
|
||||
New one:
|
||||
|
||||
```
|
||||
{< video-with-caption
|
||||
webm_url="https://travisshears.com/image-service/videos/galtenberg-ski-tour/over_the_tree.webm"
|
||||
mp4_url="https://travisshears.com/image-service/videos/galtenberg-ski-tour/over_the_tree.mp4"
|
||||
title="through the woods we go"
|
||||
>}
|
||||
```
|
||||
|
||||
Problem is this change crosses 50+ files. I knew some ways with sed to regex
|
||||
substitute it across the files but I wanted something more emacs. Eventually
|
||||
found [wgrep](https://github.com/emacsmirror/wgrep)! Its allows you to search
|
||||
with normal `+default/search-project` then edit the results.
|
||||
|
||||
- \<SPC s p> to search the project
|
||||
- type search ex: "remote_url"
|
||||
- \<C-c C-o> to open the results
|
||||
- delete some results with \<d>
|
||||
- \<C-c C-p> to make the results editable
|
||||
- make edits example :%s/remote_url/webm_url/g
|
||||
- \<Z Z> to save changes across all the files
|
||||
- lastly review changes via git
|
||||
|
||||
{{< video-with-caption
|
||||
webm_url="https://travisshears.com/image-service/videos/emacs-replace-across-multiple-files/emacs_mass_edit_small.webm"
|
||||
mp4_url="https://travisshears.com/image-service/videos/emacs-replace-across-multiple-files/emacs_mass_edit_small.mp4"
|
||||
>}}
|
||||
|
||||
final patch: https://git.sr.ht/~travisshears/travisshears.com/commit/71e9c89c32f9b9f362e8e94ca8530530c1418284
|
||||
|
||||
---
|
||||
|
||||
In the making of this snippet I had some other fun:
|
||||
|
||||
- this screen recording led me to finding
|
||||
[keycastr](https://github.com/keycastr/keycastr).
|
||||
A very helpful mac osx program that displays keys as you type them.
|
||||
Great for tutorials.
|
||||
- My personal site is not open source because I write lot of drafts that don't
|
||||
get published for months... For this snippet I wanted to show part of that
|
||||
source code as a patch, decided on hosting it as a sourcehut paste. To create
|
||||
the paste I wrote a [sourcehut-paste](https://git.sr.ht/~travisshears/sourcehut-paste).
|
||||
- Video was created with Quicktime screen recording feature plus my video
|
||||
helper app, [ts-video](https://git.sr.ht/~travisshears/ts-video)
|
||||
Loading…
Add table
Add a link
Reference in a new issue