Skip to content

Instantly share code, notes, and snippets.

@homm
Last active September 27, 2015 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homm/1261735 to your computer and use it in GitHub Desktop.
Save homm/1261735 to your computer and use it in GitHub Desktop.
User key bindings for sublime text and modificated duplicate_line.py in /Packages/Default/duplicate_line.py
[
{ "keys": ["super+g"], "command": "find_under", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
{ "keys": ["super+c"], "command": "noop", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
]
},
{ "keys": ["super+d"], "command": "duplicate_line", "args": {"force_lines": true}},
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["super+shift+x"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+k", "super+m"], "command": "set_mark" },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+q"], "command": "previous_edit" },
{ "keys": ["ctrl+shift+q"], "command": "next_edit" },
{ "keys": ["super+."], "command": "auto_complete" }
]
import sublime, sublime_plugin
class DuplicateLineCommand(sublime_plugin.TextCommand):
def run(self, edit, force_lines=False):
for region in self.view.sel():
if force_lines or region.empty():
line = self.view.line(region)
line_contents = self.view.substr(line) + '\n'
self.view.insert(edit, line.begin(), line_contents)
else:
self.view.insert(edit, region.begin(), self.view.substr(region))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment