代码之家  ›  专栏  ›  技术社区  ›  Luca Davanzo

Xcode:在单个快捷方式中缩进代码

  •  5
  • Luca Davanzo  · 技术社区  · 8 年前

    我在Swift 2.2中使用Xcode 7.3。

    关键是我对“跑步”已经厌倦了:

    命令 +A类
    Ctrl键 +我

    为了缩进整个代码。

    因此,我认为我很快就能找到解决方案,在 IDE文本键绑定集.plist .

    <key>My Custom Shortcuts</key>
    <dict> 
        <key>Indent Code In One Hit</key>
        <string>selectAll:, ....., moveLeft:</string>
    </dict>
    

    我已经做了很多测试,用各种命令替换“…..”(组合 this ),但我还没有找到解决方案。

    感谢您的任何帮助!

    3 回复  |  直到 8 年前
        1
  •  3
  •   Luca Davanzo    8 年前

    最后,我自己找到了一个解决方案,没有安装任何未经验证的插件。
    我认为这可能是其他性能更高的解决方案。

    1. 关闭Xcode
    2. 编辑 IDE文本键绑定集

      sudo nano /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
      

      添加此:

      <key>My Custom Shortcuts</key>
      <dict> 
           <key>Custom - Indent Code In One Hit</key>
           <string>selectAll:, cut:, paste:</string>
      </dict>
      
    3. 打开Xcode, 命令 + ; 打开首选项
    4. 键绑定和按“自定义”筛选
    5. 为您指定最喜爱的键绑定。

    enter image description here

    1. 退出首选项,激活代码,尝试新的快捷方式,感受力量!
        2
  •  1
  •   Quang Dam    8 年前

    我想你应该试试 this 。它可以帮助您在每次Cmd+S时重新缩进代码

        3
  •  0
  •   Ian Pilipski    8 年前

    “Command+]”将缩进所有突出显示的代码。