Community
    • Login

    Request Feature Convert Case snake_case camelCase

    Scheduled Pinned Locked Moved General Discussion
    7 Posts 6 Posters 2.6k Views 1 Watching
    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 Offline
      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 Offline
        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 Online
          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 Offline
            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 Offline
              Fenimoreson Alvaro
              last edited by Fenimoreson Alvaro

              This post is deleted!
              Mark OlsonM 1 Reply Last reply Reply Quote -3
              • Mark OlsonM Offline
                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
                • Lyla WattsL Offline
                  Lyla Watts
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote -4

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors