最新版 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
两个选项了,最后设置自己喜欢的快捷键即可