Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. removing blank / empty lines from editor ?

removing blank / empty lines from editor ?

Scheduled Pinned Locked Moved The Lounge
question
19 Posts 17 Posters 0 Views 1 Watching
  • 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.
  • M Maximilien

    notepad++

    CI/CD = Continuous Impediment/Continuous Despair

    D Offline
    D Offline
    David ONeil
    wrote on last edited by
    #6

    Specifically, for most files replace '\r\n' with nothing, and select 'Extended' in the options

    Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

    M N 2 Replies Last reply
    0
    • L Lost User

      OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

      pkfoxP Offline
      pkfoxP Offline
      pkfox
      wrote on last edited by
      #7

      Look at sed if you have a Linux box

      In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

      1 Reply Last reply
      0
      • D David ONeil

        Specifically, for most files replace '\r\n' with nothing, and select 'Extended' in the options

        Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

        M Offline
        M Offline
        Matt T Heffron
        wrote on last edited by
        #8

        No, that'll collapse everything to a single line! To remove blank lines, in Regular Expression mode replace \r\n(\r\n)+ with \r\n That assumes that the blank lines don't have any whitespace. If they might, then replace \r\n(\s*\r\n)+ with \r\n

        "Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton

        D D 2 Replies Last reply
        0
        • stefanmihaimogaS stefanmihaimoga

          Try https://codebeautify.org/remove-empty-lines[^]

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #9

          Nice. I copied about 4000 lines of code and copied it back to my .cpp file. I will try to see how my current messy " under construction " file looks now ,,, I would probably do "CodeBeautifier" when my code gets too messy... about hourly... just kidding Thanks

          K 1 Reply Last reply
          0
          • L Lost User

            Nice. I copied about 4000 lines of code and copied it back to my .cpp file. I will try to see how my current messy " under construction " file looks now ,,, I would probably do "CodeBeautifier" when my code gets too messy... about hourly... just kidding Thanks

            K Offline
            K Offline
            k5054
            wrote on last edited by
            #10

            If you're looking to reformat your code, you might want to take a look at [ClangFormat — Clang 18.0.0git documentation](https://clang.llvm.org/docs/ClangFormat.html) Depending on which IDE you're using, you may find that others have already created plug-ins for it. A quick google around suggests that Visual Studio and QtCreator both have instructions on how to integerate.

            "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

            1 Reply Last reply
            0
            • M Matt T Heffron

              No, that'll collapse everything to a single line! To remove blank lines, in Regular Expression mode replace \r\n(\r\n)+ with \r\n That assumes that the blank lines don't have any whitespace. If they might, then replace \r\n(\s*\r\n)+ with \r\n

              "Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton

              D Offline
              D Offline
              David ONeil
              wrote on last edited by
              #11

              Thanks! I was being brain dead. I have removed blank lines the way you showed before but dyslexia kicked in.

              Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

              1 Reply Last reply
              0
              • L Lost User

                OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

                P Offline
                P Offline
                pmauriks
                wrote on last edited by
                #12

                VIM or NeoVim can do this. [https://stackoverflow.com/questions/706076/vim-delete-blank-lines#706083\](https://stackoverflow.com/questions/706076/vim-delete-blank-lines#706083) When I first started with VI I hated it. The more I learn though, the better it is. It's my editor of choice now, but I confess I don't use it enough to keep all the goodness in my head, and I often need a few moments to get into the VIM headspace when I start.

                1 Reply Last reply
                0
                • D David ONeil

                  Specifically, for most files replace '\r\n' with nothing, and select 'Extended' in the options

                  Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                  N Offline
                  N Offline
                  Nelviticus
                  wrote on last edited by
                  #13

                  Or 'Edit' -> 'Line Operations' -> 'Remove Empty Lines'

                  Regards Nelviticus

                  1 Reply Last reply
                  0
                  • M Maximilien

                    notepad++

                    CI/CD = Continuous Impediment/Continuous Despair

                    T Offline
                    T Offline
                    tbim
                    wrote on last edited by
                    #14

                    Notepad++ -- Edit | Line Operations | Remove Empty Lines

                    Mike

                    1 Reply Last reply
                    0
                    • L Lost User

                      OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

                      B Offline
                      B Offline
                      BernardIE5317
                      wrote on last edited by
                      #15

                      ^\x0a|^\x0d|^[\s]+.$ seems to work . "Buyer Beware"

                      1 Reply Last reply
                      0
                      • L Lost User

                        OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

                        D Offline
                        D Offline
                        dannette
                        wrote on last edited by
                        #16

                        I have a little note for that for VS Code:

                        vscode: ^$\n (to remove empty lines)

                        And I don't believe it was with any particular extension.

                        1 Reply Last reply
                        0
                        • M Matt T Heffron

                          No, that'll collapse everything to a single line! To remove blank lines, in Regular Expression mode replace \r\n(\r\n)+ with \r\n That assumes that the blank lines don't have any whitespace. If they might, then replace \r\n(\s*\r\n)+ with \r\n

                          "Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton

                          D Offline
                          D Offline
                          dandy72
                          wrote on last edited by
                          #17

                          That's what I was thinking; you don't need a separate tool to remove blank lines; a regex search and replace ought to do it. My real question (to the OP) is, does he want the editor to keep the blank lines but just not show them, or really remove them altogether?

                          1 Reply Last reply
                          0
                          • L Lost User

                            OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

                            R Offline
                            R Offline
                            RipeTomato
                            wrote on last edited by
                            #18

                            how about Notepad++ Notepad++[^]

                            1 Reply Last reply
                            0
                            • L Lost User

                              OK. I asked before so this is a repost... (so sue me...) Is there a plain (text) editor which can remove empty lines ? It would be nice to add as "plug in" into my "development tool"... Thanks

                              R Offline
                              R Offline
                              Ralf Quint
                              wrote on last edited by
                              #19

                              Don't know (and IDC) about plugin into any development system, but for years, I am using PsPad as my go-to plain text editor on Windows, and it has a function to remove blanks lines (and many other options)...

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups