How do I delete all blank lines in a buffer?how do I quickly remove lines from emacs bufferHow to use flush-lines in a script?make `delete-duplicate-lines` ignore blank lines and certain wordsHow to delete word in next line with evil-mode?Make evil-mode more lisp friendly?Yanking line copies past kill-ring lines along with currentHow to add a suffix to every line of a text?Can I “insert” a backspace character into a buffer?Why I can't delete first line after save *occur* buffer to separate file?How to swap strings in all lines?Why after save *Occur* buffer I can't edit editable file?How keep only duplicate lines?

What to do when eye contact makes your subordinate uncomfortable?

Recommended PCB layout understanding - ADM2572 datasheet

Does IPv6 have similar concept of network mask?

putting logo on same line but after title, latex

When were female captains banned from Starfleet?

What is Cash Advance APR?

How to say when an application is taking the half of your screen on a computer

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

User Story breakdown - Technical Task + User Feature

Can I still be respawned if I die by falling off the map?

Strong empirical falsification of quantum mechanics based on vacuum energy density?

What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?

How do I delete all blank lines in a buffer?

Has any country ever had 2 former presidents in jail simultaneously?

Using substitution ciphers to generate new alphabets in a novel

Mimic lecturing on blackboard, facing audience

What is going on with 'gets(stdin)' on the site coderbyte?

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Calculate sum of polynomial roots

Temporarily disable WLAN internet access for children, but allow it for adults

Does the UK parliament need to pass secondary legislation to accept the Article 50 extension

The IT department bottlenecks progress, how should I handle this?

Bridge building with irregular planks

Why is it that I can sometimes guess the next note?



How do I delete all blank lines in a buffer?


how do I quickly remove lines from emacs bufferHow to use flush-lines in a script?make `delete-duplicate-lines` ignore blank lines and certain wordsHow to delete word in next line with evil-mode?Make evil-mode more lisp friendly?Yanking line copies past kill-ring lines along with currentHow to add a suffix to every line of a text?Can I “insert” a backspace character into a buffer?Why I can't delete first line after save *occur* buffer to separate file?How to swap strings in all lines?Why after save *Occur* buffer I can't edit editable file?How keep only duplicate lines?













4















Emacs 26.1



In buffer



1


2


3


4


I use command "delete-blank-lines". But it NOT delete ALL BLANK LINES. It's delete ONLY ONE BLANK LINE.



Why?



I need to delete ALL BLANK LINES.
The result must be like this:



1
2
3
4









share|improve this question



















  • 1





    Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

    – Willy Lee
    2 hours ago











  • What @WillyLee said.

    – Drew
    14 mins ago











  • Possible duplicate of how do I quickly remove lines from emacs buffer

    – Drew
    12 mins ago











  • See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

    – Drew
    12 mins ago
















4















Emacs 26.1



In buffer



1


2


3


4


I use command "delete-blank-lines". But it NOT delete ALL BLANK LINES. It's delete ONLY ONE BLANK LINE.



Why?



I need to delete ALL BLANK LINES.
The result must be like this:



1
2
3
4









share|improve this question



















  • 1





    Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

    – Willy Lee
    2 hours ago











  • What @WillyLee said.

    – Drew
    14 mins ago











  • Possible duplicate of how do I quickly remove lines from emacs buffer

    – Drew
    12 mins ago











  • See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

    – Drew
    12 mins ago














4












4








4


1






Emacs 26.1



In buffer



1


2


3


4


I use command "delete-blank-lines". But it NOT delete ALL BLANK LINES. It's delete ONLY ONE BLANK LINE.



Why?



I need to delete ALL BLANK LINES.
The result must be like this:



1
2
3
4









share|improve this question
















Emacs 26.1



In buffer



1


2


3


4


I use command "delete-blank-lines". But it NOT delete ALL BLANK LINES. It's delete ONLY ONE BLANK LINE.



Why?



I need to delete ALL BLANK LINES.
The result must be like this:



1
2
3
4






text-editing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Tyler

12.2k12354




12.2k12354










asked 3 hours ago









AlexeiAlexei

759212




759212







  • 1





    Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

    – Willy Lee
    2 hours ago











  • What @WillyLee said.

    – Drew
    14 mins ago











  • Possible duplicate of how do I quickly remove lines from emacs buffer

    – Drew
    12 mins ago











  • See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

    – Drew
    12 mins ago













  • 1





    Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

    – Willy Lee
    2 hours ago











  • What @WillyLee said.

    – Drew
    14 mins ago











  • Possible duplicate of how do I quickly remove lines from emacs buffer

    – Drew
    12 mins ago











  • See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

    – Drew
    12 mins ago








1




1





Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

– Willy Lee
2 hours ago





Are you saying you used delete-blank-lines once? If you look at the help for the function, it will tell you it deletes the surrounding blank lines, that is the blank lines around point, not all blank lines in the buffer.

– Willy Lee
2 hours ago













What @WillyLee said.

– Drew
14 mins ago





What @WillyLee said.

– Drew
14 mins ago













Possible duplicate of how do I quickly remove lines from emacs buffer

– Drew
12 mins ago





Possible duplicate of how do I quickly remove lines from emacs buffer

– Drew
12 mins ago













See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

– Drew
12 mins ago






See also: emacs.stackexchange.com/q/41636/105. The question has been asked more than once, expressed in different ways.

– Drew
12 mins ago











1 Answer
1






active

oldest

votes


















5














From MasteringEmacs.com By Mickey Petersen:




This is a frequent question so I figured I’d mention the solution here:



You want to remove all empty (blank) lines from a buffer. How do you do it? Well, it’s super easy.



Mark what you want to change (or use C-x h to mark the whole buffer) and run this:



M-x flush-lines RET ^$ RET



And you’re done. So what does that mean? Well, M-x flush-lines will flush (remove) lines that match a regular expression, and ^$ contain the meta-characters ^ for beginning of string and $ for end of string. Ergo, if the two meta-characters are next to eachother, it must be a blank line.



We can also generalize it further and remove lines that may have whitespace (only!) characters:



M-x flush-lines RET ^s-*$ RET



In this case s- is the syntax class (type C-h s to see your buffer’s syntax table) for whitespace characters. The * meta-character, in case you are not a regexp person, means zero or more of the preceding character.







share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "583"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f48526%2fhow-do-i-delete-all-blank-lines-in-a-buffer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    From MasteringEmacs.com By Mickey Petersen:




    This is a frequent question so I figured I’d mention the solution here:



    You want to remove all empty (blank) lines from a buffer. How do you do it? Well, it’s super easy.



    Mark what you want to change (or use C-x h to mark the whole buffer) and run this:



    M-x flush-lines RET ^$ RET



    And you’re done. So what does that mean? Well, M-x flush-lines will flush (remove) lines that match a regular expression, and ^$ contain the meta-characters ^ for beginning of string and $ for end of string. Ergo, if the two meta-characters are next to eachother, it must be a blank line.



    We can also generalize it further and remove lines that may have whitespace (only!) characters:



    M-x flush-lines RET ^s-*$ RET



    In this case s- is the syntax class (type C-h s to see your buffer’s syntax table) for whitespace characters. The * meta-character, in case you are not a regexp person, means zero or more of the preceding character.







    share|improve this answer



























      5














      From MasteringEmacs.com By Mickey Petersen:




      This is a frequent question so I figured I’d mention the solution here:



      You want to remove all empty (blank) lines from a buffer. How do you do it? Well, it’s super easy.



      Mark what you want to change (or use C-x h to mark the whole buffer) and run this:



      M-x flush-lines RET ^$ RET



      And you’re done. So what does that mean? Well, M-x flush-lines will flush (remove) lines that match a regular expression, and ^$ contain the meta-characters ^ for beginning of string and $ for end of string. Ergo, if the two meta-characters are next to eachother, it must be a blank line.



      We can also generalize it further and remove lines that may have whitespace (only!) characters:



      M-x flush-lines RET ^s-*$ RET



      In this case s- is the syntax class (type C-h s to see your buffer’s syntax table) for whitespace characters. The * meta-character, in case you are not a regexp person, means zero or more of the preceding character.







      share|improve this answer

























        5












        5








        5







        From MasteringEmacs.com By Mickey Petersen:




        This is a frequent question so I figured I’d mention the solution here:



        You want to remove all empty (blank) lines from a buffer. How do you do it? Well, it’s super easy.



        Mark what you want to change (or use C-x h to mark the whole buffer) and run this:



        M-x flush-lines RET ^$ RET



        And you’re done. So what does that mean? Well, M-x flush-lines will flush (remove) lines that match a regular expression, and ^$ contain the meta-characters ^ for beginning of string and $ for end of string. Ergo, if the two meta-characters are next to eachother, it must be a blank line.



        We can also generalize it further and remove lines that may have whitespace (only!) characters:



        M-x flush-lines RET ^s-*$ RET



        In this case s- is the syntax class (type C-h s to see your buffer’s syntax table) for whitespace characters. The * meta-character, in case you are not a regexp person, means zero or more of the preceding character.







        share|improve this answer













        From MasteringEmacs.com By Mickey Petersen:




        This is a frequent question so I figured I’d mention the solution here:



        You want to remove all empty (blank) lines from a buffer. How do you do it? Well, it’s super easy.



        Mark what you want to change (or use C-x h to mark the whole buffer) and run this:



        M-x flush-lines RET ^$ RET



        And you’re done. So what does that mean? Well, M-x flush-lines will flush (remove) lines that match a regular expression, and ^$ contain the meta-characters ^ for beginning of string and $ for end of string. Ergo, if the two meta-characters are next to eachother, it must be a blank line.



        We can also generalize it further and remove lines that may have whitespace (only!) characters:



        M-x flush-lines RET ^s-*$ RET



        In this case s- is the syntax class (type C-h s to see your buffer’s syntax table) for whitespace characters. The * meta-character, in case you are not a regexp person, means zero or more of the preceding character.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        manandearthmanandearth

        1,1851419




        1,1851419



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Emacs Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f48526%2fhow-do-i-delete-all-blank-lines-in-a-buffer%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

            Вунгтау (аеропорт) Загальні відомості | Див. також | Посилання | Навігаційне меню10°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.0833310°22′00″ пн. ш. 107°05′00″ сх. д. / 10.36667° пн. ш. 107.08333° сх. д. / 10.36667; 107.083337731608Vinh AirportVinh airport facelift improves serviceвиправивши або дописавши їївиправивши або дописавши їїр

            Тонконіг бульбистий Зміст Опис | Поширення | Екологія | Господарське значення | Примітки | Див. також | Література | Джерела | Посилання | Навігаційне меню1114601320038-241116202404kew-435458Poa bulbosaЭлектронный каталог сосудистых растений Азиатской России [Електронний каталог судинних рослин Азіатської Росії]Малышев Л. Л. Дикие родичи культурных растений. Poa bulbosa L. - Мятлик луковичный. [Малишев Л. Л. Дикі родичи культурних рослин. Poa bulbosa L. - Тонконіг бульбистий.]Мятлик (POA) Сем. Злаки (Мятликовые) [Тонконіг (POA) Род. Злаки (Тонконогові)]Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Description from Flora of China) [Poa bulbosa Linnaeus, Sp. Pl. 1: 70. 1753. 鳞茎早熟禾 lin jing zao shu he (Опис від Флора Китаю)]Poa bulbosa L. – lipnice cibulkatá / lipnica cibulkatáPoa bulbosa в базі даних Poa bulbosa на сайті Poa bulbosa в базі даних «Global Biodiversity Information Facility» (GBIF)Poa bulbosa в базі даних «Euro + Med PlantBase» — інформаційному ресурсі для Євро-середземноморського розмаїття рослинPoa bulbosa L. на сайті «Плантариум»