Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

xcode4 - Xcode duplicate line

There is a Duplicate command in the Edit Menu (with a default shortcut of ?D), but it is (as Halley pointed out) meant for duplication in the Interface Builder part of Xcode.

So, how do you (easily) duplicate a line in Xcode 4?


Related question (with a working answer) for Xcode 3 ... and which does not work for Xcode 4.


Why not just copy & paste?

Because it is tedious and entails too much hand-acrobatics:

either (1): moving to line beginning and then pressing ?^E, then copying with ?C, moving to new line, alligning cursor, and finally pasting with ?V;

or (2): ^A (set cursor to line begining), ^SPACE (set mark), ^E (set cursor to line ending), ?^W (Select to Mark; customized), copy, new line, etc.

As Frank Schr?der (in the related question) put it:

The whole point is NOT to use the Cmd-C/Cmd-V shortcuts.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Go to this folder which contains dark side of the force:

    • Xcode 4.2 or prior: /Developer/Library/PrivateFrameworks/IDEKit.framework/Resources
    • Xcode 4.3 or later: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources.
  2. Open IDETextKeyBindingSet.plist.

  3. Add a new dictionary and a new command item as the screenshot below (name them what you want): Editing the plist

    That's: selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:

  4. Restart Xcode and go to Preferences - Key Bindings, search for your command.

  5. Set a key combination for the command: Key Bindings

  6. Finally unleashed the power of key bindings on Xcode... Enjoy it!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...