Is there a way to get Xcode 4 to indent text so that pressing tab on selected text would indent it, shift + tab would unindent like in many editors?
The default ⌘] and ⌘[ do not seem to work, probably because I have a Finnish keyboard layout. Pressing the key combination for [ (alt + 8) and additionally holding down ⌘ does not indent.
In Xcode preferences I found "Key Bindings" and "Shift Right", "Shift Left", but it does not seem to understand shift + tab. If I try to press shift + tab I get ⇧⌘⇤.
How do you indent many lines of code? If you prefer using [spacebar] to indent your code rather than using [tab], you can select multiple lines by holding the [alt] key and clicking on the beginning of each line you want to indent. Then, you can press [spacebar] and all the selected lines will be affected.
As a workaround if you can't enter shift-tab, you could find the key binding (stored at ~/Library/Developer/Xcode/UserData/KeyBindings
and modify it directly. It's XML so you should be able to do this without too much trouble.
Setting the Tab binding for Shift Right did not work for me either even when remapping "Insert Tab" to something else (seems hardcoded/bug). However I did get Alt + Tab and Shift + Alt + Tab binding working (with the Finnish Keyboard layout, didn't test extended or sami). I still had to remap "Insert Tab without Extra Action" from Alt + Tab to Alt + Ctrl + Tab, you could avoid this by using Ctrl instead of Alt for shifting.
Here is the xml file for it.
cd ~/Library/Developer/Xcode/UserData/KeyBindings
vi Default.idekeybindings
(probably empty plist, if not extend appropriately)
Paste:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Menu Key Bindings</key>
<dict>
<key>Key Bindings</key>
<array>
<dict>
<key>Action</key>
<string>shiftRight:</string>
<key>Alternate</key>
<string>NO</string>
<key>CommandID</key>
<string>Xcode.IDESourceEditor.CmdDefinition.ShiftRight</string>
<key>Group</key>
<string>Editor Menu for Source Code</string>
<key>GroupID</key>
<string>Xcode.IDESourceEditor.MenuDefinition.Editor</string>
<key>GroupedAlternate</key>
<string>NO</string>
<key>Keyboard Shortcut</key>
<string>~ </string>
<key>Navigation</key>
<string>NO</string>
<key>Parent Title</key>
<string>Structure</string>
<key>Title</key>
<string>Shift Right</string>
</dict>
<dict>
<key>Action</key>
<string>shiftLeft:</string>
<key>Alternate</key>
<string>NO</string>
<key>CommandID</key>
<string>Xcode.IDESourceEditor.CmdDefinition.ShiftLeft</string>
<key>Group</key>
<string>Editor Menu for Source Code</string>
<key>GroupID</key>
<string>Xcode.IDESourceEditor.MenuDefinition.Editor</string>
<key>GroupedAlternate</key>
<string>NO</string>
<key>Keyboard Shortcut</key>
<string>~$</string>
<key>Navigation</key>
<string>NO</string>
<key>Parent Title</key>
<string>Structure</string>
<key>Title</key>
<string>Shift Left</string>
</dict>
</array>
<key>Version</key>
<integer>3</integer>
</dict>
<key>Text Key Bindings</key>
<dict>
<key>Key Bindings</key>
<dict>
<key>^~ </key>
<string>insertTabIgnoringFieldEditor:</string>
</dict>
<key>Version</key>
<integer>3</integer>
</dict>
</dict>
</plist>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With