Is it me or there is no “replace in files” in the editor?
Nope, I don’t think there is!
My favorite substitute for this is:
- Highlight the text you wish to change throughout a file.
- Press CTRL + D repeatedly (best feature to ever be implemented in any software ever).
- Type your new text!
Yes, thanks! I already use that! One of my best friends!
But I am looking for “replace in files”. I have to change a string in ALL files of the projects with a certain extension.
Perhaps you want to avoid external software for this, but I keep Notepad++ solely for how much I like the replace in files functionality.
Similarly, I use Sublime Text for this. Poor Sublime Text.
Thanks!
I have used “sed” via command line. I don’t understand very well this kind of magic, but it worked!
You could open the project in vscode, find all and replace all, but you should do it with your own risk, because it is treating it as plain text.
Easy. Look at this sample with two files (will work with any numbers of files, of course):
/tmp$ for i in *.lua; do echo "$i";cat "$i";echo "****";done
titi.lua
print "it's still me"
****
toto.lua
print "It's me"
****
Now you want to replace me by you :
/tmp$ sed -i 's/me/you/' *.lua
The -i parameter of sed
means « replaces in place » (directly in the file).
The files have to be in the same directory, but you can easily combine it with find
to find and modify in a complex tree file structure.
Result:
/tmp$ for i in *.lua; do echo "$i";cat "$i";echo "****";done
titi.lua
print "it's still you"
****
toto.lua
print "It's you"
****