Search and replace selectively across whole project in Sublime - sublimetext2

I need to change occurrences of a term only in certain places in my project.
Is there a way in Sublime Text to navigate the search results (across an entire project) and only replace the occurrences of my choice?
⌘ShiftF opens the "search and replace" for the entire project, but the Replace button only gives me the option to replace all occurrences.

If you press the ... button in the search panel, a menu will open that allows you to refine your search. You can use the Where input field with a search pattern, or some tags like <open-files>.
http://docs.sublimetext.info/en/latest/search_and_replace/search_and_replace_files.html
Other than that, if you really need human input to decide where to replace and where not to replace, you can go to the next result by pressing Enter and pasting the code manually.
Just in case you didn't know: when you make a project search a new text file opens up with all the occurrences. You can click those occurrences to navigate to the file in question.

For posterity, the functionality to search/find and replace inside the open project does exist. ⌘ShiftF and add <open project> to the Where input field.

Related

Deselect multiline selection to single last selection

Looking at the documentation
To go from multiple selections to a single selection, press Escape.
However, this always takes me to the first selection, I would like to go to the last selection, is there a plugin or command for this?
Install Sublime-MultiEditUtils and press shift+esc to jump to last region.

Option highlighting all strings matching actual selection in PhpStorm?

Is there an option highlighting all strings matching the actual selection in PhpStorm (like in SublimeText) ?
You can use Ctrl + Shift + F7 for this in PhpStorm.
This will highlight all usages of selected text.
Using built-in functionality: select text and hit Ctrl + F that will bring "Find in page" functionality: it will highlight all matches of selected text in this document. But it's not always convenient as you have to hit extra keys and have "find in page" bar open...
You can install and use BrowseWordAtCaret plugin that will automatically highlight word under caret in whole document (regardless of it's nature -- variable or just plain text) + you can easily navigate between all matches.
P.S.
You have mentioned that "I'm used to regularly change the name of an object property, an array key or a parameter name at multiple places in same document."
Consider using Refactor | Rename for variables/class members/etc -- it works across multiple files.

Shortcut to Paste & Cut selection at the same time in Sublime text?

I was wondering if there is a shortcut to Paste from the clipboard & at the same time cut the selection to be pasted somewhere else.
Elaborating the Question:
I find myself often swapping values among various sections of code. As a primitive example:
var a = "two";
var b = "one";
To swap them, I would:
cut the value of a
Paste it next to the value of b
cut the original value of b
paste that back as the value of a
I was wondering id there is a shortcut to combine step 2 & 3 of this process.
Sublime Text provides a tool for doing exactly(?) what you wish.
Double click "one" (to select it)
Hold ctrl and double click "two" (both are selected now)
press ctrl + t to swap selections
Otherwise you may wish to register a new key binding for your custom operation. You can do this via Preferences -> Key bindings (User).
Use Permute Selection > Reverse:
highlight two value
hold control
highlight one value
Edit > permute selection > reverse
Not exactly, but something is kinda there to help in such situations. There is a Clipboard History built-in Sublime Text (atleast in 3, not sure 2). Just copy the text you are replacing, then press <C-k><C-v>. This will popup a small window with clipboard's history. Select the previous copied text to replace currently selected text.
This option is available under Edit -> Paste from History.
HTH
You can do it too with a clipboard history https://github.com/colinta/SublimeClipboardManager
Copy: oneCopy: twoPaste-previous in twoPaste-next in one
The good thing is that clipboard history can be helpful in more situations

PHPStorm - Find and Replace Text in Selection?

In most other editors, I can select a portion of the text I want to run find and replace on and then hit the ctrl + h combination. A screen pops up asking me what to find and what to replace. How do I do this in PHPStorm?
If you are using the Default keymapping (you can also use the keymaps for Eclipse, Visual Studio, etc) press Ctrl+r to show the Replace Toolbar. If you already have a selection then the option In Selection will already be checked, otherwise you can check it and then do your selection (if you select first and check the option second it will unselect the text after checking the option).
The feature is called Replace in the Keymap configuration if you wish to change the shortcut.
You can also press Shift+F6 to directly rename variables if that's what you want to do.
Highlight the code selection you wish to work on
( you can use alt + arrow up if your looking for a cool way to do that)
Press Ctlr + r on PC or Command + r on a Mac
In the upper options window, insert the values you wish to replace
Select the "in selection" check box
Press Replace/Replace all button

sublime text- "list lines containing 'find' string

How do I list the lines that contains the matches from the "find" command ? ie., I would like to list all the matching lines in a separate window. Currently one can only goto next / previous 'find'.
Try 'Find in Files' (Cmd+Shift+F on a Mac, presumably Ctrl+Shift+F on a PC).
Search results will display in a new tab, and you can double-click any result to jump to that line in the matching file.
To search only open files, put <open files> in the Where field.
To show only the lines that matched without surrounding lines for context, toggle the 'Show Context' option (to the left of the 'Find All' panel).
1.Here is a reference: How can I filter a file for lines containing a string in Sublime Text 2?
Hit Ctrl+F(⌘+F) to "Find All" occurences;
Hit Ctrl+L to Expand All Selection to Line.
Then you can Ctrl+C(⌘+C) or Ctrl+Shift+K(⌃+⇧+K) to
copy/delete the lines.
2.There's now a plugin for filtering lines:
https://github.com/davidpeckham/FilterLines
It allows filtering and code folding based on strings or regular expressions.
I think the simplest way is just to search for the line like this -> ".*find_this_string.*" and make sure that regular expression is ticked. Then you can click "find all" (alt+enter) and just copy and paste all results to a new window.