How Would I Only Make Snippets Visible if Something is Typed?


#1

I’m sure this question is kind of vague, and I don’t know if I’m asking the right question anyway. I’m sorry about that, but I’ve been searching and searching and can’t find the answer, or if this is even possible.

What I’m asking is, how can I make a snippet only visible if you have something typed before it?
For example, say I have a console.log snippet. The prefix is ‘log’. While in most examples, this is changed to “console.log”, I use snippets purely for adding descriptions to functions and using other snippet functionalities rather than shortcuts (which I still use, but not always). I only want “log” to show up when I type “console.”, as to keep everything a bit more organized. Is this doable?


#2

If the prefix is log, then you will type log and press tab to expand the snippet. I’m not sure why you want to type console. when that seems like it should be part of the expanded snippet.


#3

I’m kind of trying to mimic intellisense in a way. The language I’m using doesn’t have any support for intellisense that I could find.


#4

Since I don’t use Visual Studio, I have no idea what features its code completion includes. You will have to be specific.

Based on your first post, I assumed JavaScript. If you are not using JavaScript, but using some other language where console.log is a meaningful piece of syntax, you should specify that as well.


#5

You’re asking for method auto completion, right?

Snippets won’t do that, but it’s possible to write an autocomplete package that does. Depending on the accuracy you want though, it will be very difficult. I’ve found that the hydrogen package works pretty well though.