Xcode
Assign some key combinations to the Scroll Line Up and Scroll Line Down actions:

Then install KeyRemap4MacBook and save a file like this as ~/Library/Application Support/KeyRemap4MacBook/private.xml
:
<?xml version="1.0"?>
<root>
<appdef>
<appname>XCODE</appname>
<equal>com.apple.dt.Xcode</equal>
</appdef>
<item>
<name>xcodearrows</name>
<identifier>xcodearrows</identifier>
<only>XCODE</only>
<autogen>__KeyToKey__ KeyCode::CURSOR_UP, VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_UP, KeyCode::PAGEUP, ModifierFlag::CONTROL_L | ModifierFlag::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::CURSOR_DOWN, VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_DOWN, KeyCode::PAGEDOWN, ModifierFlag::CONTROL_L | ModifierFlag::OPTION_L</autogen>
</item>
</root>
Then open the KeyRemap4MacBook application, press the ReloadXML button, and enable the setting.
Other applications
Create ~/Library/KeyBindings/
and save a property list like this like this as ~/Library/KeyBindings/DefaultKeyBinding.dict
:
{
"~\UF700" = (moveUp:, scrollLineUp:); // option-up
"~\UF701" = (moveDown:, scrollLineDown:); // option-down
}
Then quit and reopen applications to apply the changes.
DefaultKeyBinding.dict
stopped working in Xcode 4. See https://stackoverflow.com/questions/5626788/custom-key-bindings-xcode-4.
This would make option-up and option-down scroll eight lines and center the view around the caret:
{
"~\UF700" = (moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp:, moveUp, moveUp, centerSelectionInVisibleArea:);
"~\UF701" = (moveDown:, moveDown:, moveDown:, moveDown:, moveDown:, moveDown:, moveDown, moveDown, centerSelectionInVisibleArea:);
"~$\UF700" = (moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection:, moveUpAndModifySelection, moveUpAndModifySelection);
"~$\UF701" = (moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection:, moveDownAndModifySelection, moveDownAndModifySelection);
}