简体   繁体   English

是否有 VSCode 快捷方式将文本包装在 react/react-native 片段中?

[英]Is there a VSCode shortcut to wrap text in a react/react-native fragment?

我发现自己经常使用片段,并希望使用键盘快捷键来使其更容易。

Add this to keybindings.json将此添加到keybindings.json

{
    "key": "ctrl+k f", // 👈 whatever binding you want. obv.
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "snippet": "<$1>${TM_SELECTED_TEXT}</$1>"
    }
}

Bonus... the cursor is in position to enter the name of any other component if desired.奖励...如果需要,光标可以输入任何其他组件的名称。

  1. Select the element you want to wrap选择要包装的元素
  2. You could press command + P in mac, or Ctrl + P on Windows您可以在 mac 中按command + P ,在 Windows 中按 Ctrl + P
  3. Then you will see the following search bar:然后您将看到以下搜索栏:

在此处输入图像描述

  1. Write the following:写下以下内容:

    >Emmet >艾美特

  2. Select this option:选择此选项:

在此处输入图像描述

  1. Then write Fragment and click enter:然后写Fragment并点击回车:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM