-
Notifications
You must be signed in to change notification settings - Fork 219
Find and replace with preserve case #165
Comments
Adding a comment from a related issue:
|
Wow that seems really complicated and hard to reason about. Especially
|
👍 @benogle I don't personally need that edge case. I just want the very common case of accomplishing both |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Emacs also has this behaviour, by default, and it's profoundly useful. http://www.gnu.org/software/emacs/manual/html_node/emacs/Replacement-and-Case.html |
+1 very useful intelliJ feature. I miss. Here is the use case, it is not, imnsho, an "edge" case considering we frequently, for multiple languages, mix the case to indicate something is a class or a var. I want to replace 'collection' below with 'model' without doing 2 f&r: ###
Collection component provides a collection context to all children
###
class x.Collection extends React.Component
displayName: "widgets.react.Collection"
@propTypes:
collection: React.PropTypes.oneOfType([
React.PropTypes.instanceOf(Backbone.Collection)
React.PropTypes.func
]).isRequired
fetch: React.PropTypes.bool
fetchOptions: React.PropTypes.object |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
+1 - I still have to open Sublime to do this kind of replace. |
This issue was opened almost 2 years ago, it would be great to have it implemented. I too would find it very useful, since in my Angular projects I often need to duplicate existing modules and then rename their name to something else. This affects not only the module name, but also the controller name, template name, etc. And these could all be in different cases, for example camelCase, PascalCase, or lowercase. Currently, this requires three find & replace operations to accomplish in this sample code (for /**
* Module definition and dependencies
*/
angular.module('Shared.PickTime.Modal', [])
/**
* Config
*/
.config(function($modalProvider) {
//Modal definition
$modalProvider.modal('pickTime', {
templateUrl: 'shared/modals/picktime.html',
controller: 'ModalPickTimeCtrl'
});
}); If there'd be a toggle to trigger case-aware replacement, that would save a lot of time. Bonus points if support for snake_case or kebab-case (dasherized) strings can also be added. That would probably involve detection of what case the search term and replacement term are in (and I think both should match, e.g. won't work if you try to find "FooBar" and replace it with "bar-foo" with this option turned on -- you can use regular replace for that). Then, if doing a find & replace with the toggle turned on, all other case variants could be generated from the search term and found & replaced by the equivalently cased replacement term. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
An Atom port of Sublime's MultiEditUtils would be awesome! |
This comment has been minimized.
This comment has been minimized.
Please try my new package https://atom.io/packages/case-keep-replace ;) |
@itlamb Didn't work for me unfortunately. First test I tried was to replace $scope.amountOwing = user.getMoneyOwing(); After pressing replace button it just wouldn't do anything. No message, no result, no replacements :( |
Hey @adambuczynski, could you check if there is any massage in Developer Tools / Console? But if you enter |
@itlamb ah right sorry, my example didn't make sense. |
It would be nice there'd also be a way to handle dashes and underscores properly as a part of this issue, e.g. snake case and dasherized strings. This is because usually when refactoring code one would need to refactor several different common formats of essentially the same string, e.g.:
|
This comment has been minimized.
This comment has been minimized.
@itlamb @adambuczynski Can you please move the conversation about another package to that packages repository. Thanks. |
@Ben3eeE my last comment was specific to this issue, sorry if this wasn't clear.
|
This comment has been minimized.
This comment has been minimized.
3 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for everyone's help and suggestions. Unfortunately, upon further review this isn't something that we want to maintain long-term. We do think that it would be very useful as a community package however. Thanks again for everyone's input. |
I would like to give my suggestion here. Whenever user tries to replace a word, then we just need to find whether all are in same case or different. If not different, then we can replace normally. else we can show them suggestions as set |
@lee-dohm is there a link available to aforementioned review? |
Add preserve case option for buffer replace. References #165.
When you search for abc (case insensitive) and want to replace it with xyz, it should match on Abc and replace it with Xyz. This is a feature that I found useful in sublime.
The text was updated successfully, but these errors were encountered: