我正在尝试向Xcode 6添加一组自定义键绑定。我在过去的帖子中查找并发现要执行此操作,您需要编辑位于 Xcode中的Default.idekeybindings文件 - > UserData - > KeyBindings - > Default.ideakeybindings
我根据以前版本中的方式编辑了这个,但是当我进入首选项 - > Xcode中的键绑定我无法找到我定义的自定义操作。理想情况下,我想在使用Sublime和Atom时制作一键“复制线”,“剪切线”,“重复线”以及其他一些有用的键绑定。我已将我的.ideakeybindings编辑的文件内容包含在下面,以供参考我正在尝试做的事情。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>My Custom Actions</key>
<dict>
<key>Delete Current Line/Selection</key>
<string>deleteToEndOfLine:, deleteToBeginningOfParagraph:</string>
<key>Duplicate Line</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:</string>
</dict>
</dict>
</plist>
答案 0 :(得分:7)
我是在Xcode 7上做到的:
我添加了这一部分:
<key>My Custom Commands</key>
<dict>
<key>Insert New Line Below</key>
<string>moveToEndOfLine:, insertNewline:</string>
<key>Insert New Line Above</key>
<string>moveUp:, moveToEndOfLine:, insertNewline:</string>
<key>Duplicate Current Line</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
<key>Delete Current Line</key>
<string>selectLine:, delete:</string>
<key>Cut Current Line</key>
<string>selectLine:, cut:</string>
<key>Copy Current Line</key>
<string>setMark:, selectLine:, copy:, moveToEndOfLine:, swapWithMark:</string>
<key>Paste At Beginning Of Line</key>
<string>moveToBeginningOfLine:, paste:</string>
</dict>
每次安装新版本的Xcode时都会被覆盖,如果有人知道在用户目录中将它们添加到何处,那么自定义命令的用户设置位置将非常受欢迎。
答案 1 :(得分:3)
我多年来一直在使用以下内容,因为我来自Eclipse阵营并喜欢&#34;重复当前阵容&#34;和&#34;重复当前线路下行&#34;非常。 注意&#34; Xcode.app&#34;可能是&#34; Xcode62.app&#34;或&#34; Xcode63.app&#34;取决于你如何重命名它。
sudo vim /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
<key>Customized</key>
<dict>
<key>Duplicate Current Line Up</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:, moveUp:</string>
<key>Duplicate Current Line Down</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
<key>Delete Current Line</key>
<string>deleteToBeginningOfLine:, moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToBeginningOfLine:</string>
</dict>
重启Xcode |偏好|关键绑定|所有
搜索&#34;复制&#34;
搜索&#34;当前&#34;
然后输入您喜欢的快捷键绑定。
我从原来的海报中学到了很多东西。它适用于Xcode 6.3最新测试版,Xcode 6.2,6.1和之前的Xcode版本。