#!/usr/bin/python import sublime import sublime_plugin from os.path import exists from os.path import expanduser home = expanduser("~") PUDB_FILE = home + '/.config/pudb/saved-breakpoints' class AddBreakpointCommand (sublime_plugin.TextCommand): def run(self, edit): filename = self.view.file_name() if filename and exists(PUDB_FILE): with open(PUDB_FILE, 'a') as f: for selection in self.view.sel(): row, _ = self.view.rowcol(selection.begin()) breakpoint = "b %s:%d\n" % (filename, row + 1) f.write(breakpoint)