refactor all usages in sigle file

I was looking for the possibility to change all occurences of an identifier in the same file (something like "highlight all usages" and then when you change one they all change at the same time). But I was unable to find it.
Is there such a thing? if not, what would be the accepted/default way of doing this? find/replace?

0
8 comments

Replace (Ctrl+R) should help when you replace string insige single file. Methods, classes, etc better rename with Refactor | Rename (Shift+F) (Shift+F6)


Message was edited by: Elena Shaverdova

0

Default hotkey for Refactor | Rename is Shift+F6, not Shift+F.

0

Thank you, Dmitriy! That was mistype.

0
Avatar
Permanently deleted user

The problem I am having with Replace is that it renames everything with that string (so my variable called 'contact' will be renamed, but also any occurance of the string contact), also, I need to make very tightfitting searches (to excluse for example contactBase).
The problem I have with Rename (refactor) is that it renames everything project wide. I want it to be just in the current file (sometimes I can just copy files from one module to the next and rename the files and some identifiers, doing this by hand is just inefficient).

So am I to understand that there is no way of doing this other than using Replace?

Edited: Changed 'Rename' to 'Replace'.

0

Renaming dialog has checkboxes "Search in comments and strings" and "Search for text occurences". Unselect them to rename only variable.

0
Avatar
Permanently deleted user

I cannot see those options? (See attached screenshot).

edit: Oh you mean refactor-rename? Yes, but that will still rename across all files, not just one.

edit2: I think the confusion is because I said 'Rename' where I mean 'Replace'.



Attachment(s):
Capture.PNG
0

Yes, I've meant Refactor | Rename. It renames all references to renamed variable, so, when copy-pasted code is visible to its source, you'll have to rename manually with Replace.

0
Avatar
Permanently deleted user

Evert,

I created an issue which affects described functionality, please vote - http://youtrack.jetbrains.net/issue/WI-7178

Thank you for feedback!

0

Please sign in to leave a comment.