MartinDuo
MartinDuo

Reputation: 743

Why is VS Code adding many blank lines at the end of all my files?

I just installed Win 10 1809 on my Dell PC, and it seems to run okay. But the first thing I did was start up VS Code. I wanted to run yarn start for my React project, but I had to type it way down in the terminal window, while the prompt was at the top. It worked though.

And when I open any project file, there seems to be approximately 100 blank lines appended at the end of each. But the line numbers don't go down that far and the cursor stops at the last line number. But the scroll bar acts as if those blank lines are there.

So I'm guessing the same number of blank lines are being added to the terminal too. But in the terminal window, the cursor is positioned at the bottom of the scrollable window.

What's going on? Is there a fix?

EDITED:

I see that I can scroll the file's window up until the cursor and last line is at the top, but no further, regardless of the window size. Maybe this has always be the case, and I never noticed. But now because of my terminal problem, I am suspicious of everything and checking for any abnormalities. So I don't think that extra blank lines are being added to my files. Sorry for the mistake.

But the terminal problem persists. The screen clip below shows the terminal display after I enter "yarn start". The typed input shows up way down from the initial prompt, and the blank area is a long string of "0D0A" characters. Sometimes I can click on "kill Terminal" and then start a new one and the new one works correctly. But not always.

TerminalScreenSnip

Still trying to figure this out.

Upvotes: 1

Views: 3987

Answers (3)

notes-jj
notes-jj

Reputation: 1547

Your Terminal Problem is described as Bug in VS Code Issues. As of July 2019 the intergration is pending due to stability problems.

Addendum (August 2019): The Problem seams to be fixed with VS Code 1.37.1 and Windows 10 Patchlevel 1903

Upvotes: 3

acekizzy
acekizzy

Reputation: 67

Did you try uninstalling and reinstalling?

Going back to your questions.

What's going on? No idea. Fix. Use this extension https://marketplace.visualstudio.com/items?itemName=rintoj.blank-line-organizer

or

  1. Open Visual Studio project and collapse all the folder and make it handy.
  2. Now press “ Control + Shift + H “ key combination and you can see the Popup which shows Find and Replace options.
  3. In the Find place input “^&\n” combination and select Use Regular Expression checkbox without fail as this input will mainly work with the regular expressions only.
  4. In the replace field leave it empty so nothing will be replaced rather remove the empty blank lines.
  5. In the input Find field we have give ^ for Start of the line and $ for end of line and \n which is for new line break.

source for second solution: http://www.f5debug.net/post/2015/01/03/How-to-remove-Blank-lines-between-codes-in-Visual-Studio-Code-editor.aspx

The extension will be useful overall especially when working in a team project where a lot of people might be leaving too many empty lines. Good luck

Upvotes: 0

Rom
Rom

Reputation: 1838

Can you share snapshots for your problems?

This is some hint for your problem

In VS Code, type

  • Linux / Windows: Ctrl + Shift + P

  • MacOS: Cmd + Shift + P

Type Settings to go Settings

enter image description here

At settings, search end of file, at here you can configure something for your problem with auto append blank lines each file

enter image description here

I hope it will help you :)

Upvotes: 4

Related Questions