editorconfig-sublime icon indicating copy to clipboard operation
editorconfig-sublime copied to clipboard

Editorconfig doesn't work on new files

Open tinganho opened this issue 11 years ago • 20 comments

tinganho avatar Dec 11 '12 04:12 tinganho

Can you be a little more depicting?

Also paste in the output of your Sublime console.

sindresorhus avatar Dec 11 '12 08:12 sindresorhus

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.

tinganho avatar Dec 11 '12 08:12 tinganho

You have multiple indent_style properties

sindresorhus avatar Dec 11 '12 09:12 sindresorhus

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

tinganho avatar Dec 11 '12 09:12 tinganho

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

dotcypress avatar Mar 13 '13 07:03 dotcypress

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

sindresorhus avatar Mar 13 '13 08:03 sindresorhus

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...

aripalo avatar Mar 19 '13 12:03 aripalo

@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.

sindresorhus avatar Mar 19 '13 15:03 sindresorhus

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?

aripalo avatar Mar 19 '13 16:03 aripalo

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

treyhunner avatar Mar 19 '13 17:03 treyhunner

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.

aripalo avatar Mar 19 '13 18:03 aripalo

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

OliverJAsh avatar Jun 11 '14 14:06 OliverJAsh

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

sindresorhus avatar Jun 11 '14 15:06 sindresorhus

@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.

OliverJAsh avatar Jun 12 '14 10:06 OliverJAsh

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

sindresorhus avatar Jun 19 '14 00:06 sindresorhus

:+1:

toymachiner62 avatar Jun 17 '15 15:06 toymachiner62

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

mpcabd avatar Jun 17 '15 21:06 mpcabd

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 avatar Jul 03 '15 10:07 func0der

@sindresorhus So?

func0der avatar Jul 27 '15 08:07 func0der

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

PxAnn avatar May 17 '18 03:05 PxAnn