• Login
Community
  • Login

Add 'G1' to the start of each line.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 16.8k Views
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.
  • C
    Cnc Builder
    last edited by Jul 1, 2017, 4:23 PM

    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
    • G
      guy038
      last edited by guy038 Jul 1, 2017, 5:25 PM Jul 1, 2017, 5:13 PM

      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
      • C
        Cnc Builder
        last edited by Jul 1, 2017, 6:02 PM

        Many thanks did just what I needed great help :)

        1 Reply Last reply Reply Quote 0
        2 out of 3
        • First post
          2/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors