直到Xcode 8.0,才有可能自定义IDETextKeyBindingSet.plist文件。但是,现在看来修改此文件会导致Xcode停止正常运行(例如箭头键停止工作),并且似乎无法再创建自己的快捷键。
Xcode从未有过行重复和插入快捷方式。以前可以通过在正确的位置添加以下内容将它们添加到IDETextKeyBindingSet.plist中:
<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>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>Delete Current Line</key>
<string>selectLine:, delete:</string>
<string>selectLine:, delete:</string>
有人知道如何在Xcode 8.0或更高版本中实现相同的目标吗?
我想知道Apple的开发人员是否使用Xcode?如果他们检查StackOverflow?或者他们的雇佣合同是否被禁止?
编辑:在Xcode 9.x中它似乎再次运作。
编辑:在Xcode 10.0中,它再次被破坏。
编辑:在Xcode 10.1中它仍然被破坏,复制/粘贴也被部分破坏,这意味着它并不总是有效。 (我还在High Sierra)
答案 0 :(得分:29)
确认,仍然在macOS Mojave 10.14.2上的 Xcode 10.1 中工作
针对 Xcode 9.2 及更新版本进行了更新,感谢max
添加以下行
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <sys/time.h>
using namespace std;
int main() {
POINT p;
POINT coords[4];
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
printf("Move cursor to following tiles and press enter to select the coordinates:\n\n");
for(int i = 0; i < 4; i++) {
printf("%i. tile:", (i+1));
getchar();
GetCursorPos(&p);
coords[i] = p;
printf("- X: %d, Y: %d\n\n", p.x, p.y);
}
COLORREF currColor;
HDC dc = GetDC(NULL);
while(true) {
if(GetAsyncKeyState(VK_ESCAPE)) {
printf("\rPaused, press ENTER to continue ...");
getchar();
printf("Continue ...\n\n");
}
bool countFound = 0;
for(int i = 0; i < 4; i++) {
COLORREF color = GetPixel(dc, coords[i].x, coords[i].y);
if(color <= 3000000) {
printf("\r");
for(int j = 0; j < i; j++) {
printf("[ ] ");
}
printf("[X] ");
for(int j = 0; j < (3-i); j++) {
printf("[ ] ");
}
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
SetCursorPos(coords[i].x, coords[i].y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
if(color > 100000) {
Sleep(50);
} else {
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
}
}
}
ReleaseDC(NULL, dc);
return 0;
}
进入
的根词典<key>Sublime Commands</key>
<dict>
<key>Cut Current Line</key>
<string>selectLine:, cut:</string>
<key>Copy Current Line</key>
<string>selectLine:, copy:</string>
<key>Duplicate Current Line</key>
<string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
</dict>
重新启动Xcode后,您可以进入/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist
设置并为新的三个命令指定所需的任何快捷方式。只需搜索他们的Key Bindings
。
令人遗憾的是,在21世纪,您仍然需要手动添加这些基本快捷方式。
答案 1 :(得分:8)
上述答案似乎在Xcode 9中被打破了。
以下是我已验证的另一种解决方案在Xcode 9 GM中的作用:
<key>Custom Commands</key>
<dict>
<key>Duplicate Current Line</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
</dict>
答案 2 :(得分:3)
当我尝试时,上一个答案留下了错误的空白。这在Xcode 9中适用于我:
selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine: