Skip to content

Instantly share code, notes, and snippets.

@rg3915
Last active June 21, 2022 13:45
Show Gist options
  • Save rg3915/400371a8795fb0bc030ddaaae2b213fa to your computer and use it in GitHub Desktop.
Save rg3915/400371a8795fb0bc030ddaaae2b213fa to your computer and use it in GitHub Desktop.
Sublime Text 3 config + ajax_ snippet
// https://github.com/beautify-web/js-beautify#css--html
{
"html": {
"wrap-attributes": "force-expand-multiline"
},
"end_with_newline": true,
"indent_level": 2,
}
[
{ "keys": ["ctrl+shift+r"], "command": "auto_pep8", "args": {"preview": false} },
{ "keys": ["ctrl+q"], "command": "close_all" },
{ "keys": ["ctrl+0"], "command": "reset_font_size" },
{ "keys": ["ctrl+4"], "command": "run_macro_file", "args": {"file": "res://Packages/User/new-branch.sublime-macro"}},
{ "keys": ["ctrl+5"], "command": "run_macro_file", "args": {"file": "res://Packages/User/ins_date.sublime-macro"}},
{ "keys": ["ctrl+6"], "command": "run_macro_file", "args": {"file": "res://Packages/User/ok.sublime-macro"}},
{ "keys": ["ctrl+7"], "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 }
]
},
{ "keys": ["ctrl+8"], "command": "insert_snippet", "args": {"contents": "```\n${0:$SELECTION}```\n\n"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
{ "keys": ["ctrl+shift+8"], "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 }
]
},
{ "keys": ["ctrl+9"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+9"], "command": "toggle_comment", "args": { "block": true } },
{ "keys": ["ctrl+k", "ctrl+t"], "command": "title_case" },
{ "keys": ["alt+shift+up"], "command": "column_select", "args": {"by": "lines", "forward": false}},
{ "keys": ["alt+shift+down"], "command": "column_select", "args": {"by": "lines", "forward": true}},
{ "keys": ["ctrl+alt+pageup"], "command": "column_select", "args": {"by": "pages", "forward": false}},
{ "keys": ["ctrl+alt+pagedown"], "command": "column_select", "args": {"by": "pages", "forward": true}},
{ "keys": ["ctrl+alt+home"], "command": "column_select", "args": {"by": "all", "forward": false}},
{ "keys": ["ctrl+alt+end"], "command": "column_select", "args": {"by": "all", "forward": true}},
// https://stackoverflow.com/a/13194410
// Syntax Change
{"keys": ["alt+shift+h"], "command": "set_file_type",
"args": {"syntax": "Packages/HTML/HTML.tmLanguage"}
},
{"keys": ["alt+shift+p"], "command": "set_file_type",
"args": {"syntax": "Packages/Text/Plain text.tmLanguage"}
},
{"keys": ["alt+shift+y"], "command": "set_file_type",
"args": {"syntax": "Packages/Python/Python.tmLanguage"}
},
// Tab size
{ "keys": ["ctrl+shift+2"], "command": "set_setting", "args": {"setting": "tab_size", "value": 2} },
{ "keys": ["ctrl+shift+4"], "command": "set_setting", "args": {"setting": "tab_size", "value": 4} },
// Slugify
{ "keys": ["super+alt+y"], "command": "slugify" },
]
// https://github.com/ehuss/Sublime-Column-Select

Macro

Requer package insert_date

# ins_date.sublime-macro
[
    { "command": "insert_snippet", "args": {"contents": "Branch: $2-$0\nDate: $1\n\n#$0 - $2. Close #$0\n"} },
    { "command": "insert_date", "args": {"format": "%x"} },
    { "command": "next_field" }
]

keymap shortcut

{ "keys": ["ctrl+5"], "command": "run_macro_file", "args": {"file": "res://Packages/User/ins_date.sublime-macro"}},
# -*- coding: utf-8 -*-
from datetime import datetime
import time
import sublime_plugin
class TimestampCommand(sublime_plugin.EventListener):
"""Expand `isoD`, `now`, `datetime`, `utcnow`, `utcdatetime`,
`date` and `time`
"""
def on_query_completions(self, view, prefix, locations):
if prefix in ('isoD', 'now', 'datetime'):
val = datetime.now().strftime('%Y-%m-%d %H:%M')
elif prefix in ('utcnow', 'utcdatetime'):
val = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')
elif prefix == 'date':
val = datetime.now().strftime('%Y-%m-%d')
elif prefix == 'data':
val = datetime.now().strftime('%d/%m/%Y')
elif prefix == 'mdata':
val = datetime.now().strftime('%d/%m/%y')
elif prefix == 'dt':
val = '## %s' % datetime.now().strftime('%d/%m/%y')
elif prefix == 'time':
val = str(int(time.time()))
else:
val = None
return [(prefix, prefix, val)] if val else []
@rg3915
Copy link
Author

rg3915 commented May 11, 2020

Manter .txt em Plain Text
Abra um arquivo .txt
Depois vá em *View > Syntax > Open all with current extension as ... * e escolha Plain Text.

@rg3915
Copy link
Author

rg3915 commented Oct 12, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment