Sublime text 2 - find and replace globally ( all files and in all directories )

91,297

Solution 1

Yes, there is Multiple Files search and replace.

Press ctrlshiftF (cmdshiftF on MacOS):

enter image description here

In the Where field you can also add filters to search only folders and files that you need. If nothing is set, the search is made on all files listed in the sidebar.

If you double click on a line of the search result, Sublime will jump to that line.

Notice these icons in the search bar:

enter image description here

The first (show context) toggles context in result format (if enabled, some lines of text are shown before and after the matching line). The second allows to show the result in a new buffer, or in a console.

Solution 2

Press ctrlshiftF (cmdshiftF on  Mac OS X :) and then put *.* in the where: field

This will open the search up to all files in the project as opposed to only open files or folders.

You can also use this to search only files of a certain type, or with a certain name regardless of type. It's just wildcards for the filename and extension.

Share:
91,297
itsme
Author by

itsme

JS

Updated on December 18, 2020

Comments

  • itsme
    itsme over 3 years

    Is there any way to find and replace text string automatically in all folder's files?

  • George Shaw
    George Shaw over 11 years
    Is there a way to control which of the found cases in "Find in Files" get replaced? The Replace button does Replace_All.
  • Riccardo Marotti
    Riccardo Marotti over 11 years
    I think that the only way is to use multiple files search to get the files you need to modify and then use normal search and replace (cmd+alt+F), file by file.
  • Ivan Castellanos
    Ivan Castellanos about 11 years
    I don't pretend to know more than the creator of ST himself but you could just close the files (middle mouse click or ctrl+w) where you don't need the changes done and then click replace. Afterwards you can use Ctrl+Shift+t to reopen the closed files. You could also "add a exclude filter" clicking the button in the middle (the ellipsis) and write down the files where you don't want replacements.
  • jeffbyrnes
    jeffbyrnes almost 11 years
    If you put <project> in the "Where" field, it'll search recursively through all of the folders and files in the currently open project. You can also type in a relative path (e.g., search/for/things/here/ and it will only search through that folder, recursively, relative to your project's root. Very handy.
  • reflexiv
    reflexiv almost 11 years
    For this where field to come up by default with search and replace (ctrl+H) I added this to my user keybindings: { "keys": ["ctrl+h"], "command": "show_panel", "args": {"panel": "find_in_files"} }
  • sam
    sam over 10 years
    Is there a way to use this whilst ignoring the word your searching for if its in a comment ?
  • Littlee
    Littlee over 7 years
    @RiccardoMarotti Hi~, when in sublime text 3, cmd + shift + F only show FInd: and Where:, without Replace: ,what do I do ?
  • granadaCoder
    granadaCoder over 2 years
    Is this a Menu item? While I ultimately use the short-cut, I look at the Menu item to figure out what the short cut keys are. All I see in my Build "4107" is the basic Replace.