Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippets in VSCode #24

Closed
michael3m opened this issue Aug 20, 2022 · 3 comments
Closed

Snippets in VSCode #24

michael3m opened this issue Aug 20, 2022 · 3 comments

Comments

@michael3m
Copy link

michael3m commented Aug 20, 2022

Hello.
VSCode has built-in support of snippets.
But the way they are handled by your great extension is not perfect.

Let me explain.

At this gif you can see, how snippets works in SublimeText - they are perfectly formatted and ready to use right after typing it.
Sublime

Now, let's add same snippet into VSC:
snippetTXT

and then try to use it:
VSC

As you can see, snippet is not properly formatted (pay attention to the label) and demands some handwork to get it to the usable state.
And note, please - I've used a very simple example of snippet - look at this one:
basic
In VSCode, we'll need much more formatting work in this case.

So, question is simple: is it possible to solve this problem and use snippets with more efficiency?

@mborik
Copy link
Owner

mborik commented Aug 23, 2022

Hello, I understand your problem but it's not an issue of my extentension, isn't it? 🤓
There are many opened issues in vscode for years without any conclusion.

My thoughts are that \r would be great addition to snippets but unfortunately it does not work.

{
  "loop_BC": {
    "prefix": "loop_BC",
    "body": [
      "ld bc,$1",
      "\rloop\tdec bc",
      ...
    ]
  }
}

BUT, if you want to have such variable indent snippets you could define it with tabulators and insert snippet on zero cursor position within the line:

{
  "loop_BC": {
    "prefix": "loop_BC",
    "body": [
      "\tld bc,$1",
      "loop\tdec bc",
      "\tld a,b",
      "\tor c",
      "\tjr nz,loop",
      "\t$0"
    ]
  }
}

However you still can define your code style in my extension and let the formatter do its business 😉

@michael3m
Copy link
Author

I'm not sure. I thought, your extension acts as default formatter, so this problem related to it.
Well, sorry then.

@mborik
Copy link
Owner

mborik commented Aug 29, 2022

@michael3m You can disable built-in plugin formatter (if you're using FormatOnType or FormatOnPaste) OR as I suggesting you few lines above, setup your code-style in settings, enable FormatOnType/Paste and try your snippets. 👍
But as I mentioned last week, my extentension not affecting default behaviour of VSCode and how it's putting snippets into the code in any way. Comparing Sublime vs VSC and then putting the blame on my extension is not fair 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants