When I press Command+X in Xcode 5, I want the key binding to act differently based on two circumstances.
If there is a selection made, copy the selection, then delete it. This behavior already exists in Xcode.
If there is NO selection made, copy the current line (a.k.a. the paragraph), then delete it.
Is a conditional key binding like that possible to do in Xcode?
I've read through this article on adding key bindings to Xcode 5. The only problem I'm having is the conditional aspect of such a key binding. Thanks for any help.
Related
I would like to use Xcode editor instead of others for swift typing but I am missing basic functionality of deleting whitespace backward.
Normally in the world of code editors, you just press option + backspace or something similar and thats it, it deletes whitespace just until next character starts, eating new line in the way as everyone needs.
But xCode is doing some wired unusable staff and is deleting not just whitespace and new line, but also part of text on previous line, until it considers some character start of word, basically making it unusable.
I don't need to know how to use "Delete subword backward" !
All key bindings can be edited in Xcode -> Preferences -> Key Bindings.
By default the combination you're interested in is assigned to something like Delete Subword Forward. Just remove the combination from the action that you don't need and add it to the action called Delete Forward (or whatever action you're looking for, it's not very clear).
To add a key binding you double click on existing Key value, click +, press Option+Backspace, click somewhere outside the field to save new value.
In most key bindings a small minus sign appears on the right to remove the binding, but with Jump to Next/Previous Counterpart it seems it is not possible to clear that one.
I want to use that key binding for a different command and I can't do it without removing it first.
When trying to delete those a small error message appears that says:
Can't delete the keyboard shortcut because it has alternate menu items
Any idea on how to get rid of those shortcuts?
How do I switch between the header and implementation file in Xcode 4?
In XCode 3 it was cmd and right or left (I think)
Ctrl+Cmd+Up or Down, but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why.
Be sure to FIRST click ON the actual code window...
that's the critical tip to ensure it works. Click anywhere at all on the actual code. (If you're active in one of the other many panes of Xcode, the keystroke combo has no, or different, meaning(s).)
Also, you can 3 finger swipe up and down on the touchpad if you have one.
Ctrl+Cmd+Up or Down
The shortcut sometimes stops working!!
The menu option has moved to "Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart".
In preferences the key binding is now under "Jump to Next Counterpart" and "Jump to Previous Counterpart".
Why Apple insist on changing the menu positions AND names of these things is beyond me! I mean "Counterpart"!?
Worth nothing that Ctrl+Cmd+Left or Right move between previous and next files that were viewed (I mean "counterparts") too. These are also under the key bindings "Jump to Next Counterpart" & "Jump to Previous Counterpart").
The reason the menu option has been split between:
"Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart"
is because you can have more than just one header file and one source file with the same file name. Besides having matching .xib files for view controllers, I have separate .vsh and .fsh files for vertex and fragment shaders in my OpenGL program. Along with my .h and .cpp files that's a list of 4 files that I can navigate up or down through with one key binding, instead of hitting the same key binding 3 times in a row to cycle back from file 2 to file 1.
Also in Xcode 6.1/7.1 shortucts are the same:
Jump to next counterpart:
Ctrl+Cmd+Up
Jum to previous counterpart:
Ctrl+Cmd+Down
Personally, coming from eclipse, I change this shortcut with:
Ctrl+Tab
this combination insn't already binded to anything else.
Xcode -> Preferences -> Key Bindings
search for "Jump to next counterpart" and put the new keys combination.
PRO
This is more efficient than default bindings see that you can use one hand instead of two!
"but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why."
Sometimes Xcode loses track of which .m and .h belong together. This is e.g. the case
when you open one of the files directly from the Finder. When you open the file from
the file list in Xcode, it normally works okay. Although when you have moved files between
folders & groups in the file list of Xcode, it will also list the relation between the files.
The command to swap between m and h files is CTL-CMD-up/down. It sometimes get stuck. To unstick it simply save the file, i.e. CMD-S, and the hotkey should work again.
In most multi-document editors for windowing environments, Control-TAB will utilize an MRU list to bring the user back to the last visible file. What is the appropriate command to accomplish this in Xcode 3.x?
I currently have Ctrl-TAB mapped to "View|Previous File", however this does not appear to be an MRU. Worse yet, if it hits the "beginning" of the list (should be a circular buffer), it falls back on inserting an actual TAB character into the text editor.
As of Xcode Version 3, there isn't anything that's exactly like the MRU you describe - however, check out the discussion on this page for some options that will get you closer to the behavior you want.
In recent XCode (10.3), when in a code editor press:
ctrl+1, right, right
Then use up and down keys and enter
to select from the MRU sorted list of recent files.
There is even an option to increase the size of the history.
In Xcode 3 (or any Mac application) you can use Command-Tilde (⌘~) to switch between open windows.
In Xcode 4 you use ⌘} for next tab and ⌘{ for previous tab - command shift bracket.
As a side note, for some reason Xcode 4 won't let me set the key binding for previous/next tab to the standard Control-Tab. When I try it puts in Command-Control-Tab.
In Preferences->Key Bindings->Text Key Bindings Xcode has a "Change Case of Letter" key binding. However, when I assign a shortcut to this binding and then attempt to utilize it to swap the case of a letter in one of my source code files, it doesn't seem to do anything.
I've tried positioning the cursor before and after the letter, and tried selecting the letter before triggering the assigned shortcut. Nothing seems to do anything.
Does anybody know what I might be doing wrong?
That had been a general AppKit text function, but was apparently removed several years ago. I'll update Xcode's text bindings to reflect it.
Instead, write a user script:
(source: mac.com)
and assign it whatever shortcut you want.