Different tab size depending on language


#1

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
#2

+1

Would really love to see this happen!


#3

+1

Python web-dev is basically impossible without this!


#4

:+1: Must have feature!


#5

+1

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


#6

+1

This needs to be done!

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


#7

:+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).


#8

+1

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.


#9

+1

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


#10

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


#11

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.


#12

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


#13

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


#14

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

Very cool concept.


#15

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'
    editor.setTabLength(4)
```

#16

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


#17

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.


#18

:+1:

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


#19

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

'.source.gfm':
  'softWrap': true

The config got changed automatically though, to:

'.gfm.source':
  'softWrap': true

Any idea on how to get scoped settings to work?


#20

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.