Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Make an new empty line ever 7th line

    Help wanted · · · – – – · · ·
    newline macro failed search replace
    3
    9
    54
    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.
    • Adam Larsson
      Adam Larsson last edited by

      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?

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Adam Larsson last edited by

        @Adam-Larsson

        Any particular reason you posted the same thing TWICE?

        Please don’t do that.

        Adam Larsson 1 Reply Last reply Reply Quote 0
        • Adam Larsson
          Adam Larsson @Alan Kilborn last edited by Adam Larsson

          @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
          • guy038
            guy038 last edited by guy038

            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

            Adam Larsson Alan Kilborn 2 Replies Last reply Reply Quote 1
            • Adam Larsson
              Adam Larsson @guy038 last edited by

              @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?

              Alan Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                Alan Kilborn @Adam Larsson last edited by

                @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.

                Adam Larsson 1 Reply Last reply Reply Quote 1
                • Alan Kilborn
                  Alan Kilborn @guy038 last edited by

                  @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
                  • Adam Larsson
                    Adam Larsson @Alan Kilborn last edited by Adam Larsson

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

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

                      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
                      • First post
                        Last post
                      Copyright © 2014 NodeBB Forums | Contributors