Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support replacements with case-changes (contains JS-code that implements this) #11

Open
RieksJ opened this issue Oct 22, 2020 · 1 comment

Comments

@RieksJ
Copy link

RieksJ commented Oct 22, 2020

@angelo-mollame: A few months ago, the replace functionality of VSCode has been enhanced to support replacements with case change. This allows you to change the case of texts you search. Examples are here.

It would be nice if this feature were supported in batch-replacer as well.
Consider the following input strings

    "This is a STRING"
    "here is Another String"

Here is some commands and the associated outputs:
Modifier \L changes the next element in all lowercase (using \U would change it in all uppercase)

replace-regex ""([^"]+)""
with "\L$1"

OUTPUT:
    "this is a string"
    "here is another string"

Modifier \l changes only the first character of the next element to lowercase (analogously, \u does that to uppercase)

replace-regex ""([^"]+)""
with "\l$1"

OUTPUT:
    "this is a STRING"
    "here is Another String"

Can this be done?

@RieksJ
Copy link
Author

RieksJ commented Oct 23, 2020

As an alternative, we can introduce a way that does not replace text with some other text, but simply converts the case, by by using with-case instead of with. You can convert text to UPPERCASE:

// Input:
//     We use Keywords 'must' and 'should' as in RFC 2119
// Output
//     We use Keywords 'MUST' and 'SHOULD' as in RFC 2119
replace-regex "'[^']*?'"
with-case "uppercase"

or to lowercase:

// Input:
//     We use Keywords 'MUST' and 'SHOULD' as in RFC 2119
// Output
//     We use Keywords 'must' and 'should' as in rfc 2119
replace-regex "'[^']*?'"
with-case "lowercase"

I was able to have the JavaScript files of the extension itself modified, which should help someone that can do TypeScript to get it into the VSCode extension officially: case-conversion-hack.zip.

@RieksJ RieksJ changed the title Feature request: support replacements with case change Feature request: support replacements with case-changes Oct 23, 2020
@RieksJ RieksJ changed the title Feature request: support replacements with case-changes Feature request: support replacements with case-changes (contains JS-code that implements this) Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant