最新版 Xcode 已默认支持
Delete Line和Duplicate
借鉴文章:高效开发iOS系列 -- 为Xcode添加删除行、复制行快捷键
修改权限
修改Xcode里快捷键的配置文件(plist)权限,打开终端输入如下两条命令:
sudo chmod 666 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
sudo chmod 777 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/
打开plist 文件
open /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
删除整行
然后找到root下的Deletions,在Deletions下添加一个key:Delete Current Line值为:
deleteToBeginningOfLine:, moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:
复制整行和在下方添加一行
在Insertions and Indentations下添加两个key:
-
Duplicate Current Line值为:selectLine:, copy:, moveLeft:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward: -
Insert Line Under值为:moveToEndOfLine:, insertNewline:
设置快捷键
重启一下Xcode,然后在preferences里找到Key Bindings,就能找到Delete Current Line和Duplicate Current Line两个选项了,最后设置自己喜欢的快捷键即可

plist文件

设置快捷键

设置快捷键