Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to insert a final newline #1666

Closed
sarbbottam opened this issue Dec 27, 2015 · 17 comments
Closed

Provide an option to insert a final newline #1666

sarbbottam opened this issue Dec 27, 2015 · 17 comments
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@sarbbottam
Copy link

Something similar to insert_final_newline = true.

@bpasero bpasero changed the title trim all the trailing empty line at the end of the file but one Provide an option to insert a final newline Dec 28, 2015
@bpasero bpasero added the feature-request Request for new features or functionality label Dec 28, 2015
@bpasero bpasero added this to the Backlog milestone Dec 28, 2015
@bpasero bpasero added the editor label Dec 28, 2015
@sarbbottam
Copy link
Author

If the file already has multiple empty lines at the end, it would be great to trim all but the last one.

@jhasse
Copy link
Contributor

jhasse commented Apr 28, 2016

This extension implements this: https://marketplace.visualstudio.com/items?itemName=samverschueren.final-newline

I still think this should be available in VS Code itself and enabled by default :)

@sarbbottam
Copy link
Author

editorconfig-vscode addressed my concern.

@jhasse
Copy link
Contributor

jhasse commented Apr 29, 2016

@sarbbottam Don't you think that this essential feature should be part of the core?

@sarbbottam
Copy link
Author

It would be good to have it as part of the core.

On Fri, Apr 29, 2016, 2:59 AM Jan Niklas Hasse notifications@github.com
wrote:

@sarbbottam https://github.com/sarbbottam Don't you think that this
essential feature should be part of the core?


You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
#1666 (comment)

@jhasse
Copy link
Contributor

jhasse commented Apr 29, 2016

Can you reopen this issue to keep track of it? Thanks :)

@sarbbottam sarbbottam reopened this Apr 29, 2016
@bpasero bpasero self-assigned this Nov 2, 2016
@bpasero bpasero modified the milestones: November 2016, Backlog Nov 2, 2016
@bpasero bpasero closed this as completed in f9cbe20 Nov 4, 2016
bpasero added a commit that referenced this issue Nov 4, 2016
Provide an option to insert a final newline (fixes #1666)
@bpasero
Copy link
Member

bpasero commented Nov 4, 2016

Added files.insertFinalNewline for November.

@sarbbottam
Copy link
Author

Thanks!

@concatime
Copy link
Contributor

Hi.
Is it possible to automatically replace all empty lines at end with only one?

@ronak1009
Copy link

with the extension blank line is not working. The code seems to undergo infinite loop where the new line adds and gets removed automatically, and I cannot save the file.

Also with the insert_final_newline: true option in the settings, the js files does not have a blank line at the end of the file.
I am using VSC 1.11.2 Date: 2017-04-13 release.

@ronak1009
Copy link

"files.insertFinalNewline" = true
@bpasero I added this parameter to the user settings and workspace settings, but it is still not working onVSC 1.12.1 version. Do I need to add some more configuration done? I am not using any plugin for this. If I add plugin, then it go into infinite loop as I reported in my previous comment

@stern-shawn
Copy link

"files.insertFinalNewline" = true

Hey @ronak1009 ! If you'll take another look, notice that your VSCode preferences are in a file named settings.json, so you'll need to set that value to true using JSON syntax with a colon instead of an equals sign, like this:

"files.insertFinalNewline": true

Verified that this is working in my copy of VSCode 1.12.1 which matches yours 👍

@gris-martin
Copy link

gris-martin commented May 13, 2017

EDIT: Found the culprit. It was the JS-CSS-HTML Formatter that overrode the setting.

I'm not able to get this setting working either, on Ubuntu 1.12.1. My user settings look like this:

// Place your settings in this file to overwrite the default settings
{
    "files.insertFinalNewline": true,
    "editor.formatOnPaste": true,
    "editor.renderWhitespace": "all",
    "editor.renderIndentGuides": true
}

and my workspace settings look like this:

// Place your settings in this file to overwrite default and user settings.
{
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/.idea": true,
        "**/build": true,
        "**/node_modules": true,
        "**/nohup.out": true,
        "**/data": true
    }
}

When I press ctrl+s it's like a newline gets there but immediately disappears, and the saved file does not contain a new line. I've verified that the other settings work as expected. Could another setting or extension be overriding this?

@jonathan-s
Copy link

@bpasero I just tried this, but it doesn't trim extraneous lines. It'd be nice if either there was an option for that too or if insertFinalNewline removed any extra blank lines at the end of the file.

@DenisTis
Copy link

DenisTis commented Jun 6, 2017

Visual Studio Code version 1.12.2
Exactly same issue.
With parameter "files.insertFinalNewline": true
line is added and instantly removed.
With EditorConfig it goes into infinite loop..

Obviously the problem is still not solved

@mdanetzky
Copy link

With parameter "files.insertFinalNewline": true
New Line gets removed for HTML files and inserted for .js and .ts

@mausworks
Copy link

Any update on this issue regarding editorconfig vscode + "files.insertFinalNewline": true?

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests