Following the suggestion in this post I'm able to insert a snippet around some selected text. As seen in @Mark's demo after completing the insert the cursor is left in two places. The line/lines all end with a newline.
original:
cube([10, 10, 10]);
what I want:
difference() {
cube([10, 10, 10]);
|
}
what I get:
|difference() {
cube([10, 10, 10]);
|}
Here is the snippet code I'm using:
"body": [
"${1:${TM_SELECTED_TEXT/^([ \\t]*)[\\s\\S]*$/$1/}}difference() {",
"${TM_SELECTED_TEXT/^(.*?)$(\\r?\\n)?/\t$1$2/gm}", // note the 'g' flag !!!
"$1$0}\n"
],
Based on the snippet code it makes sense that the $0 point is underneath the second cursor. So how can I remove the last newline in the selected text so I can put $0 before that last newline? I realize I may have to type a tab
to get to the position of the $0. For now I'm just making sure I don't select the last newline, but I'd like to just be able to triple click and drag the cursor down to select the lines.