Repository: spyder-ide/spyder

Issue:
Change keybinding for Replace text (⌘H) in the Editor on Mac
Spyder 3.0.0b2 
Python 2.7.11 64bits, Qt 5.4.1, PyQt5 5.4.1 on Darwin

The default keyboard shortcut for Replace text is "Ctrl+H", which is "⌘H" on Mac. 
https://github.com/spyder-ide/spyder/blob/master/spyderlib/config/main.py#L548

However,  "⌘H" is already bound to the menu "python -> Hide Spyder". In fact, "⌘H" on Mac is the system default shortcut to "Hide the windows of the front app".

Thus I would suggest changing the shortcut for Replace text on Mac to, for example, "Command + Alt + F" (and maybe also changing it to "Control + Alt + F" on other platforms).



Discussion:
What if we change that shortcut to `Cmd+R` on Mac and `Ctrl+R` for other OSes. Is there a problem with that?

`Cmd+R` has no conflict with other default shortcuts in Spyder. It could be a good choice as it's easy to remember and 33% shorter than `Cmd+Alt+F`!

Yep, that's nice and also used in other text editors (like Kate). I'll change it for beta3.

Thanks!  :+1: 

Ctrl+f is common in lots of applications on windows and linux. The default could be changed for mac only ?

@Nodd, `Ctrl+F` is for searching and `Ctrl+R` for search and replace :-)

Ctrl+h for search and replace is widely used, sorry.

@Nodd Here is the list of the default shortcuts for "Search and replace":
https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts#Text_editing
Windows: Ctrl+H
Mac: Cmd+F
GNOME: Ctrl+H
KDE: Ctrl+R

So `Ctrl+H` is very common on windows and gnome. However, on Mac `Alt+Cmd+F` is very popular in many text editors, such as Xcode, TextEdit and Sublime Text.

Thus I guess we may have two options for Spyder:
1. Use the same shortcut on all platforms, and `Ctrl+R` (`Cmd+R` on Mac) could be a good candidate since `Ctrl+H` is excluded due to Mac.
2. Continue using `Ctrl+H` on windows and linux, but use a different one for Mac. In that case, I would suggest `Alt+Cmd+F` for Mac convention.

Or, we can simply use `Ctrl+F` for the combined "Find" and "Replace" function using the current "Replace" widget: https://github.com/spyder-ide/spyder/issues/2921


Resolving patch:
diff --git a/spyderlib/app/spyder.py b/spyderlib/app/spyder.py
--- a/spyderlib/app/spyder.py
+++ b/spyderlib/app/spyder.py
@@ -1171,7 +1171,8 @@ def add_xydoc(text, pathlist):
         # This is a workaround because we can't disable shortcuts
         # by setting context=Qt.WidgetShortcut there
         if sys.platform == 'darwin':
-            for name in ['file', 'run', 'debug', 'plugins']:
+            for name in ['file', 'search', 'source', 'run', 'debug',
+                         'plugins']:
                 menu_object = getattr(self, name + '_menu')
                 menu_object.aboutToShow.connect(
                     lambda name=name: self.show_shortcuts(name))
diff --git a/spyderlib/config/main.py b/spyderlib/config/main.py
--- a/spyderlib/config/main.py
+++ b/spyderlib/config/main.py
@@ -345,7 +345,7 @@
               '_/find text': "Ctrl+F",
               '_/find next': "F3",
               '_/find previous': "Shift+F3",
-              '_/replace text': "Ctrl+H",
+              '_/replace text': "Ctrl+R",
               # ---- Editor ----
               # -- In widgets/sourcecode/codeeditor.py
               'editor/code completion': CTRL+'+Space',
@@ -585,7 +585,7 @@
 #    or if you want to *rename* options, then you need to do a MAJOR update in
 #    version, e.g. from 3.0.0 to 4.0.0
 # 3. You don't need to touch this value if you're just adding a new option
-CONF_VERSION = '27.0.0'
+CONF_VERSION = '27.1.0'
 
 
 # XXX: Previously we had load=(not DEV) here but DEV was set to *False*.


Test patch: