Remove empty lines from a fileHow to move multiple IPs to different lines

How to communicate to my GM that not being allowed to use stealth isn't fun for me?

Why was this person allowed to become Grand Maester?

Extreme flexible working hours: how to get to know people and activities?

Russian word for a male zebra

Who enforces MPAA rating adherence?

60s or 70s novel about Empire of Man making 1st contact with 1st discovered alien race

Are there any important biographies of nobodies?

How to hide rifle during medieval town entrance inspection?

Who won a Game of Bar Dice?

Why can my keyboard only digest 6 keypresses at a time?

Why are trash cans referred to as "zafacón" in Puerto Rico?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Does the 2019 UA Artificer's Many-Handed Pouch infusion enable unlimited infinite-range cross-planar communication?

Live action TV show where High school Kids go into the virtual world and have to clear levels

Align equations within one column

Is an entry level DSLR going to shoot nice portrait pictures?

Determining fair price for profitable mobile app business

Fixing obscure 8080 emulator bug?

Why does logistic function use e rather than 2?

New pedal fell off maybe 50 miles after installation. Should I replace the entire crank, just the arm, or repair the thread?

LuaLaTex - how to use number, computed later in the document

You have (3^2 + 2^3 + 2^2) Guesses Left. Figure out the Last one

sed + add word before string only if not exists

Why does the Mishnah use the terms poor person and homeowner when discussing carrying on Shabbat?



Remove empty lines from a file


How to move multiple IPs to different lines













2















I'm able to find empty lines with /^$, but when I go to remove them using :%s/^$//, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads XX substitutions on XX lines where XX is the number of empty lines in the file.



Questions:



  1. What substitutions are being made, as indicated by the status line?

  2. How do I accomplish what I want to do (eliminate empty lines from a file)?









share|improve this question






















  • One answer to #2 is :g/^$/d

    – chb
    Jun 1 at 1:46











  • A solution would be to replace an actual character: :%s/^n// but that depends on file format.

    – aragaer
    Jun 1 at 10:26















2















I'm able to find empty lines with /^$, but when I go to remove them using :%s/^$//, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads XX substitutions on XX lines where XX is the number of empty lines in the file.



Questions:



  1. What substitutions are being made, as indicated by the status line?

  2. How do I accomplish what I want to do (eliminate empty lines from a file)?









share|improve this question






















  • One answer to #2 is :g/^$/d

    – chb
    Jun 1 at 1:46











  • A solution would be to replace an actual character: :%s/^n// but that depends on file format.

    – aragaer
    Jun 1 at 10:26













2












2








2








I'm able to find empty lines with /^$, but when I go to remove them using :%s/^$//, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads XX substitutions on XX lines where XX is the number of empty lines in the file.



Questions:



  1. What substitutions are being made, as indicated by the status line?

  2. How do I accomplish what I want to do (eliminate empty lines from a file)?









share|improve this question














I'm able to find empty lines with /^$, but when I go to remove them using :%s/^$//, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads XX substitutions on XX lines where XX is the number of empty lines in the file.



Questions:



  1. What substitutions are being made, as indicated by the status line?

  2. How do I accomplish what I want to do (eliminate empty lines from a file)?






substitute






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 1 at 1:24









chbchb

1154




1154












  • One answer to #2 is :g/^$/d

    – chb
    Jun 1 at 1:46











  • A solution would be to replace an actual character: :%s/^n// but that depends on file format.

    – aragaer
    Jun 1 at 10:26

















  • One answer to #2 is :g/^$/d

    – chb
    Jun 1 at 1:46











  • A solution would be to replace an actual character: :%s/^n// but that depends on file format.

    – aragaer
    Jun 1 at 10:26
















One answer to #2 is :g/^$/d

– chb
Jun 1 at 1:46





One answer to #2 is :g/^$/d

– chb
Jun 1 at 1:46













A solution would be to replace an actual character: :%s/^n// but that depends on file format.

– aragaer
Jun 1 at 10:26





A solution would be to replace an actual character: :%s/^n// but that depends on file format.

– aragaer
Jun 1 at 10:26










1 Answer
1






active

oldest

votes


















8















  1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters

  2. To actually perform the substitution, the idioms are


:g/^$/d


and



:g/^$/j





share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "599"
    ;
    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%2fvi.stackexchange.com%2fquestions%2f20182%2fremove-empty-lines-from-a-file%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









    8















    1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters

    2. To actually perform the substitution, the idioms are


    :g/^$/d


    and



    :g/^$/j





    share|improve this answer





























      8















      1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters

      2. To actually perform the substitution, the idioms are


      :g/^$/d


      and



      :g/^$/j





      share|improve this answer



























        8












        8








        8








        1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters

        2. To actually perform the substitution, the idioms are


        :g/^$/d


        and



        :g/^$/j





        share|improve this answer
















        1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters

        2. To actually perform the substitution, the idioms are


        :g/^$/d


        and



        :g/^$/j






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 2 at 12:46

























        answered Jun 1 at 3:23









        D. Ben KnobleD. Ben Knoble

        3,0431521




        3,0431521



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Vi and Vim 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%2fvi.stackexchange.com%2fquestions%2f20182%2fremove-empty-lines-from-a-file%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

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form