有没有办法让 Xcode 5 像 Visual Studio 一样自动完成?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5274053/
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
Is there a way to have Xcode 5 autocomplete like Visual Studio?
提问by zneak
Xcode 5 now displaced Xcode 4, and one common complaint that I had against both IDEs is that they don't autocomplete very aggressively. In Visual Studio, autocompletion is committed as soon as you hit a non-identifier key (like a parenthesis, a comma, a dot, a space, etc). On Xcode 5, you have to hit tab or enter.
Xcode 5 现在取代了 Xcode 4,我对这两个 IDE 的一个常见抱怨是它们没有非常积极地自动完成。在 Visual Studio 中,只要您按下非标识符键(如括号、逗号、点、空格等),就会立即提交自动完成。在 Xcode 5 上,您必须按 Tab 或 Enter。
Is there a known way to get a behavior closer to Visual Studio's for autocompletion?
是否有一种已知的方法可以使行为更接近 Visual Studio 的自动完成?
回答by Mahadev Kale
You can select following two options from XCode->Preferences->Text Editing:
您可以从 XCode->Preferences->Text Editing 中选择以下两个选项:
- Suggest completions while typing.
- Enable Type-over completion
- 打字时建议完成。
- 启用输入完成
回答by Marco Mirisola
In xCode the only way to autocomplete is pressing tab keyor "ctrl space" to have a list of all methods and variable starting with that char sequence. If you want, you can customize the key shortcut pressing "cmd ," and, in the section "Key Bindings", you can customize it.
在 xCode 中,自动完成的唯一方法是按Tab 键或“ ctrl space”以获取以该字符序列开头的所有方法和变量的列表。如果需要,您可以按“cmd”自定义快捷键,并且在“键绑定”部分中,您可以自定义它。
回答by Tommie C.
The following key binding options are available for code completion. I do not believe there is any way to change the underlying engine to make finding appropriate completions easier, however one could write as many code snippets as desired to quickly reuse code.
以下键绑定选项可用于代码完成。我不相信有任何方法可以更改底层引擎以更轻松地找到合适的补全,但是可以根据需要编写尽可能多的代码片段以快速重用代码。
Alternative
选择
I prefix my code snippets with my own initials followed by my own logically phrased structures. This presents a pretty useful [faux] index that let's me short-circuit the auto completion routines.
我用我自己的首字母作为我的代码片段的前缀,然后是我自己的逻辑短语结构。这提供了一个非常有用的 [faux] 索引,让我可以缩短自动完成例程。
e.g. Structure of a typical user snippet
例如典型用户片段的结构
[tnc][AddMethod][Somename]
[tnc][AddMethod][Somename]
When necessary I then start tnc... to gain access to my [faux] index of commonly used snippets.
必要时,我会启动 tnc... 以访问常用片段的 [faux] 索引。
Snippets are notautocompletion per se but they do provide an alternative index to autocomplete coding and could address the concern of finding relevant information quickly.
片段本身不是自动完成的,但它们确实提供了自动完成编码的替代索引,并且可以解决快速查找相关信息的问题。
回答by Ricardo
control+space is probably the only feature I've known. I agree xcode does not have any auto completion that I'm aware off.
control+space 可能是我所知道的唯一功能。我同意 xcode 没有任何我知道的自动完成功能。
But otherwise since visual studio keeps on getting updated most of the time. The auto completion on it works fine. At some point Xcode might add a feature like that on their future updates.
但除此之外,因为 Visual Studio 大部分时间都在不断更新。它的自动完成工作正常。在某些时候 Xcode 可能会在他们未来的更新中添加类似的功能。
回答by Daniel Gomez Rico
You can use a key shortcut to show a completion list.
您可以使用快捷键来显示完成列表。
You can press "ctrl + ," and it will show the "visual studio like and feel" list for autocomplete.
您可以按“ctrl + ,”,它将显示自动完成的“视觉工作室喜欢和感觉”列表。
回答by charleyh
Now if you start typing auto-complete will pop up. There is nothing you need to do.
EDIT
Sorry about that. Misunderstood the question. The only way to select autocomplete is by typing a tab, enter, or right arrow key. There is no way to do this in normal XCode.
现在,如果您开始键入自动完成功能将弹出。您无需执行任何操作。
编辑
很抱歉。误解了问题。选择自动完成的唯一方法是键入 Tab、Enter 或右箭头键。在普通的 XCode 中没有办法做到这一点。
回答by Stephen J
You're not listing the other problem, XCode autocompletes by alphabetical values, not compatible ones. Visual Studio actually gives you things that work, but in XCode you can shove an Int to a class or visa-versa thanks to autocomplete.
您没有列出另一个问题,XCode 按字母值自动完成,而不是兼容的值。Visual Studio 实际上为您提供了有用的东西,但在 XCode 中,由于自动完成,您可以将 Int 推送到类中,反之亦然。
The options that come closest are in XCode menu->Preferences->Text Editing. However, it doesn't have what you are after. I do notice autocompleting the brackets isn't very intelligent and I may turn mine off soon.
最接近的选项在 XCode 菜单->首选项->文本编辑中。然而,它没有你所追求的。我确实注意到自动完成括号不是很智能,我可能很快就会关闭我的。
Anyway, the XCode alternative IDE actually has contextual autocomplete, which greatly improves your ability to code without looking at the docs. Unsure what its preferences are but it may be worth looking at. I'm not trying to advertise it so I'll let you google the XCode alternative if you want to.
无论如何,XCode 替代 IDE 实际上具有上下文自动完成功能,这大大提高了您无需查看文档即可进行编码的能力。不确定它的偏好是什么,但它可能值得一看。我不是要宣传它,所以如果你愿意,我会让你谷歌 XCode 替代品。
In practice, the . and , "stopping" autocomplete actually saves me many times. For example, write for(int x = 0; x < 5; x++) {} then try to change the x to a y. Autocomplete will step in and completely throw you off, unless you hit space or . or ,. If you had aggressive autocomplete, it would shove in its nonworking alphabetical value at the top of the list.
在实践中,. 并且,“停止”自动完成实际上为我节省了很多次。例如,写 for(int x = 0; x < 5; x++) {} 然后尝试将 x 更改为 y。除非您点击空格或 . 或者 ,。如果您有积极的自动完成功能,它会将其非工作字母值推到列表的顶部。
Long story short, XCode 4 isn't separate from the rest of the mac, a nightmare when you try to go and use it. For one clear example, take a large text file in TextEdit, and scroll halfway down. Wait a second, now try to highlight half of the document. (Your scroll bar will disappear before you can do anything, for example).
长话短说,XCode 4 与 mac 的其余部分并没有分开,当你尝试去使用它时,这是一场噩梦。举一个明显的例子,在 TextEdit 中获取一个大文本文件,然后向下滚动一半。等一下,现在尝试突出显示文档的一半。(例如,您的滚动条将在您执行任何操作之前消失)。
The answer you're looking for may or may not exist, but I hoped to provide you with some alternatives that may satisfy your craving. The example at the end just shows the true nature of the tools and their UI principle.
您正在寻找的答案可能存在也可能不存在,但我希望为您提供一些可能满足您渴望的替代方案。最后的例子只是展示了这些工具的真实本质和它们的 UI 原则。
There's always Monodevelop, (not objective C, but should be more customizable), or perhaps an ide that has Objective C, if you don't mind coding in alternatives.
总是有 Monodevelop,(不是目标 C,但应该更可定制),或者可能是具有目标 C 的 ide,如果您不介意以替代方式编码。
Good luck, I wish XCode had more customizing too.
祝你好运,我希望 XCode 也有更多的自定义。
回答by Konrad77
I don't know if this works with xCode 4 though, but its worth a try http://code.google.com/p/xcode-auto-assistant/
我不知道这是否适用于 xCode 4,但值得一试 http://code.google.com/p/xcode-auto-assistant/
回答by Denshi
If you want to complete the same things every time you could use third party software like text expander for this or use Snow Leopards integrated textreplacement feature.
如果您想每次都完成相同的事情,您可以使用第三方软件(如文本扩展器)或使用 Snow Leopards 集成的文本替换功能。