Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Keyboard shortcut for switching focus between panes #10555

Closed
TessaI159 opened this issue Feb 9, 2015 · 16 comments
Closed

Keyboard shortcut for switching focus between panes #10555

TessaI159 opened this issue Feb 9, 2015 · 16 comments

Comments

@TessaI159
Copy link

I'm not sure if somebody else has already submitted this or not, the trello board won't load for me, and I'm not even sure if this the right place to do this but it can't hurt.
I would love to see a keyboard shortcut that would allow me to switch which view is active. I love the vertical split idea so I can see two documents at once, but it seems inconvenient that I need my mouse to switch focus between them.

@RaymondLim
Copy link
Contributor

@Tessag159 You can assign them with User Key map easily. Just Select User Key Map from Debug menu and paste the following key bindings. Then, reassign the keys to whatever you want.

        "Ctrl-1": "cmd.splitViewNone",
        "Ctrl-2": "cmd.splitViewVertical",
        "Ctrl-3": "cmd.splitViewHorizontal"

Update: actually, the key bindings above only allow you to switch between different split views, but not to set focus from one view to the other. So we still don't have any command to switch focus between split views.

@peterflynn
Copy link
Member

@Tessag159 You can use Ctrl-Tab to navigate between recent documents, including switching across panes. There's also my File Navigation Shortcuts extension, which lets you switch to any open document quickly by typing a few characters of its name.

It should also be pretty easy for someone to write an extension that specifically jumps focus to a given pane (or toggles focus between the two panes -- unlike Ctrl-Tab regardless of whether the other pane's document was recently focused before or not). I'll mark this 'extension idea' in case anyone wants to implement that.

@JeffryBooher
Copy link
Contributor

@Tessag159 you could also write an extension which registers a key to toggle between the two panes.

The code below should do it but I haven't tested it. You'll need to wire that up to a keyboard command. For that refer to the hello-world sample: https://github.com/adobe/brackets/wiki/Simple-%22Hello-World%22-extension

function switchPanes() {

    if (MainViewManager.getPaneCount() > 1) {
        var activePane = MainViewManager.getActivePaneId(),
            paneIds = MainViewManager.getPaneIdList(),
            index = paneIds.indexOf(activePane) + 1;

         if (index >= paneIds.length) {
            index = 0;
         }

         MainViewManager.setActivePaneId(paneIds[index]);
    }
}

@peterflynn peterflynn changed the title New keyboard shortcut Keyboard shortcut for switching focus between panes Feb 10, 2015
@TessaI159
Copy link
Author

Thank you guys so much, I'll get around to seeing if any of these suggestions work just as soon as I can.

@noragrossman
Copy link

Has anyone done any more work on this? I am a new developer and I thought I'd give this a try, but I don't want to duplicate efforts if an extension is already in progress.

@TessaI159
Copy link
Author

I haven't done anything with it, and I doubt anybody else has either. Go ahead and give it a shot.

@alexeyoganezov
Copy link

I've wrote extremly simple extension for toggling panes:
https://github.com/ivan1810/moving-between-splitted-windows

You can install it through extension manager.
Does it solve your problem?

@petetnt
Copy link
Collaborator

petetnt commented Oct 7, 2016

I'd love to see this feature in the core too. Tagging as starter bug.

@arthur801031
Copy link
Contributor

Hi @petetnt , Can I try adding this feature in the core? Thank you!

@petetnt
Copy link
Collaborator

petetnt commented Oct 24, 2016

@arthur801031 Sure thing!

See the article How to hack on Brackets to get started with the Brackets codebase. If you have any questions, feel free to post them here! We also have a Slack channel for day-to-day communication. (You can join by sending a mail to admin@brackets.io with the subject line slack registration request specifying the email addresses you would like to register).

arthur801031 added a commit to arthur801031/brackets that referenced this issue Oct 26, 2016
arthur801031 added a commit to arthur801031/brackets that referenced this issue Oct 26, 2016
@arthur801031
Copy link
Contributor

Hi @petetnt I've added this feature in the core. Please let me know if I need to make any changes. Thank you very much.

arthur801031 added a commit to arthur801031/brackets that referenced this issue Oct 28, 2016
arthur801031 added a commit to arthur801031/brackets that referenced this issue Oct 28, 2016
petetnt pushed a commit that referenced this issue Oct 28, 2016
* Added the feature to toggle between panes as requested by petetnt in issues #10555

* Added the feature to toggle between panes as requested by petetnt in issues #10555

* Bumping version Number to 1.9

* Edited the files and added a unit test for this feature as requested by petetnt and swmitra

* Removed duplicate/unnecessary code in Pane.js

* Removed additional duplicate/unnecessary code in Pane.js

* Edited 'should switch pane when alt-w is pressed' function in MainViewManager-test.js and the test is now passing

* Revert package.json and src/config.json to previous commit

* Added the feature to toggle between panes as requested by petetnt in issues #10555

* Added the feature to toggle between panes as requested by petetnt in issues #10555

* Edited the files and added a unit test for this feature as requested by petetnt and swmitra

* Removed duplicate/unnecessary code in Pane.js

* Removed additional duplicate/unnecessary code in Pane.js

* Edited 'should switch pane when alt-w is pressed' function in MainViewManager-test.js and the test is now passing

* Revert package.json and src/config.json to previous commit

* Modified test code to test CMD_SWITCH_PANE_FOCUS

* Removed unnecessary code in MainViewManager-test.js
@petetnt
Copy link
Collaborator

petetnt commented Oct 28, 2016

Fixed/added in #12853

@petetnt petetnt closed this as completed Oct 28, 2016
@ronherrema
Copy link

It's not clear to me how or where this has been incorporated. Is there now a default shortcut for switching panes?

@TessaI159
Copy link
Author

Yeah, Brackets updated it so that it is included in the core package now. I believe the shortcut key is Alt + W

@ronherrema
Copy link

I'm on Mac. There are shortcuts for moving from one document to another in the document list, but I don't see anything for switching between the two open panes.

@petetnt
Copy link
Collaborator

petetnt commented May 11, 2017

@ronherrema which version of Brackets are you using? Have you tried without extensions? Alt+W works for me on MacOSX with Brackets 1.9 (and latest master).

If it still doesn't work, check the developer tools (Debug -> Show Developer Tools -> Console) if there are any warnings of duplicate keyboard shortcuts. It might also be that another program is blocking the command, in which case you can update the keymap.json to change the shortcut.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants