Sublime Forum

Replacing a line in the view with a string?

#1

Hi guys,

I’m working on a plugin that will generate a variable for a CSS property if you run the command on that line. So far so good, and I have reached a point where running my plugin produces this result:

As you can see, I have run the script on line 25. My output is formatted correctly, and the first result is copied to the clipboard. The second is what I need to place back into the line. Can someone just guide me over the final hurdle please?

Thanks,

0 Likes

#2

Assuming you are inside a text command and have the edit object available and the text is in the variable text just write:

line = view.line(view.sel()[0])
view.replace(edit, line, text)
2 Likes