Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Automatically use hard tabs for Makefile buffers #3

Closed

Description

@cbednarski

Since makefiles require hard tabs, I'd like Atom to automatically use hard tabs whenever I'm editing a Makefile. Atom already detects the buffer type automatically.

Sublime Text accomplishes this via language-specific configuration files. So for example, I can independently specify 2 spaces default for javascript, 4 spaces default for python, and hard tab default for Makefiles. Not sure if this makes sense in Atom land but it seems like a simple way to do it.

Activity

  1. noseglid commented on Apr 12, 2014

    @noseglid

    +1

  2. iamdanfox commented on Apr 19, 2014

    @iamdanfox

    👍 This was the first thing that forced me to switch back to Sublime Text!!

  3. azhang commented on May 10, 2014

    @azhang

    👍 just ran into this problem now.

  4. lost-carrier commented on May 13, 2014

    @lost-carrier

    +1

    Makefile:X: *** missing separator.  Stop.
    

    OMG! Pain in the a... please fix this!!!

  5. liangshan commented on May 14, 2014

    @liangshan

    +1

  6. kgrossjo commented on May 14, 2014

    @kgrossjo

    +1

    I will edit it in vim for the time being.

  7. bral commented on May 16, 2014

    @bral

    I ended up just writing this and placing it in my Atom > Init Script

    path = require 'path'
    
    # Set Makefile[.any extension] and '.mk' files to always use hard tabs
    atom.workspaceView.eachEditorView (editorView) ->
      editor = editorView.getEditor()
      if path.basename(editor.getPath()) is 'Makefile'
        editor.setSoftTabs(false)
      if path.extname(editor.getPath()) is '.mk'
        editor.setSoftTabs(false)
    

    Seems to be working so far

  8. parabuzzle commented on May 23, 2014

    @parabuzzle

    I'll look into creating a pull request for a fix for this

  9. johnwebbcole commented on May 30, 2014

    @johnwebbcole

    +1

  10. parabuzzle commented on May 31, 2014

    @parabuzzle

    I wonder if anyone is going to review my pull request... 😕

  11. yoshuawuyts commented on Aug 13, 2014

    @yoshuawuyts

    @parabuzzle Have you started the PR? This bug is super annoying.

  12. parabuzzle commented on Aug 13, 2014

    @parabuzzle

    @yoshuawuyts the pull request has been open since May -> #8

  13. parabuzzle commented on Aug 13, 2014

    @parabuzzle

    @yoshuawuyts according to the PR referenced here for the core Atom code (atom/atom#2917) It appears that languages can specify hard tabs as an option.

    I'll look into it today. If that's the case, I'll submit a new PR using this new option.

  14. 27 remaining items

  15. rgbkrk commented on Oct 15, 2015

    @rgbkrk

    Could my own settings be overriding this somehow? I'm still ending up with spaces by default.

  16. rgbkrk commented on Oct 15, 2015

    @rgbkrk

    To answer my own question, it's a result of soft being set instead of auto in settings under "Tab Type":

    screenshot 2015-10-15 17 09 21

  17. thomasjo commented on Oct 16, 2015

    @thomasjo
    Contributor

    @rgbkrk The language settings should win, and in the case of language-make, the tab type is set hard.

    @atom/feedback Can any of you repro this?

  18. winstliu commented on Oct 16, 2015

    @winstliu
    Contributor
  19. LantosIstvan commented on Oct 25, 2015

    @LantosIstvan

    @50Wliu I installed the language-make 0.19.0 with apm install language-make command, but still inserting spaces instead of tabs. :(

    Console output:

    $ apm install language-make
    The language-make package is bundled with Atom and should not be explicitly installed.
    You can run `apm uninstall language-make` to uninstall it and then the version bundled
    with Atom will be used.
    Installing language-make to C:\Users\[USERNAME]\.atom\packages done
    
  20. asbjornu commented on Jan 27, 2016

    @asbjornu

    I've been struggling like a nutbag with this in Atom 1.4.1. I've tried every possible setting of "Soft Tabs" and "Tab Type". I've tried to convert spaces to tabs. Whatever I do; when the Makefile is saved, it has spaces in it.

    Checking "Show invisibles" reveals that I do get tabs when I press the tab key (represented by ») in the editor, but when I save, they are replaced with spaces.

    I finally figured out what it was. The tabs to spaces package has a configuration that I obviously must have turned on at some point:

    "tabs-to-spaces":
        "onSave": "untabify"

    This was being applied even when the package was disabled. Perhaps I need to restart Atom for the package's config to be ignored when the package is disabled? I don't know. I've tried to change the package's configuration to this:

    "*":
      "tabs-to-spaces":
        "onSave": "untabify"
    "Makefile":
      "tabs-to-spaces":
        "onSave": "tabify"

    But it doesn't help. I know this is beyond the scope of this issue, but I just wanted to mention it, for anyone else who stumble on to this with the same problem as I.

  21. thomasjo commented on Jan 27, 2016

    @thomasjo
    Contributor

    @asbjornu Are you able to reproduce the behavior in safe mode? atom --safe. Nothing in Atom (should) perform anything like this on save, so I'm guessing this is actually caused by the tabs-to-spaces package (which has "on save" behavior).

  22. asbjornu commented on Jan 27, 2016

    @asbjornu

    @thomasjo You're right. As I've updated my comment above, tabs-to-spaces and its onSave functionality is to blame. I was just dumbfounded that it was doing its thing even though I had disabled the package. Adjusting the configuration also doesn't help, so I'm creating an issue with it.

  23. sunjay commented on Feb 26, 2017

    @sunjay

    For anyone who ends up here from Google and sees @asbjornu's configuration, it needs to look like this:

    "*":
      "tabs-to-spaces":
        "onSave": "untabify"
    ".source.makefile":
      "tabs-to-spaces":
        "onSave": "tabify"

    This was addressed in: lee-dohm/tabs-to-spaces#42

  24. braadworst commented on Jul 17, 2017

    @braadworst

    @sunjay, ace! I couldnt figure out what the scope key name was for makefiles.

  25. bennabiy commented on Nov 17, 2017

    @bennabiy

    I am still having this issue, but not sure what package is causing it as I do not have tabs-to-spaces installed. I have tabs in my Makefile, but on save, I get 8 spaces instead.

  26. bennabiy commented on Nov 17, 2017

    @bennabiy

    I may be dense, but where do I set those settings to make it work?

  27. dcburleigh commented on Nov 29, 2017

    @dcburleigh

    How do I tell Atom which files are makefiles? I have some files like makefile.dev, makefile.inc,
    and I'd like Atom to give me hard tabs, syntax highlighting, etc.

  28. winstliu commented on Dec 3, 2017

    @winstliu
    Contributor

    @dcburleigh you can use the Grammar Selector (Ctrl+Shift+L on Windows/Linux, cmd-shift-L on macOS), or follow the instructions at https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539.

  29. richardPFisk commented on Feb 20, 2018

    @richardPFisk

    I had some joy using .editorconfig with this setting:

    [Makefile]
    indent_style = tab
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions