Community
    • Login

    Add 'G1' to the start of each line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 19.8k 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.
    • Cnc BuilderC Offline
      Cnc Builder
      last edited by

      Sorry noob here… I am writing a G-Code program for my home made cnc. My thing is I need to add ‘G1’ to the start of each line and as I have over 12,000 lines I don’t want to do each line in turn…
      Is there a way to use find and replace to do this automatically?

      Any help would be great.

      1 Reply Last reply Reply Quote 0
      • guy038G Offline
        guy038
        last edited by guy038

        Hello, @cnc-builder

        Elementary task with regular expressions, indeed !!

        • Move back to the very beginning of the file to change ( Ctrl + Origin )

        • Open the Find/Replace dialog ( Ctrl + H )

        • Type ^, in the Find what: box

        • Type G1, in the Replace with: box

        • Choose the Regular expression search mode

        • Click on the Replace All button

        Et voilà !

        Notes :

        • The ^ character is the symbol, meaning “beginning of line”, in regular expressions

        • If you prefer to separate the string G1 from the rest of text, you may, either, add a space character after G1 or the symbol \t, for a tabulation character

        Best regards,

        guy038

        P.S. :

        For newby people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :

        http://docs.notepad-plus-plus.org/index.php/Regular_Expressions

        In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by Notepad++, since its 6.0 version, at the TWO addresses below :

        http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

        http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

        • The FIRST link explains the syntax, of regular expressions, in the SEARCH part

        • The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part


        You may, also, look for valuable informations, on the sites, below :

        http://www.regular-expressions.info

        http://www.rexegg.com

        http://perldoc.perl.org/perlre.html

        Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))

        1 Reply Last reply Reply Quote 0
        • Cnc BuilderC Offline
          Cnc Builder
          last edited by

          Many thanks did just what I needed great help :)

          1 Reply Last reply Reply Quote 0

          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