Different tab size depending on language


Title says it all. It would be nice to be able to configure the tab size (4spaces, vs 2spaces) depending on if I am working in JS, or CSS, or Ruby, etc.

Syntax-based tab length
Per syntax tab length settings and conversions
Of Markdown, remote editing, and soft-wrapping


Would really love to see this happen!



Python web-dev is basically impossible without this!


:+1: Must have feature!



As said above, this is a must feature. Supporting http://editorconfig.org/ would automatically fix this.



This needs to be done!

Who wants to take on this task and write a package? :smirk:


:+1: I use 2 spaces for languages with braces wrapping blocks (JavaScript, CSS) and 4 spaces for the ones that don’t (Python, Stylus, CoffeeScript).



One of the nice things about Sublime Text that I’m missing here is that it will try to automatically determine the tab size per-file. Additionally, you can set tab size per language, per project, and globally. Being reduced to a single global setting is slightly annoying.



This was the first problem I ran into. 2 spaces for JS, 4 for python.


+1 must have. I’m really missing per-language settings.


I just published a first go at automatic indentation detection: https://atom.io/packages/auto-detect-indentation

This sets per file tabLength/softTab settings for each file that’s opened. If it can’t detect the tab type, it falls back to the atom default.


@jtokoph Thanks! I’m using it as we speak.


+1! Would love this. @jtokoph’s plugin is a step in the good direction but it would be great if you could “force” tab settings based on the language you’re editing.


I’ve had luck with the EditorConfig plugin: http://editorconfig.org

Very cool concept.


Anyone still looking at this topic, there seems to be a nice solution here: https://atom.io/packages/syntax-settings

But personally, I just use the init file:

#example init.coffee
path = require 'path'

atom.workspaceView.eachEditorView (editorView) ->
  editor = editorView.getEditor()
  filepath = editor.getPath()

  # set Tab Length for JS sources
  if path.extname(filepath) is '.js'


And this kind of hackability is the reason why I :heart: Atom. Thank you for this simple solution.


Note that this feature has been implemented in Atom core: https://github.com/atom/atom/pull/3718

It should be released in the next version.



Nice to read that.
Indeed it is a must have feature.


Finally, there is a new release!

I don’t know how can I set this up in config though.
Following pull request #3718, I added this into my config.cson

  'softWrap': true

The config got changed automatically though, to:

  'softWrap': true

Any idea on how to get scoped settings to work?


Not sure. I’ve tried it myself and it’s not working for me either! I know @leedohm has messed around with it, perhaps he can shed some light.