Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does Sublime Text 2 allow the user to perform find-and-replace, limited to the current selection?

I should think it must, only I've been unable after multiple searches to find how to carry it out.

share|improve this question
add comment

5 Answers

up vote 5 down vote accepted

There is a button for that in ST2.

Screenshot

share|improve this answer
1  
True, there is a button. But how do you use it? In particular, how do you set "the selection"? From my experience ST2 uses the selection from the time when you opened the search bar. So if the bar is open already you have to close it first (Esc), then select the range of text you want to examine and then open it again (Ctrl+F or Ctrl+H). Pro tip: If the selection spans multiple lines it won't replace your current search expression. –  Robert Apr 23 '13 at 18:28
1  
Cmd+Opt+F on mac to open the find & replace console. –  Micah May 31 '13 at 16:37
add comment

Just select the text you want to search, then click Replace from the find menu. It will automatically do it within your selection.

share|improve this answer
add comment

(with Mac OS X specific shortcuts) to replace some name with new name:

  1. place the cursor above the text
  2. Find some name: cmdf, type some name (sometimes need to press return)
  3. Specify replace: shiftcmdr, tabtab to get to replace field, type new name, don't press return
  4. repeat altcmde until done.
share|improve this answer
    
Does anyone know a faster way of doing this?! It's pretty ridiculous and unnecessarily hard to remember –  AJP Sep 9 '12 at 0:37
    
see @oliver-g 's answer - ST2 does so by default, and if you have disabled it, just click ctrl+H and left to "Find What:" there's a button titeled "In selection" –  Peter Sep 30 '12 at 11:30
add comment

If your selection includes a line break, the "within selection" button will be automatically activated - on ST2

The smart activation has been lost on ST3, unfortunately. You can follow up on that here http://www.sublimetext.com/forum/viewtopic.php?f=3&t=11679

share|improve this answer
1  
It's now possible to bring back this functionality by using: "auto_find_in_selection": true –  mdrozdziel Sep 24 '13 at 7:27
add comment

the key to work with replace within selection is to FIRST select the text then go to find > replace then fill in text for what your are gonna find & replace, then check the button tooltipped "in selection" then click on "Replace All"...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.