xcode 在Xcode中自动插入右括号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1367517/
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
Automatically insert closing bracket in Xcode
提问by Nicolinux
is there a way to have Xcode append a closing bracket ")" when I type the opening one "("? I know that it does this for those {}. I really miss Textmate :( A generic way to define which chars should be automatically inserted when the opening ones are entered would be kickass.
有没有办法让 Xcode 在我输入开头的“(”时附加一个右括号“)”?我知道它是为那些 {} 做的。我真的很想念 Textmate :( 一种定义哪些字符应该是的通用方法输入开头的内容时自动插入会很糟糕。
回答by nevan king
Have a look under Edit->Insert Text Macro->Objective C->Bracket Expression. This will insert a matched pair of brackets (or if you have something highlighted, put brackets around it). You could bind this to [ as a keyboard shortcut.
查看编辑->插入文本宏->目标C->括号表达式。这将插入一对匹配的括号(或者如果您突出显示了某些内容,请在其周围加上括号)。您可以将此绑定到 [ 作为键盘快捷键。
You can follow the instructions here to create one for parentheses. I tried but couldn't make it work.
您可以按照此处的说明为括号创建一个。我试过了,但无法让它工作。
http://cocoawithlove.com/2008/06/hidden-xcode-build-debug-and-template.html#textmacros
http://cocoawithlove.com/2008/06/hidden-xcode-build-debug-and-template.html#textmacros
Personally, I drag the classes folder over to Textmate and edit there. I switch back to Xcode when I need to type in some long method name, or to build. I've been building a library of snippets for some of the common things I do in Textmate to make life easier there.
就个人而言,我将 classes 文件夹拖到 Textmate 并在那里进行编辑。当我需要输入一些长的方法名称或构建时,我会切换回 Xcode。我一直在为我在 Textmate 中所做的一些常见事情构建一个片段库,以使那里的生活更轻松。
回答by user151019
In Xcode 3.1 go to Preferences->Indentation Check Syntax-ware indenting to on and check Automatically insert closing "}"
在 Xcode 3.1 中转到 Preferences->Indentation Check Syntax-ware indenting to on 并检查 Automatically insert closed "}"
and choose the characters you want to be inserted when the opening one is.
并选择要在开场时插入的字符。
Also why not use Textmate nothing stops you and Xcode will notice if a file is edited externally
另外,为什么不使用 Textmate 没有什么可以阻止您,Xcode 会注意到是否在外部编辑文件