Dotfiles/sublime-text/Default/duplicate_line.py

12 lines
458 B
Python
Raw Normal View History

2014-05-12 18:57:15 +02:00
import sublime, sublime_plugin
class DuplicateLineCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if 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))