A quick google search on hard and soft tabs in Atom shows that lots of people have trouble with this issue, and that a lot of the recommended solutions seem to work for some people but not others. After struggling with the settings for a while today, I think I can explain what’s going on to others who might be having trouble getting the result they want, without having to try installing 6 different packages (or any).
The problem seems to be that Atom has two different internal properties that affect tabbing:
softTabs might not work if
tabType is for some reason contradicting it (for example because you’re new to Atom, and, like me, you just tried a bunch of random things without understanding them first).
softTabs takes a boolean (
tabType takes an argument, either
These settings can be accessed and changed in the
That’s enough info if you always want to use the same type of tab, but if you want to use different tab types for different languages, read on…
For most users, I would recommend ALWAYS having
tabType set to
'auto'. This allows you to specify the type of tab for each file, or type of file, using
You can do this by adding the following line to
under the heading:
Then you can set
softTabs to whatever your normal preference is:
and change it in each file using the
Toggle Soft Tabs command, available for example with
This is huge pain, so you might want to use the magical
init.coffee file to set preferences for different types of files. The following code, inserted into
init.coffee, will set the tabbing preference based on the file extension. This code will turn off softTabs for ‘.abc’ files and on for ‘.cba’ files:
path = require 'path'
atom.workspace.observeTextEditors (editor) ->
filepath = editor.getPath()
if path.extname(filepath) is '.abc'
if path.extname(filepath) is '.cba'
Tab sizes can be changed with similar code:
If you try all this and is doesn’t work:
- Save everything
- Close Atom
- Test the settings by creating a new file
Hope this helps someone avoid spending as much time as I did figuring it out.