Reputation: 10035
When I type action()
and hit return in the between the parentheses, I get this:
action (
)
instead of this:
action (
)
How do I change this?
I have this in my keybindings right now but it only works in non-js files-
[
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
]
},
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
{ "keys": ["super+shift+\\"], "command": "reveal_in_side_bar"},
{"keys": ["tab"], "command": "expand_abbreviation_by_tab", "context":
[
{ "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" },
{ "match_all": true, "key": "selection_empty" },
{ "operator": "equal", "operand": false, "match_all": true, "key": "has_next_field" },
{ "operand": false, "operator": "equal", "match_all": true, "key": "auto_complete_visible" },
{ "match_all": true, "key": "is_abbreviation" }
]
},
]
Upvotes: 6
Views: 203
Reputation: 2852
The way I got it to work was, from within a *.js file in ST3, click Preferences > Settings - Syntax Specific
. A separate window with 2 panes should open. In the right-hand pane add
"auto_indent": false,
between the braces and Save. When you go back into the JavaScript file and type action()
and hit return in the between the parentheses there should be no more indenting.
Upvotes: 1
Reputation: 1573
If nothing is working out then you can write a snippet for yourself in sublime like this (Menu Bar -> Tools -> Developer -> New snippet) and put the following code and save it.
<snippet>
<content><![CDATA[
action(${1:}
)
]]></content>
<tabTrigger>act</tabTrigger>
<!-- <scope>source.JavaScript</scope> -->
</snippet>
It is a temporary solution not the best one. But for time being it can work.
Upvotes: 4