import os.path import sublime import sublime_plugin class CopyPosCommand(sublime_plugin.TextCommand): def run(self, edit): try: project_path = self.view.window().extract_variables().get("project_path", "") line, _ = self.view.rowcol(next(iter(self.view.sel())).begin()) sublime.set_clipboard("{}:{}".format(os.path.relpath(self.view.file_name(), project_path), line+1)) except StopIteration: pass