• Login
Community
  • Login

Make an new empty line ever 7th line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
newlinemacrosearch & replace
9 Posts 3 Posters 1.2k 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.
  • A
    Adam Larsson
    last edited by Mar 20, 2021, 11:26 AM

    I’ve got a long list of dates, one on each line.
    now I want to add an empty line every 7th line (to add an empty line when I new week begins)

    I’ve tried to create a macro by recording, but it’s not working, neither does the npp manual site.

    any other ways to add a new line every 7th line?

    A 1 Reply Last reply Mar 20, 2021, 11:39 AM Reply Quote 0
    • A
      Alan Kilborn @Adam Larsson
      last edited by Mar 20, 2021, 11:39 AM

      @Adam-Larsson

      Any particular reason you posted the same thing TWICE?

      Please don’t do that.

      A 1 Reply Last reply Mar 20, 2021, 11:40 AM Reply Quote 0
      • A
        Adam Larsson @Alan Kilborn
        last edited by Adam Larsson Mar 20, 2021, 11:41 AM Mar 20, 2021, 11:40 AM

        @Alan-Kilborn Yeah, I pressed reload on my phone by mistake, wasn’t suppose to post it twice…

        I’ve corrected it.

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by guy038 Mar 20, 2021, 12:08 PM Mar 20, 2021, 11:41 AM

          Hello, @adam-larsson and All,

          A general regex S/R, to add a blank line, every 7 lines of a list, could be used !

          • Open the Replace dialog ( Ctrl + H )

          • SEARCH ^(.+\R){7}\K

          • REPLACE \r\n    OR    \n ( if you use UNIX files )

          • Select the Regular expression search mode

          • Click on the Replace All button ( Do NOT use the Replace button )

          Et voilà !

          Best Regards,

          guy038

          A A 2 Replies Last reply Mar 20, 2021, 11:43 AM Reply Quote 1
          • A
            Adam Larsson @guy038
            last edited by Mar 20, 2021, 11:43 AM

            @guy038 said in Make an new empty line ever 7th line:

            ^(.+\R){7}\K

            It’s this every 7th line from the beginning of the document or current cursor position?

            A 1 Reply Last reply Mar 20, 2021, 11:44 AM Reply Quote 0
            • A
              Alan Kilborn @Adam Larsson
              last edited by Mar 20, 2021, 11:44 AM

              @Adam-Larsson said in Make an new empty line ever 7th line:

              It’s this every 7th line from the beginning of the document or current cursor position?

              Current caret position.
              Tick Wrap around for beginning-of-doc origination.

              A 1 Reply Last reply Mar 20, 2021, 11:46 AM Reply Quote 1
              • A
                Alan Kilborn @guy038
                last edited by Mar 20, 2021, 11:46 AM

                @guy038

                Because the use of \K (usually) eliminates the possibility to do single, step-by-step replaces, wouldn’t it be better to specify such regexes without using \K, especially for newbies, that probably like the confidence of a single-step replace?

                Maybe not totally applicable in this case, though.

                But, I would write it without the \K.

                1 Reply Last reply Reply Quote 0
                • A
                  Adam Larsson @Alan Kilborn
                  last edited by Adam Larsson Mar 20, 2021, 11:47 AM Mar 20, 2021, 11:46 AM

                  @Alan-Kilborn Works Perfectly, thx a lot!
                  just pressed replace all…

                  1 Reply Last reply Reply Quote 0
                  • G
                    guy038
                    last edited by guy038 Mar 20, 2021, 11:56 AM Mar 20, 2021, 11:53 AM

                    Hi, @adam-larsson, @alan-kilborn, and All,

                    @adam-larsson :

                    • If you do not tick the Wrap around option, it adds a blank line, every block of 7 non-empty lines from caret location till the very end of file

                    • If you tick the Wrap around option, it adds a blank line, every block of 7 non-empty lines, from beginning of file till the very end of file

                    Alan, I understand your restriction regarding the \K feature. Luckily, thanks to @Uhf7, it will be possible to use, very soon, in a next release, the \K feature with the step by step replacement. Nice, isn’t it ?!

                    BR

                    guy038

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