[
// Here are some of the usefull sublime user keys bindings
// 1. The following code will add Print ERB tag( <%= selected_ruby_code %>) with your selected word. This will place empty Print ERB tag ( <%= %> ) if you did not select any word. Now I just added Control (Ctrl) and Comma (,), You can customize this by changing "keys": ["ctrl+,"] from the following code.
// Auto-pair Print ERB tag <%= %>
{ "keys": ["ctrl+,"], "command": "insert_snippet", "args": {"contents": "<%= $0 %>"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
{ "keys": ["ctrl+,"], "command": "insert_snippet", "args": {"contents": "<%= ${0:$SELECTION} %>"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
// 2. The following code will add ERB tag( <% selected_ruby_code %>) with your selected word. This will place empty ERB tag ( <% %> ) if you did not selected any word. Now I just added Control (Ctrl) and Dot (.), You can cusomize this by changeing "keys": ["ctrl+."] from the following code.
// Auto-pair ERB tag <% %>
{ "keys": ["ctrl+."], "command": "insert_snippet", "args": {"contents": "<% $0 %>"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
{ "keys": ["ctrl+."], "command": "insert_snippet", "args": {"contents": "<% ${0:$SELECTION} %>"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
// 3. Another most using key binding for me is debuggers in javascript and binding.pry in ruby code
{ "keys": ["ctrl+alt+d"], "command": "insert", "args": {"characters": "<% binding.pry %>"} },
{
"keys": ["alt+d"], "command": "insert", "args": {"characters": "debugger;"},
"context": [{"key": "selector", "operator": "equal", "operand": "source.js,source.json"}]
},
{
"keys": ["alt+d"], "command": "insert", "args": {"characters": "binding.pry"},
"context": [{"key": "selector", "operator": "equal", "operand": "source.ruby"}]
},
{ "keys": ["alt+l"], "command": "insert_snippet", "args": {"contents": "console.log($0);"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }
]
},
// 4. Switch between Project directories, It is already there some times it won't work, so I just added it again in my Userkeybining file
{ "keys": ["ctrl+alt+w"], "command": "prompt_select_workspace" }
]