Community
    • Login

    How to save without comments?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.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.
    • Andrew TommyA
      Andrew Tommy
      last edited by

      Hi all!
      After doing a user language highlighting i would need an option to save the file WITHOUT comments i added.

      Is is possible to add this option?
      I tried to create a macro, but it didn’t recognize the comments (they are written between #, e.g. #this is a comment#).
      Thanks in advance,

      Andrew

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Andrew Tommy
        last edited by Scott Sumner

        @Andrew-Tommy

        It is certainly easy enough to get rid of your comments, but it seems as if you’d want to end up with TWO versions of your file–one with comments (your worked hard to put the comments in, why not retain them!), and one without comments. Thus it might be wise to do a “Save A Copy As…” or “Save As…” and then remove the comments from the copy.

        As to removing the comments, a simple regular expression Replace-All operation should suffice:

        Find-what box: (?s)#.+?#
        Replace-with box: make sure this box is empty!
        Search mode: Regular expression

        You didn’t say if your comments could span lines or not, so the regular expression allows this (the (?s) part). Otherwise, the expression looks for a # character, followed by one or more characters (the .+? part), followed by another #. It replaces any matches with nothing effectively deleting the comment.

        You could record the Replace-All part as a macro, certainly. However, if you like the save-a-copy part, that doesn’t lend itself to macro-izing too well.

        If this (or ANY) posting was useful, don’t post a “thanks”, just upvote ( click the ^ in the ^ 0 v area on the right ).

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