Add dired replace tutorial

This commit is contained in:
Jose 2023-07-24 10:32:03 -03:00
parent f4d3f48653
commit 92cedfb7d9
2 changed files with 33 additions and 0 deletions

View file

@ -46,6 +46,7 @@ Emacs is free software project with many years of development and a very active
*** Working with files
* [[./doc/ido.org][Using 'ido' mode]]
* [[./doc/replace_text_mutiple_files.org][Replace text in multiple files using 'dired']]
*** Emacs org-mode

View file

@ -0,0 +1,32 @@
#+date: 2023-07-24
#+options: toc:nil num:nil author:nil
* Replace text in multiple files using dired
Sometimes you may need to replace words or sentences across multiple files.
That operation could be bore, since you will need to open, replace and close
multiple files.
Emacs has options to deal with that situation using ~dired~. Let's say you need
to replace the word "code language" in multiple files within a directory.
You may follow this steps:
- Open the directory using ~dired~:
- Use the keys[fn:1] ~C-x d~
- Mark all the files where you need to make the replacement
- You may press the key "m" over each name of the files
- Optionally press "t" to mark all files
- Then you may use ~M-x~ ~dired-do-find-and-replace~ [fn:2]
- After this you will present with multiple occurrences of the text
you will replace.
- You may replace all the occurrences using "!"
- You may also check every occurrence and use backspace to make a replacement
by each occurrence
* Footnotes
[fn:1] i.e., press "Control" and "x" keys, then, press "d" in the keyboard
[fn:2] i.e., press the key "Alt" and "x", then write the instruction. You may
press also the key "Q"