Sublime Forum

Make snippets remember last string used in a field?

#1

I have this getterandsetter snippet:

${2:int} get${1/\b(\w*)\b/\u\1/g:Var}(){ return ${1:Var}; } void set${1/\b(\w*)\b/\u\1/g:Var}(${2:int} p_${1:var}){ ${1:var}=p_${1:var}; }
And it gets pretty annoying to put the type everytime it’s not an int. Unless I can search the file for the variable type, I think the only way to avoid that to some extent would be to remember the last used type, so I only need to change it once for the next variable row. Is it possible?

0 Likes

#2

Interesting idea, could be added to ST as a feature.

Other than that, I think this would be hackable with a plugin, however it would involve a lot of messing with on_text_command and probably not for beginners. If you have experience with plugins, then I suggest to give it a try.

0 Likes