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

Editorconfig doesn't work on new files #6

Open
tinganho opened this issue Dec 11, 2012 · 20 comments
Open

Editorconfig doesn't work on new files #6

tinganho opened this issue Dec 11, 2012 · 20 comments

Comments

@tinganho
Copy link

No description provided.

@sindresorhus
Copy link
Owner

Can you be a little more depicting?

Also paste in the output of your Sublime console.

@tinganho
Copy link
Author

Tabbing doesn't work correctly. If you have the default settings in Sublime, indent using tabs and tab size 4. And in the .editorconfig file you use the following file:

root = true

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

It will not override the default settings when you create a new file. It will use the sublime default settings.

@sindresorhus
Copy link
Owner

You have multiple indent_style properties

@tinganho
Copy link
Author

Ok removed the first indent_style, but the problem still occurs for new files. Editorconfig doesn't override Preference -> Settings -Default on new files

@dotcypress
Copy link

If you tell about new and unsaved file, is not a bug, because plugin can't find config.

@sindresorhus
Copy link
Owner

Yes, that's correct. The settings should take effect the moment you save the file though.

@aripalo
Copy link

aripalo commented Mar 19, 2013

For me it doesn't work on new file even after I've saved it, but it works after I've closed the file and reopened it...

@sindresorhus
Copy link
Owner

@aripalo sorry, I was wrong, what you describe is the intended behavior. We don't want to apply settings without you being able change them back. That's why everything is applied on load (except for charset which has to be applied on save). Should probably mention this in the readme.

@aripalo
Copy link

aripalo commented Mar 19, 2013

Hmm... Well I'd argue that the whole point of the .editorconfig file is to enforce agreed upon code style. Therefore if user chooses to revert back to some other style, she could add an exception (pointing to the file she is editing) to the .editorconfig file before saving.

What do you think?

@treyhunner
Copy link
Contributor

Maybe this is a job for the Sublime Text configuration file?

@aripalo
Copy link

aripalo commented Mar 19, 2013

Getting the configuration file setting would be a "victory" for me :) I'm annoyed that I need to save and then reopen the files all the time for Sublime to "pick up the code style" & our team isn't that big at the moment that I could check that everyone has the proper "on save" configuration.

But even so I'd still argue that it should be "on save" by default, otherwise it's easy for another team member accidentally mess things up. Also if "on save" would be the default, it'd mean that I'd only have to make sure everyone in the team has the plugin installed without worring about their Sublime configurations.

@OliverJAsh
Copy link

I’m frustrated that it doesn't add a new line to my files unless I close and re-open them.

@sindresorhus
Copy link
Owner

@OliverJAsh it does it on save. That how Sublime works:

settings.set('ensure_newline_at_eof_on_save', True)

@OliverJAsh
Copy link

@sindresorhus If it's a new file, when you save it brings up a dialog to ask where you'd like to save. After saving, a new line is not added – if I save again, then it is added.

@sindresorhus
Copy link
Owner

I won't have time to look into this for a while, but help welcome :)

@toymachiner62
Copy link

👍

@mpcabd
Copy link

mpcabd commented Jun 17, 2015

I have a similar problem, but my problem is that my indention style in the .editorconfig file is different from the default indention style of Sublime, and that results in what you see in the picture below. And that's because when I created the file I wrote the first class, and then saved it, and the next time I opened it I wrote the second one, so it took the configuration from the .editorconfig file.

I wonder would it make a difference if I was working on a project? I currently just have the folder opened in Sublime, without a defined project.

Thanks! 👍

screen shot 2015-06-17 at 10 58 46 pm

@func0der
Copy link

func0der commented Jul 3, 2015

I find that since

    "tab_size": 2,
    "translate_tabs_to_spaces": true

in a sublime-project file do apply to new files created in that project window, this should also apply for .editorconfig configured (soon-to-be-)files.
So whatever is given in the [*] section, it should be applied to EVERYTHING, saved or not, file or draft, cow or chicken.

@func0der
Copy link

@sindresorhus So?

@PxAnn
Copy link

PxAnn commented May 17, 2018

I'm using vscode editor and I meet the same issue. After I installed a plugin called 'editorconfig vs vscode', my new .editorconfig works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants