- Code: Select all
class RelativeIndentPasteCommand(sublimeplugin.TextCommand):
def run(self, view, args):
view.runCommand('insertInlineSnippet', ['$PARAM1', sublime.getClipboard()])
You could almost get away with just view.runCommand('insertInlineSnippet', [sublime.getClipboard()]), but then the contents of the clipboard will be interpreted as a snippet, which is probably a bad idea.
It's also worth noting that there are couple of extra things that copy/paste do in sublime, that aren't accessible via getClipboard/setClipboard:
- An extra flag is stored in the clipboard indicating if it should be pasted as a stand alone line. This is used to make Ctrl+C, Ctrl+V function as 'duplicate line' when the selection is empty.
- The syntax of the text copied to the clipboard is also stored there for meta info, so when pasting into a new buffer, the syntax will be applied.