0

Let's say I have a bunch of functions below:

library.object1.function1()

library.object1.function2()

library.object2.function1()

library.object2.function2()

library.object3.function1()

library.object3.function2()

With what they provide in current custom snippet, when I type lib, it will show all those above functions, which will be a mess if there are too many functions.

I want to make my snippets work like what they did in default code completion:

  • When I type lib, it only shows:

library

  • When I type library., it shows:

object1

object2

object3

  • When I type library.object1., it shows

function1()

function2()

  • Also, if I type lib, and leave it there, then comeback and add rary, the snippet doesn't work at all, I want it to continue the completion.

Is there a way to achieve it?

2
  • What is the "current custom snippet" you mention? From some extension you have installed? Commented May 25, 2018 at 4:16
  • @Mark it's how vscode allow user to create their own custom snippet: code.visualstudio.com/docs/editor/userdefinedsnippets Commented May 25, 2018 at 5:37

1 Answer 1

1

I think the closest you can get is something like this (using javascript.json snippet file as an example):

"my library": {
  "prefix": "lib",
  "body": [
    "library.${1|object1,object2,object3|}.${2|function1,function2,function3,function4|}()",
  ],
  "description": "my library functions" 
}

With that, when you type lib you get only the library suggested completion. Tab and you will get all the object choices you included in the snippet in the suggestion panel. Tab again and will get the function options that you listed in the snippet.

See snippet choices.

Sign up to request clarification or add additional context in comments.

1 Comment

Great idea. It isn't exactly what I want, but it's good enough. Thank you Mark!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.