Is there a way to disable or modify Xcode's co

2020-03-01 08:21发布

问题:

I have unchecked both "Show arguments in pop-up list" and "Insert argument placeholders for completions" in Xcode Code Sense preferences, but when I type "else" (for example) in the editor, Xcode still dumps in a pre-formatted "else" block.

Is there a way to disable this feature entirely, or (better yet) to modify the block that Xcode inserts? The default Xcode "else" block doesn't match my coding style, so the placeholder actually hampers my productivity instead of helping.

UPDATE: I just found this question Which describes how to change the default indentation and whitespace used for code completion, so that answers the second half of my question.

UPDATE #2: Setting "Automatically Suggest" to "never", as suggested by outis effectively disables code completion entirely. I suppose what I'm looking for is a way to disable specific code completions, (like the "else" block) while keeping all of the usual completions for variable and method names.

回答1:

You can override any of the existing code completions, copy any of the .xtcmacro files from:

/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro

(you'll have to right-click on Xcode.app and say "Show Package Contents" to proceed further down the directory chain unless you are using Terminal)

into a local directory:

~/Library/Application Support/Developer/Shared/Xcode/Specifications

(You'll probably have to make the Specifications directory). Then simply go through all of the definitions in there, to eliminate an annoying completion you can take out the CompletionPrefix for any entry, or edit the code to be inserted to work how you like.

On a side note, you can put any file named .xctxtmacro and put it in that specifications directory and it will be read in, allowing you to define some very useful custom macros.



回答2:

The "Text Editing" and "Indentation" preference sections might have the settings you seek.

You can set "Automatically suggest" to "never".



回答3:

You can enable/disable code completion in Xcode using below steps:

  1. Click on Xcode menu on top-left corner
  2. Select Preferences... (Preference Pop-up appears)

  1. Select Text Editing menu
  2. See Code Completion.
  3. Uncheck Suggest completion while typing option.



回答4:

Does the information here help?

http://cocoawithlove.com/2008/06/hidden-xcode-build-debug-and-template.html