Well, I’m replacing a range. So the user would select the 3 lines of
with the cursor, then the .replace function would run. How would I regex or re-indent this since it’s in a range?
Let’s say this is my original text:
[code]
Name:
<%= @accessory.name %>
<p>
<b>Description:</b>
<%= @accessory.description %>
</p>
<p>
<b>Price:</b>
<%= @accessory.price %>
</p>[/code]
I select and want to replace the entire code above with:
<b>Hello!</b>
However, see how the original code is indented? I want the same amount of indention prepended to the replacement text. Hopefully that is a little clearer than the example in my previous post.
Looking in ST2’s Default/indentation.py package, there are some ideas, but I’m not sure of the best way to implement them into my own plugin. Can they be executed into my plugin? If so, I’m not sure how nor which function to call necessarily. The plugin is finished, I just want to try and polish it up before putting it in my repo.