Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Semicolon after Autocomplete

When using autocomplete to fill in method arguments, most of the time there should be a semicolon at the end.

It seems like there must be some keyboard shortcut to put in the semicolon (and maybe a newline) at the end but I can't find it!

Thanks.

edit: Maybe the question isn't clear, when finishing an autocomplete method the cursor looks like this:

someMethod(argument1, argument2 )
                               ^ cursor here

Maybe its just because I'm not used to the macbook keyboard, or because my muscle memory wants to use "end" rather than right-arrow or command right-arrow. But since the IDE is already helping me jump around the code with tab it would be nice to be able to return and have the semicolon get added, or at least move to the right of the close paren.

like image 535
Winder Avatar asked Feb 20 '10 15:02

Winder


4 Answers

XCode supports (many) Emacs-style keyboard navigation commands. In particular, you can use ctrl-e to jump the cursor to the end of the line, where you can then place the semicolon.

like image 189
Alex Basson Avatar answered Nov 17 '22 12:11

Alex Basson


I know this behavior from eclipse. It autocompletes something then you just hit enter and then the curser is after autocopleted code and then you can type semicolon.

I just saw your question while searching something like that behavior and could not find really something, how can I achieve that.

It is really annoying to move your right hand on arrow keys while you are writing. Not exactly what you are looking for but, helps:

From the preferences of xcode I set a shortcut for "Move to Right End of Line" shift+enter. After auto completion just hit shift+enter, it is better then using arrow keys for me.

like image 38
Mert Avatar answered Nov 17 '22 11:11

Mert


One option you have in XCode 4 (tested on 4.5.2) is to bind (Preferences → Key Bindings) the "Fix Next Issue (Navigate Menu)" command to a sensible keystroke.

Note that it's locked as the control-toggled-alternate of the "Jump to Next Issue ("Navigate Menu)" command so you'll have to play with that to find something you like. Personally, I use ctrl+shift+enter for this bind.

printf("hello, world" ) => <key binding> => printf("hello, world");
                     ^                                             ^

You may also want to take a look at "Fix Previous Issue..." and "Fix All in Scope..." commands.

like image 2
Paul Fryzel Avatar answered Nov 17 '22 11:11

Paul Fryzel


You can type a semicolon and press CTRL+T to transpose the two characters.

like image 2
Stuart Carnie Avatar answered Nov 17 '22 11:11

Stuart Carnie