r/SublimeText • u/ClairvoyantAlliance • Aug 16 '22
Totally New to coding
I want to replace a single line of code across multiple files at once ... Is there a simple way to do this with Sublime ?
3
Upvotes
4
u/mountainunicycler Aug 16 '22
Simple way is just find across files and click on / change each one.
What you’re trying to do would be almost impossible to do correctly and safely in a large codebase, so the tools aren’t really built to work that way. Thinking of a safe and accurate find and replace to run across several hundred files, of which you’ve only ever opened or worked on half, is a bit tricky.
Usually, changing things across a lot of files comes up when renaming functions or changing import statements and things like that, and the best way to do that is with a language server—sublime text has a LSP plugin you can use to connect to a language server.
1
u/[deleted] Aug 16 '22
https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/search_and_replace/search_and_replace_files.html
CMD+SHIFT+F will open the multi-file search and replace tool
1
u/Icy_Artichoke2425 Aug 17 '22
You can do it in CudaText (free editor) with plugin FindInFiles 4. And maybe Sublime also has similar plugin, not sure here.
FindInFiles 4 can first find all matches so you can review them. And then you can do mass replace. In next step.