Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Login

    Request Feature Convert Case snake_case camelCase

    General Discussion
    5
    6
    98
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BernardB
      Bernard
      last edited by

      greetings kind regards
      am surprised snake and camel are not on the list of cases to convert to .
      thank you kindly

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @Bernard
        last edited by

        @Bernard
        This is pretty easy to do with regular expressions in the find/replace form:
        For both conversions, make sure the Search Mode of the find/replace form is set to Regular expressions.

        Camel to snake:

        FIND: (?-i)([a-z])([A-Z])
        REPLACE WITH: ${1}_\l${2}

        Snake to camel:

        FIND: (?-i)([a-z])_([a-z])
        REPLACE WITH: ${1}\u${2}
        example of snake case (should be converted to camel by my Snake to camel regex):

        _foo = __bar + now_is_the_time_for_all_good_men
        
        class foo_bar:
            def __init__(self, blah_man_zoo, _foo, baz_):
                self.blah_man_zoo = blah_man_zoo
                self._foo = _foo
                self.baz_ = baz_
        
            def __repr__(self):
                return self._foo + self.baz_
        
            def baz(_foo):
                return _foo
        

        example of camel case (should be converted to snake by my camel to snake regex):

        _foo = __bar + nowIsTheTimeForAllGoodMen
        
        class fooBar:
            def __init__(self, blahManZoo, _foo, baz_):
                self.blahManZoo = blahManZoo
                self._foo = _foo
                self.baz_ = baz_
        
            def __repr__(self):
                return self._foo + self.baz_
        
            def baz(_foo):
                return _foo
        
        1 Reply Last reply Reply Quote 4
        • guy038G
          guy038
          last edited by guy038

          Hello, @bernard, @mark-olson and All,

          @bernard, see also this old post :

          https://community.notepad-plus-plus.org/topic/130/convert-case-to/4


          Note that some of the capitalisation rules, presented in this post, are now directly accessible, from within N++, via the Edit > Convert Case To menu option. !

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 4
          • Alan KilbornA
            Alan Kilborn
            last edited by

            Possibly of related interest: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13306

            1 Reply Last reply Reply Quote 3
            • Fenimoreson AlvaroF
              Fenimoreson Alvaro
              last edited by Fenimoreson Alvaro

              It sounds like you’re requesting a feature that allows you to convert text between snake_case and camelCase. This can be a useful utility for developers and anyone working with code. While I can’t directly implement features, I can provide you with a simple Python code snippet that demonstrates how you can convert text between these two cases. You can use this as a starting point to create a dedicated tool or integrate it into your projects

              Mark OlsonM 1 Reply Last reply Reply Quote -3
              • Mark OlsonM
                Mark Olson @Fenimoreson Alvaro
                last edited by

                @Fenimoreson-Alvaro
                It sounds like you’re using generative AI to create responses to topics in the forum. That can be a useful utility for developers and anyone working with code. Unfortunately, use of generative AI to respond to posts on this forum is banned.

                If that’s not what’s happening, and your post just happened to have the style of a ChatGPT response, then I apologize.

                1 Reply Last reply Reply Quote 5
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors