Xcode 重复/删除行 [英] Xcode duplicate/delete line

查看:14
本文介绍了Xcode 重复/删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 Eclipse 并且一直习惯于重复行,很奇怪发现 Xcode 没有这样的功能.还是这样?

Coming from Eclipse and having been used to duplicate lines all the time, it's pretty strange finding out that Xcode has no such function. Or does it?

我知道可以更改系统范围的键绑定,但这不是我想要的.

I know it's possible to change the system wide keybindings but that's not what I'm after.

推荐答案

重点是不要使用 Cmd-C/Cmd-V 快捷键.我有来自 IntelliJ 的相同问题,并且能够使用 Cmd-D 复制行并使用 Cmd-Y 删除它们可以节省大量时间.

The whole point is NOT to use the Cmd-C/Cmd-V shortcuts. I have the same issue coming from IntelliJ, and being able to just duplicate lines with Cmd-D and delete them with Cmd-Y is a big time saver.

从那以后它就一直困扰着我.但是,看起来其他人已经找到了一个可行的解决方案.

It's been bugging me ever since. However, it looks like someone else has found a solution that works.

简而言之,创建一个文件~/Library/KeyBindings/PBKeyBinding.dict,内容如下,然后重启Xcode.

In short, create a file ~/Library/KeyBindings/PBKeyBinding.dict with the following content and restart Xcode.

{
    "^$K" = (
        "selectLine:",
        "cut:"
    );

    "^$D" = (
        "selectLine:",
        "copy:",
        "moveToEndOfLine:",
        "insertNewline:",
        "paste:",
        "deleteBackward:"
    );
}

这将创建两个快捷键:Ctrl-Shift-K 用于删除当前行和Ctrl-Shift-D 用于复制当前行.请注意,这在您使用 Xcode 中设置的自定义键绑定时才有效.切换到XCode Default",一切都会正常.在 Snow Leopard 上在 XCode 3.2 上测试.

This will create two shortcuts: Ctrl-Shift-K for deleting the current line and Ctrl-Shift-D for duplicating the current line. Please note that this will only work if you are NOT using a custom key binding set in Xcode. Switch to "XCode Default" and things should work. Tested on XCode 3.2 on Snow Leopard.

有关 Mac OS X 键绑定的更多信息:http://funkworks.blogspot.it/2013/03/republishing-of-wwwerasetotheleftcompos.html

More information on Mac OS X key bindings: http://funkworks.blogspot.it/2013/03/republishing-of-wwwerasetotheleftcompos.html

这篇关于Xcode 重复/删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆