question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trimming whitespace/inserting newline broken?

See original GitHub issue
  • I have a question that is specific to this extension; thus, inappropriate for the main EditorConfig issue tracker.
  • I tried running code --disable-extensions and the issue did NOT present itself.
  • I tried npm install editorconfig -g and ran editorconfig [file-in-question] and the configuration was what I expected. If not, please file on the editorconfig-core-js issue tracker.

Issue

Visual Studio Code editorconfig-vscode
Version 1.11.2 0.9.3

Root .editorconfig File

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

; Golang and Makefile
[{*.go,Makefile}]
indent_style = tab

; JSON, Markdown, and YAML (and similar)
[*.{json,yml,yaml,babelrc,eslintrc,eslintrc.json,gqlconfig,md,markdown}]
indent_size = 2

Are there any other relevant .editorconfig files in your project? No

Visual Studio Code Setting Default User Workspace
editor.insertSpaces true ____ ____
editor.tabSize 4 _ _
editor.trimAutoWhitespace true ____ ____
files.autoSave "off" "___" "___"
files.insertFinalNewline false _____ _____
files.trimTrailingWhitespace false _____ _____

File opened

Any

Expected behavior

Trim whitespace and insert final newline

Actual behavior

No trimming or inserted newline. Other settings (such as indent size) behave correctly.

Additional comments or steps to reproduce

I’ve been using this config without issue for months, and just noticed it stopped working. Tried disabling other extensions in case of a conflict, but it didn’t make a difference. Looking at VSCode’s Output window, I see EditorConfig prints the following whenever I save a file: No configuration found for pre-save.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jednanocommented, May 5, 2017

@spencerhakim I’m so glad I added that logging as a new feature. It’s so incredibly useful for cases like these! Thanks for the update and I’ll go ahead and close this for now unless it resurfaces. Looks like it was a vscode issue.

1reaction
spencerhakimcommented, May 5, 2017

Updated to VSCode 1.12.1 today and everything is working again. I’ll leave it up to someone else if this issue should be closed or investigated further. For the record, whenever I save now I see the following in the output window:

[file path]: setEndOfLine(LF)
[file path]: editor.action.trimTrailingWhitespace
[file path]: insertFinalNewline(LF)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove white space from the start of every new line of a string
It replaces any sequence of white space, including at least one line break ( \R ), with a single line break ( \n...
Read more >
Trim whitespace and add line break - UNIX and Linux Forums
I'm a newbie at shell scripting and regular expressions and I just need to take a file that's arranged like the one below,...
Read more >
white-space - CSS-Tricks
When the text renders in the browser, those line breaks appear as if they are stripped out. Also stripped out are the extra...
Read more >
15 Easy Ways to Trim a String in Python - miguendes's blog
Learn how to trim a string in Python with these 15 actionable tips. Remove spaces, tabs, newline, special characters, line ending, and more!...
Read more >
String.Trim Method (System) - Microsoft Learn
Because of this change, the Trim() method in the .NET Framework 3.5 SP1 and earlier versions removes two characters, ZERO WIDTH SPACE (U+200B)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found