Instead of view.insert
, you can try paste_and_indent
From Docs/Commands:
paste_and_indent
Inserts the clipboard contents after the caret and indents contextually.
Also, try:
"onClick={}\n\tkind={}\n\tfoo={}\n"
( your version did not include \t
for the tab character of the 2nd & 3rd lines )
If that doesn’t work for you, you could also dynamically calculate the indentation level.
Check out:
#Indentation.py
It’s part of a dependency I’m working on. It’s not ready for release yet, but the Indentation
module is fully functional.
You can use get_Level
to find the current line’s indentation level, and then get_IndentationString
to return a string of the files proper indentation characters for your desired indentation level.