在 Xcode 中删除用户代码片段

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5923513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:58:57  来源:igfitidea点击:

Delete a User Code Snippet in Xcode

xcodecode-snippets

提问by

How ??? I can not delete a custom code snippet in Xcode.

如何 ???我无法删除 Xcode 中的自定义代码片段。

回答by

I did these steps :

我做了这些步骤:

  • Select needed code snippet and press Delete key.
  • A pop-up window will appear , and select Delete button.
  • Remember that : this action cannot be undone.
  • 选择所需的代码片段,然后按 Delete 键。
  • 将出现一个弹出窗口,然后选择删除按钮。
  • 请记住:此操作无法撤消。

回答by alyoka

In the Library select the code snippet you want to delete and press Backspace. A confirm dialog will show up, click "Delete".

在库中选择要删除的代码片段,然后按 Backspace。将出现确认对话框,单击“删除”。

回答by McCygnus

Good question, I haven't found a way to do it from within Xcode, but they can be deleted from the Finder. The snippets are stored at ~/Library/Developer/Xcode/UserData/CodeSnippets/. Each one is a separate file that you can delete. Unfortunately they're named with an ID and don't give an indication of which one is which. They're XML files though, so you can open them up in your favorite text editor to check. Also, I've had to restart Xcode in order to get the deleted snippets to no longer show up.

好问题,我还没有找到在 Xcode 中执行此操作的方法,但是可以从 Finder 中删除它们。代码片段存储在 ~/Library/Developer/Xcode/UserData/CodeSnippets/。每个都是一个单独的文件,您可以删除。不幸的是,它们以 ID 命名,并且没有指明哪个是哪个。不过,它们是 XML 文件,因此您可以在您喜欢的文本编辑器中打开它们进行检查。此外,我不得不重新启动 Xcode 以使已删除的片段不再显示。

If anyone has a way to do it from within Xcode4 I'd love to hear it. This way is a bit of a pain.

如果有人有办法从 Xcode4 中做到这一点,我很乐意听到。这种方式有点痛苦。

回答by jamone

I was having trouble, and after messing around a bit it finally worked. You select the user snip and hit the delete key. I tried this multiple times but it didn't work initially. This may be due to me running a prerelease version of Xcode though.

我遇到了麻烦,经过一番折腾,终于奏效了。您选择用户剪辑并按删除键。我尝试了多次,但最初不起作用。这可能是因为我运行的是 Xcode 的预发布版本。

回答by Soheil Novinfard

  1. In Xcode 10, select snippet from snippet pop-up dialog.

  2. Then press Shift+?

  3. After that just confirm your removal.

  1. 在 Xcode 10 中,从代码段弹出对话框中选择代码段。

  2. 然后按Shift+?

  3. 之后,只需确认您的删除。

Note: This process cannot be undo at this moment.

注意:此过程目前无法撤消。

回答by Paul Bruneau

I was trying forever to delete the useless (to me) C++ ones, but apparently you can only delete the user-created ones in Xcode 10. Bummer.

我一直试图删除无用的(对我来说)C++ 的,但显然你只能在 Xcode 10 中删除用户创建的。无赖。

回答by Olha Pavliuk

User-created code snippets are located in ~/Library/Developer/Xcode/UserData/CodeSnippets.

用户创建的代码片段位于 ~/Library/Developer/Xcode/UserData/CodeSnippets.

If your XCode UI for deletings snippets doesn't work as in my Xcode 10.2.1, you can navigate to this folder and either delete all user snippets with rm *or use some kind of cat/grepto find the ones you want to delete.

如果用于删除代码段的 XCode UI 与我的 Xcode 10.2.1 中的不同,您可以导航到此文件夹并使用 / 删除所有用户代码段rm *或使用某种cat/grep查找要删除的代码段。

回答by Shaniraaj

In xcode select the code snippet Delete title and shortcut and save it after that select the same and press delete a confirmation box pops up asking you to delete or cancel the code snippet.

在 xcode 中选择代码片段删除标题和快捷方式并保存,然后选择相同的并按删除弹出确认框,要求您删除或取消代码片段。