Repository: spyder-ide/spyder

Issue:
Provide better keyboard shortcuts to switch editor tabs on Mac
_From [ehreming...@gmail.com](https://code.google.com/u/107391130974036659868/) on 2014-02-24T20:12:08Z_

We need to add keyboard shortcuts to switch between (at least two) commonly used editor tabs. I know there are open tickets about dragging and dropping and renaming, which are not making much progress, but what about simply switching via the keyboard rather than mouse? 

What steps will reproduce the problem?
1. open one tab
   1. open another tab
   2. try to switch back to the first tab by using only the keyboard in less time than reaching for the mouse What version of the product are you using? On what operating system? 2.3 third beta 

Please provide any additional information below

. Please? :)

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1741_



Discussion:
_From [adityajo...@gmail.com](https://code.google.com/u/106183379593005237020/) on 2014-09-03T09:55:54Z_

Shortcuts for changing tabs is a very important part of any ide or editor. This feature is needed. Till then I'm using Pydev...

_From [contrebasse](https://code.google.com/u/contrebasse/) on 2014-09-03T12:28:27Z_

Try Ctrl+Tab and Ctrl+Shift+Tab ? I admit that with many tabs the switch order is inconsistent, but in your example there is only 2 tabs.

Also, 2.3 is out, you can update your beta version.

_From [ccordoba12](https://code.google.com/u/ccordoba12/) on 2014-09-03T17:07:03Z_

There is a shortcut to show a menu from which you can select your file. It's Ctrl+E.

Could you try it and see if that's what you're looking for?

_From [contrebasse](https://code.google.com/u/contrebasse/) on 2014-09-04T08:15:25Z_

Woah, I didn't know that ! Cool !

It's not very interactive, though. To switch tab you have to press Ctrl+E, Tab (to change te focus from the filter to the list) up or down arrow a few times, then Enter. It's fine when typing (part of) the name.

_From [ccordoba12](https://code.google.com/u/ccordoba12/) on 2014-09-21T11:50:02Z_

**Labels:** -Easy  

Isn't this already available via Ctrl+PageUp?

Indeed.

What is this on Mac?

I can't find it in Preferences -> Keyboard shortcut.
It's hard coded because all editors/browsers/IDEs use those shortcuts (Ctrl+Tab and Ctrl+Shift+Tab). But this issue will be properly fixed in Spyder 3.2 too.
Any updates on this for Mac?
Is this still unavailable on macOS in Spyder 3.3.6?  So if I have two editor tabs open and want to quickly switch between them, I have to use the touchpad rather than the keyboard?  The macOS shortcuts for this are shift-command-[ and shift-command-], but neither of these seem to do anything.  Ctrl-PageUp and Ctrl-PageDown don't work.  Ctrl-Tab and Ctrl-Shift-Tab don't work.  There also doesn't seem to be a menu entry for doing this, which I could bind in System Preferences.
I'm using spyder 4.1.5 on a mac, and command-PgUp/Down works to swap editor tabs
Needed for Mac. My keyboard doesn't have PgUp/Down

Resolving patch:
diff --git a/spyder/widgets/tabs.py b/spyder/widgets/tabs.py
--- a/spyder/widgets/tabs.py
+++ b/spyder/widgets/tabs.py
@@ -389,13 +389,13 @@ def keyPressEvent(self, event):
         handled = False
         if ctrl and self.count() > 0:
             index = self.currentIndex()
-            if key == Qt.Key_PageUp:
+            if key == Qt.Key_PageUp or key == Qt.Key_8:
                 if index > 0:
                     self.setCurrentIndex(index - 1)
                 else:
                     self.setCurrentIndex(self.count() - 1)
                 handled = True
-            elif key == Qt.Key_PageDown:
+            elif key == Qt.Key_PageDown or key == Qt.Key_9:
                 if index < self.count() - 1:
                     self.setCurrentIndex(index + 1)
                 else:


Test patch: