When committing files to an SCM in Xcode it brings up its Version Editor with a Comparison View (showing the diffs for each file). If you click in the gutter between files you can quickly navigate between changes using the up & down arrow keys. However, you can't easily move to the next file using the keyboard (as far as I know). It's very tedious to have to use the mouse to click on each file, then click in the gutter, use the keyboard to move between changes and then click on the next file.
Does anyone know of a way to navigate between files in this view using just the keyboard?
I've done some searching & looked through Xcode's Key Bindings preferences but I can't find anything.
It's a bit clunky, but you can press Cmd-Shift-J to go to the current file in the Project navigator, then use the up and down arrows to select different files. From there you can press Cmd-J, Return to put the cursor into the editor view.
Related
What I really like with a text editor (or IDE) is to be able to easily remap its keyboard shortcuts to what I want, and Xcode seems to do a bad job with this.
I want to be able to switch file tabs by using option + command + arrow (left and right arrows). However, when I try to change keyboard shortcuts for the Show Previous Tab and Show Next Tab actions, the option key is not applied.
In the screenshot, you can see—through KeyCastr—how I pressed the option + command + right arrow keys and end up with command + right arrow in Xcode, the option key is missing.
Is there any solution? Note that the option key can be used on some actions, for example I can use it with the About Xcode action, but this is obviously not what I want.
I'm using Xcode 13.4.1.
Okay so I've found a solution. Not a perfect one but it works!
There is no way to use the option key in some actions because they are constrained by the Navigation in Xcode preferences.
Instead you can change the system preferences to add a new shortcut to the Xcode app.
However, when you will use those keyboard shortcuts in Xcode, you will see a weird behavior where the tab you are switching to, gets opened in a new editor.
This is due to the default navigation preferences of Xcode, change the "Optional Navigation" preference from "Uses Next Editor" to "Uses Tab".
In macOS vscode, when I close a file that has some changes made to it, I get a dialog on top. How do i navigate the buttons here with just my keyboard?
The screenshot doesn't show it but it defaults to the Save button.
I don't know if VS Code follows normal Mac conventions but, if it does, Return should select the default button (Save, presumably); Escape should cancel; and Command-D or possibly Command-Delete should select Don't Save.
Also, if you have System Preferences > Keyboard > Shortcuts > Full Keyboard Access set to "All controls", the Tab key should move focus among the buttons and Space will press the one with focus. If you don't normally have that set that way, Control-F7 will toggle it on.
So, after struggling with horrible interface choices of Xcode 4, I'm finally on 5.1.1.
The tabs became almost usable. Double clicking can be configured to open a file in a new tab. Good. Double clicking another file opens it in a new tab. Good. Double clicking first file again switches to previously open tab. Good! Double clicking first file while it is open in current tab opens a second tab with that file. Ok, I can live with that, since from there on they just switch from one to another.
So far a surprisingly sane behavior.
Unless you make a single click in the navigation panel by mistake. Single click opens whatever you click in the current tab, all logic and reason be damned.
The question is, how to change single click behavior to "Use separate tab" (or however Xcode refers to that behavior)?
Is there any way to disable single clicks from doing anything at all aside from highlighting the selection?
There's no option to disable the single-click behavior. Two options that get you close to your desired behavior are:
Use a single separate window for most of your tabs. Use a "main" window that has the file navigator visible, and a separate "work" window with the file navigator hidden. If you want to add a tab to the work window, create it in the main window and then drag it's tab over to the work window. This is an extra step, but you'll never have a single click change any of the tabs that you care about (thought it'll still change the primary or focussed editor in the main window, depending on your settings).
Use separate windows for each file. There's a preference setting that lets you create windows instead of tabs when you double-click a file in the file navigator. Use Mission Control instead of the tab bar to navigate between your files.
In Xcode, I am big fan of the assitant editor that shows me the corresponding .h or .m for the file that I am editing.
Is there a shortcut that allows me to swap focus between this two windows? I frequently switch between the two and using the mouse every time is annoying.
New answer:
Move Focus To Editor — commandj followed by ←/↑/↓/→ and return
This goes nicely together with commandshiftj which is Reveal in Project Navigator.
Old answer:
Use optioncommand` keyboard shortcut.
It can be remapped in Preferences - Keyboard Bindings - Move Focus To Next Area.
Edit: Removed XVim recommendation.
#Oneiros: Not quite what the OP was asking for..
I don't know of a 'short' shortcut but there's Cmd-J showing a popup where you can choose what to focus.
I made this to help answer another question... Does it help?
Xcode 8+
This is the easiest option:
^` - Move Focus to Next Editor
When using multiple assistant editors, ⇧^` moves focus to previous editor.
Xcode 4+
⌥⌘` - Move Focus to Next Area
⇧⌥⌘` - Move Focus to Previous Area
Using this option you can switch between Project Navigator (left pane), Primary Editor, Assistant Editors, Utility Area (right pane), Debug Area, etc.
⌘J - Move Focus to Editor...
Using this option you can choose where to move the focus using graphical navigation chooser.
For Xcode 4.4:
Use Cmd+Option+` (left to number 1) to Move Focus to Next Area, and use Cmd+Option+Shift+` to Move Focus to Previous Area
For Xcode 4.3:
If you only have the Editor and Assistant open, use Cmd+Option+. to switch between them (Navigator>Move Focus to next area)
Also, if you want to open a different file in the right pane, like the .xib or any other, press
Command ⌘shift ⇧o
The open quickly window will appear, search the file, use capital letters to filter through camel case notation, then press
Alt ⌥enter ↵
The file will be opened in the assistant window
Switching between .h and .m:
Control ^Command ⌘Up Arrow ↑
You can do this:
Assume you have Standart(S) and Assistance(A) editor opened and you want swap them.
1) Double tap with holded Alt to line in navigation bar of S editor with file name (look screenshot). This file will open in A editor.
2) In A editor tap Go Back and do 1. File from A editor will be opened in S editor.
3) In A editor tap Go Forward.
DONE!
When coding in Xcode, I double-click a file in the "Groups and files" list, and it opens a new editor window. I have several of these open at once.
Until today.
Today, when I double-click a file in the list, it opens the file in the last editor window I was using, meaning I can only have one editor window up at any one time.
I guess I've switched some option somewhere by mistake. How do I get it back to the way I like it?
I'm using Xcode 3.2.5
In the top right of the editing window is an icon that says "grouped", perhaps you clicked on it by accident.
Click on it so it says "ungrouped", and you'll be back to opening multiple windows.
perhaps preferences>General>Open Counterpart in same Editor