user16117431
user16117431

Reputation:

How to delete LAST blank lines and add one in the end of file?

I should follow python style guide. And i want to delete all blank lines in the end of file but one.

Upvotes: 0

Views: 115

Answers (1)

romainl
romainl

Reputation: 196566

  1. Move the cursor to last line:

    G
    
  2. Vim considers a series of blank lines as a "paragraph", which may seem odd but works in our favour, here, because we can change the current paragraph:

    cip
    

    and immediately go back to normal mode:

    <Esc>
    

Demo:

demo


But, as far as I can tell, PEP8, doesn't mandate that and I suspect that the last blank line you want to keep may be a misunderstanding.

Upvotes: 2

Related Questions