I would like to quickly swap two views from one side to the other and wonder if there is a hotkey for this functionality?
Single Assistant Editor
This can be done in two steps. You can start with the cursor in either the Primary or the Assistant editor.
Step 1:
⌥⌘, - Open in Assistant / Primary Editor
It opens the current file (where the cursor is) in Primary Editor if you are in Assistant Editor and vice versa. You end up with two exact same files open.
Step 2:
^` - Move Focus to Next Editor (available since Xcode 8, in older version use ⌘J)
^⌥⌘← - Go Back (and open the result) in Primary / Assistant Editor
This opens the previous file of the other editor in the first one.
Idea: It might be even possible to assign a custom shortcut to it using the technique used in Xcode duplicate line. I have not gone so far.
Multiple Assistant Editors
If you are using multiple assistant editors, you can use graphical navigation chooser to choose the destination of each action. You can start in any editor and you can even swap the content of two assistant editors this way.
⇧⌥⌘, - Open in... and choose the second editor
⌘J - Move Focus to Editor... and choose the second editor (or use ^` multiple times)
⇧^⌥⌘← - Go Back in... and choose the first editor
Shift
to this shortcut, you will be able to choose any editor as a destination (not just Primary editor). –
Precondition ^
+⌥
+⌘
+←
. (go back and open result in assistant editor) –
Precondition There is a very easy way to do this. In the assistant editor, there is a bar at the top that shows the path of the file in the editor. Drag that file's icon into the same bar in the main editor.
Boom! swapped.
Keep in mind, that you need to be set up this way to pull this off:
- Have the "Assistant Editor" selected
- The Assistant Editor needs to be set to Automatic or "Counterparts" for the swap to work.
Here are the keyboard shortcuts to do the swap:
ctrl + command + up
or
ctrl + command + down
You can open active document in any other editor by pressing
⇧⌥⌘,
I would use it like this:
Suppose we have two editors E1
and E2
- Choose
E1
- Press ⇧⌥⌘,
- In
graphical navigation chooser
chooseE2
Original content of
E1
now opened both inE1
andE2
- ⇧⌥click the back arrow of
E2
(or just press ⇧⌃⌥⌘←) - In
graphical navigation chooser
chooseE1
Congratulations, you've swapped content of two editors 🎉
You could press just ⌃⌥⌘← instead of last two steps, because ⌥ opens file in assistant editor.
P.S.
Meaning of ⇧⌃⌥⌘←:
⇧⌥ is resposible for graphical navigation chooser
⌃⌘← is responsible for Go back
ctr + cmd + up
or
ctr + cmd + down
If you have assistant view open it will automatically open the counterpart file. This way if you switch back and forth in your main window your counterpart window will update with the header/implementation file.
- Position the cursor over the symbol you want to load (e.g. the method or class name)
- Command + Shift + O to load the quick open window (it will prepopulate with the item underneath the cursor)
- Shift + Option + Enter loads a UI that lets you choose a tab or editor
- It should select the primary editor by default, so just press Enter!
You can also use Command + Shift + Option + Click.
© 2022 - 2024 — McMap. All rights reserved.