├── Stupid Indent.sublime-settings ├── packages.json ├── stupid_indent.py ├── Main.sublime-menu └── README.md /Stupid Indent.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "configuration": 3 | [ 4 | { 5 | "patterns": ["Gemfile", "*.rb", "*.erb", "*.scss", "*.coffee"], 6 | "tab_size": 2, 7 | "translate_tabs_to_spaces": true 8 | }, 9 | { 10 | "patterns": ["*.html", "*.js", "*.css"], 11 | "tab_size": 2, 12 | "translate_tabs_to_spaces": true 13 | }, 14 | { 15 | "patterns": ["*.php"], 16 | "tab_size": 4, 17 | "translate_tabs_to_spaces": false 18 | }, 19 | { 20 | "patterns": ["*.md", "*.markdown"], 21 | "tab_size": 4, 22 | "translate_tabs_to_spaces": true 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages.json: -------------------------------------------------------------------------------- 1 | { 2 | "schema_version": "1.2", 3 | "packages": [ 4 | { 5 | "name": "Stupid Indent", 6 | "description": "A Sublime Text 2/3 plugin to determine indentation settings based on filename rather than current indentation", 7 | "author": "Latchezar Tzvetkoff", 8 | "homepage": "https://github.com/tzvetkoff/sublime_stupid_indent", 9 | "last_modified": "2012-10-19 14:00:00", 10 | "platforms": { 11 | "*": [ 12 | { 13 | "version": "1.1.0", 14 | "url": "https://nodeload.github.com/tzvetkoff/sublime_stupid_indent/zipball/master" 15 | } 16 | ] 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /stupid_indent.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | 4 | import os.path 5 | import fnmatch 6 | import sublime 7 | import sublime_plugin 8 | 9 | class StupidIndent(sublime_plugin.EventListener): 10 | def on_load(self, view): 11 | basename = os.path.basename(view.file_name()); 12 | settings = view.settings() 13 | 14 | for entry in sublime.load_settings('Stupid Indent.sublime-settings').get('configuration'): 15 | for pattern in entry.get('patterns', []): 16 | if fnmatch.fnmatch(basename, pattern): 17 | settings.set('tab_size', entry.get('tab_size', settings.get('tab_size'))) 18 | settings.set('translate_tabs_to_spaces', entry.get('translate_tabs_to_spaces', settings.get('translate_tabs_to_spaces'))) 19 | return 20 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences", 4 | "mnemonic": "n", 5 | "id": "preferences", 6 | "children": 7 | [ 8 | { 9 | "caption": "Package Settings", 10 | "mnemonic": "P", 11 | "id": "package-settings", 12 | "children": 13 | [ 14 | { 15 | "caption": "Stupid Indent", 16 | "children": 17 | [ 18 | { 19 | "command": "open_file", 20 | "args": {"file": "${packages}/Stupid Indent/Stupid Indent.sublime-settings"}, 21 | "caption": "Settings – Default" 22 | }, 23 | { 24 | "command": "open_file", 25 | "args": {"file": "${packages}/User/Stupid Indent.sublime-settings"}, 26 | "caption": "Settings – User" 27 | }, 28 | { 29 | "caption": "-" 30 | } 31 | ] 32 | } 33 | ] 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Stupid Indent for Sublime Text 3 | 4 | A Sublime Text plugin to determine indentation settings based on filename rather than current indentation. 5 | Supports both Sublime Text 2 and 3. 6 | 7 | ## Installation 8 | If you're using the [Sublime Package Control](http://wbond.net/sublime_packages/package_control) plugin, you can install the plugin just like any other - `⌘⇧P`, `Install Package`, `Stupid Indent`. 9 | 10 | The other way around is to manually clone the repository: 11 | 12 | ``` bash 13 | # WARNING: This instructions apply only to Mac OS X 14 | cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages 15 | # or ~/Library/Application\ Support/Sublime\ Text\ 2/Packages 16 | git clone https://github.com/tzvetkoff/sublime_stupid_indent sublime_stupid_indent 17 | ``` 18 | 19 | ## Configuration 20 | Stupid Indent adds settings to the Package Settings menu: `Preferences -> Package Settings -> Stupid Indent`. 21 | To customize them, just copy `Settings -> Default` to `Settings -> User`, or use mines below: 22 | ``` json 23 | { 24 | "configuration": 25 | [ 26 | { 27 | "patterns": [ "Gemfile", "Rakefile", "*.rb", "*.erb", "*.scss", "*.coffee", "*.thor", "*.rake", "*.rhtml", "*.less", "*.yaml","*.yml" ], 28 | "tab_size": 2, 29 | "translate_tabs_to_spaces": true 30 | }, 31 | { 32 | "patterns": [ "*.html", "*.js", "*.css", "*.tpl" ], 33 | "tab_size": 2, 34 | "translate_tabs_to_spaces": true 35 | }, 36 | { 37 | "patterns": [ "*.php" ], 38 | "tab_size": 4, 39 | "translate_tabs_to_spaces": false 40 | }, 41 | { 42 | "patterns": [ "*.md", "*.markdown" ], 43 | "tab_size": 4, 44 | "translate_tabs_to_spaces": true 45 | }, 46 | { 47 | "patterns": [ "*.py" ], 48 | "tab_size": 4, 49 | "translate_tabs_to_spaces": false 50 | } 51 | ] 52 | } 53 | ``` 54 | --------------------------------------------------------------------------------