Question

I want to do multiple select and edit within a specified selection in Sublime Text 2. The following screenshot illustrates the situation:

enter image description here

When I select "element" and press Alt + F3 (in Windows) I can simultaneously edit all instances of element. However what I would like to do is to be able to edit all instances of element only within container-a while leaving element within container-b untouched. I tried first selecting a specific area but then as soon as I attempt to select "element" my first selection disappears.

Is this possible to achieve in Sublime Text 2?

Was it helpful?

Solution

You can simply use the Find in Selection option in the Find panel. Select the text that you want to search in:

selection

then hit CtrlF to open the Find panel. Type in the text you want to find (such as element), then, in the group of buttons to the left of the text area, click the second button from the right - In Selection (highlighted in red):

Find In Selection

Finally, either hit AltEnter or click Find All to select all the instances of element in the selected area:

found

and you're good to go.

OTHER TIPS

Press Ctrl+D to select one more element and then one more again until you have selected all elements in container-a.

(Sorry my approach is very similar, but just a tiny thing to make it very slightly faster.)

Before you start, have the setting "auto_find_in_selection" to true, (This is probably only for SublimeText 3). This will have the "In Selection" button automatically done in most cases.

  1. (if you are already under the word) use Ctrl+E (command slurp_find_string). This causes the word to be used in find box.
  2. select the region you want (Ctrl+Shift+J should work nicely in your case)
  3. Hit Ctrl+F, you will find all settings are right ("In Selection" on, your word in box already)
  4. Just hit Alt+Enter and you are there.

For Mac, select what you want and then you can use --> cmd+ctrl+g

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top