在VS代码中创建摘要时,如何更改TM_FILENAME_BASE?

发布于 2025-01-26 21:56:51 字数 420 浏览 6 评论 0原文

我有一个名为的文件“ card.styled.js”

我想创建一个摘要来编写更轻松的样式组件:

"styled": {
  "prefix": "styled",
  "body": [
    "import styled from \"styled-components\"",
    "",
    "export const ${1:${TM_FILENAME_BASE}} = styled.$2`",
    "",
    "${3}",
    "`"
  ]
}

但是$ {1:$ {$ {TM_FILENAME_BASE}}}是返回我card.Styled

在这种情况下,我只想返回card

I have a file named "Card.styled.js"

I want to create a snippet to write easier the styled component:

"styled": {
  "prefix": "styled",
  "body": [
    "import styled from \"styled-components\"",
    "",
    "export const ${1:${TM_FILENAME_BASE}} = styled.$2`",
    "",
    "${3}",
    "`"
  ]
}

But ${1:${TM_FILENAME_BASE}} is returning me Card.styled.

I want to return only Card in this case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猛虎独行 2025-02-02 21:56:51

card.Styledcard.styled.js的正确TM_FILENAME_BASE。您将不得不进一步修改它。

您想要这样的东西:

  "styled": {
    "prefix": "styled",
    "body": [
      "import styled from \"styled-components\"",
      "",
      "export const ${1:${TM_FILENAME_BASE/(.*?)\\..*/$1/}} = styled.$2`",
      "",
      "${3}",
      "`"
    ]  
  } 

(。*?)\\ ..*在第一个中获取所有内容,进入捕获组1

匹配整个FILENAME_BASE,并仅用捕获替换它第1组。

Card.styled is the correct TM_FILENAME_BASE of Card.styled.js. You will have to modify it further.

You want something like this:

  "styled": {
    "prefix": "styled",
    "body": [
      "import styled from \"styled-components\"",
      "",
      "export const ${1:${TM_FILENAME_BASE/(.*?)\\..*/$1/}} = styled.$2`",
      "",
      "${3}",
      "`"
    ]  
  } 

(.*?)\\..* get everything before the first . into capture group 1

Match the entire filename_base and replace it with only capture group 1 .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文