Reputation: 52288
I've read this thread indicating how to find and replace within selection in ST2. Despite reading this thread but still cannot figure out if it's possible to do a simple find and replace within selection in ST3?
Upvotes: 11
Views: 16954
Reputation: 91
Select the word by pressing CMD+D it selects 1 from whole file and show transparent selection of all related word you can press more times CMD+D for selecting all word then edit it all words take places
Upvotes: 9
Reputation: 960
You can (using ctrl-h, then toggling the 'in selection' option from the dialog), but it's a bad design IMO. Firstly, if you have an area of text highlighted when you request 'replace', it should assume "replace in selection" automatically. Secondly, as soon as you choose 'replace' it thoughtfully cancels the text selection for you. The whole process ends up involving cumbersome repetition, or an illogical sequence of steps. Visual Studio gets the UI design right; Sublime does not.
Upvotes: 7
Reputation: 16075
show_panel
command by going to preferences -> keybindings, then adding this line to the user keybindings: { "keys": ["ctrl+shift+s"], "command": "show_panel", "args": { "panel": "replace", "in_selection": true } }
to ensure that the "in selection" mode is active and skip the next step. (see the forums for more available args.)If you want to change the selection you are searching within, you will need to close and re-open the panel.
If the region/selection you are searching within always contains multiple lines, you may want to consider setting the following preference for convenience:
// When auto_find_in_selection is enabled, the "Find in Selection" flag
// will be enabled automatically when multiple lines of text are selected
"auto_find_in_selection": true,
Upvotes: 22
Reputation: 22791
Searching and/or replacing within only a selected area in Sublime is indeed possible.
If you have text selected, once you open the Find
or Replace
panels, you can select the button for Find in Selection
(which is turned off by default unless you have the auto_find_in_selection
turned on and select multiple lines) to have the operation you carry out only apply to the selected area.
In this example I'm doing the following:
to
, showing how many of them there areFind and Replace
panel with Ctrl+Hto
with the word FROM
to
outside of the selection are still there untouched.Upvotes: 5
Reputation: 31
Select the line/word/code and Press Ctrl+d. Matched piece of text will be selected and will have cursor after them. You can edit them together.
Ctrl+h is the shortcut for 'Copy and Replace' in all versions of Sublime.
Upvotes: 3