for context: i'm writing snippet python cast variable, so: variable_foo
str(variable_foo)
.
if use $selection, works fine. if use $tm_current_word, inserts replacement value middle of variable text, this: variastr(variable_foo)ble_foo
.
i keep using $selection, i'd prefer added ease of not having select variable first ctrl+d $tm_current_word provide. there i'm overlooking makes possible, or $selection way go?
for reference, functional version of snippet: ${1:type}($selection)${0}
and alternate version: ${1:type}${selection/^.*/\($0\)/g}${0}
i believe intended behavior. can use plugin behavior want though.
import sublime_plugin class expandinsertsnippetcommand(sublime_plugin.textcommand): def run(self, edit, contents=none, name=none): cursors = self.view.sel() new_cursors = [] cursor in cursors: new_cursors.append(self.view.word(cursor)) cursors.clear() cursor in new_cursors: cursors.add(cursor) self.view.run_command("insert_snippet", {"contents": contents, "name": name})
rather using command "insert_snippet" whatever binding have, use "expand_insert_snippet".
Comments
Post a Comment