sindresorhus / editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
MIT License
1.77k stars 108 forks source link

Editorconfig doesn't work on new files #6

Open tinganho opened 11 years ago

sindresorhus commented 11 years ago

Can you be a little more depicting?

Also paste in the output of your Sublime console.

tinganho commented 11 years ago

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 commented 11 years ago

You have multiple indent_style properties

tinganho commented 11 years ago

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 commented 11 years ago

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

sindresorhus commented 11 years ago

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

aripalo commented 11 years ago

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 commented 11 years ago

@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 commented 11 years ago

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 commented 11 years ago

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

aripalo commented 11 years ago

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 commented 10 years ago

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

sindresorhus commented 10 years ago

@OliverJAsh it does it on save. That how Sublime works: https://github.com/sindresorhus/editorconfig-sublime/blob/79b466e0eee57ef0b8fa50b96350a60543778446/EditorConfig.py#L91

OliverJAsh commented 10 years ago

@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 commented 10 years ago

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

toymachiner62 commented 9 years ago

:+1:

mpcabd commented 9 years ago

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! :thumbsup:

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

func0der commented 9 years ago

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 commented 9 years ago

@sindresorhus So?

PxAnn commented 6 years ago

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