Community
    • 登入

    Make an new empty line ever 7th line

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    newlinemacrosearch & replace
    9 貼文 3 Posters 1.5k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Adam LarssonA
      Adam Larsson
      最後由 編輯

      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 KilbornA 1 條回覆 最後回覆 回覆 引用 0
      • Alan KilbornA
        Alan Kilborn @Adam Larsson
        最後由 編輯

        @Adam-Larsson

        Any particular reason you posted the same thing TWICE?

        Please don’t do that.

        Adam LarssonA 1 條回覆 最後回覆 回覆 引用 0
        • Adam LarssonA
          Adam Larsson @Alan Kilborn
          最後由 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 條回覆 最後回覆 回覆 引用 0
          • guy038G
            guy038
            最後由 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 LarssonA Alan KilbornA 2 條回覆 最後回覆 回覆 引用 1
            • Adam LarssonA
              Adam Larsson @guy038
              最後由 編輯

              @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 KilbornA 1 條回覆 最後回覆 回覆 引用 0
              • Alan KilbornA
                Alan Kilborn @Adam Larsson
                最後由 編輯

                @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 LarssonA 1 條回覆 最後回覆 回覆 引用 1
                • Alan KilbornA
                  Alan Kilborn @guy038
                  最後由 編輯

                  @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 條回覆 最後回覆 回覆 引用 0
                  • Adam LarssonA
                    Adam Larsson @Alan Kilborn
                    最後由 Adam Larsson 編輯

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

                    1 條回覆 最後回覆 回覆 引用 0
                    • guy038G
                      guy038
                      最後由 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 條回覆 最後回覆 回覆 引用 3
                      • 第一個貼文
                        最後的貼文
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors