0

I have been trying to use a custom snippet using hypersnips, but it doesn't seem to work. I have installed the extension in vs code and wrote the snippet in all.hsnips, but I am not able to use it inside my react file. Can someone help me with this? This is my snippet code(all.hsnips)

snippet `divx\.([^ ]+) ` "expand to jsx className" A
<div className={``rv=m[1]``}>$1</div>
endsnippet

I have also referred these LaTeX fraction snippets in VSCode

MR. Mentor
  • 11
  • 2
  • Your snippet works fine for me in an `all.hsnips` file. Did you `HyperSnips: Reload Snippets` from the Command Palette after making any changes to the `all.snips` file? [For performance reasons probably better to put the snippet into `javascriptreact.hsnips` instead.] – Mark Sep 18 '22 at 17:40
  • Yes I added the snippet in all.hsnips, then did HyperSnips: Reload Snippets in vs code. Then I opened my react file and then isn't it supposed to automatically activate? Or is there any other step that I missed? – MR. Mentor Sep 20 '22 at 15:29
  • No other steps. Your regex prefix does have a space at the end so it won't trigger until that space, so something like `divx.myClassName ` should trigger it. – Mark Sep 20 '22 at 22:22
  • Thank you very much, I have got it working. I forgot that space triggers it.. – MR. Mentor Sep 22 '22 at 17:06

0 Answers0