Repository: spyder-ide/spyder

Issue:
The "Next word" and " Previous word" shortcuts do not work as expected
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below

## Problem Description

The `Next word` and `Previous word` shortcut call the `End of word` and `Start of word` actions instead of `Next word` and `Previous word`.

This error occurs in the 3.x and master branch and is is due to an error [here](https://github.com/spyder-ide/spyder/blob/3.x/spyder/widgets/sourcecode/codeeditor.py#L599) in the code for the 3.x and [here](https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/editor/widgets/codeeditor.py#L546) for master:

The `StartOfWord` and `EndOfWord` variable name should be replaced by `PreviousWord` and `NextWord`

Also, a test should be added to catch this error. This is problematic however because, as explained in #7853, both shortcuts use the `Meta` key by default in the key sequence. So this would have to be changed also as part of fixing this.


Discussion:
I would replace the default key sequence for these 2 shortcuts like this :

Next word: `Meta+Right` -> `Ctrl+Right`
Previous word: `Meta+Left` -> `Ctrl+Left`

Which are the default key sequence for all OSes but macOS:

http://doc.qt.io/qt-5/qkeysequence.html#standard-shortcuts
![image](https://user-images.githubusercontent.com/10170372/45301720-7ea13180-b4df-11e8-99c0-701e2420eb86.png)

Ok, thanks a lot. Please work on this for Spyder 3.
@ccordoba12 
I think we should do 2 PR to fix this if this is possible. 

In a PR based against 3.x, we should only replace the `StartOfWord` and `EndOfWord` variable name by `PreviousWord` and `NextWord`. Due to the situation with builtin shortcuts in 3.x, I'm not sure it is worth doing more than that.

In another PR based against master, I think we should:
1. replace the `StartOfWord` and `EndOfWord` variable name by `PreviousWord` and `NextWord`
2. change the default key sequence for the 2 shortcuts.
3. add a test
> I think we should do 2 PR to fix this if this is possible

Agreed with your plan :+1: 

Resolving patch:
diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py
--- a/spyder/widgets/sourcecode/codeeditor.py
+++ b/spyder/widgets/sourcecode/codeeditor.py
@@ -596,9 +596,9 @@ def cursor_move_event():
         next_char = config_shortcut(cb_maker('Right'), context='Editor',
                                     name='Next char', parent=self)
 
-        prev_word = config_shortcut(cb_maker('StartOfWord'), context='Editor',
+        prev_word = config_shortcut(cb_maker('PreviousWord'), context='Editor',
                                     name='Previous word', parent=self)
-        next_word = config_shortcut(cb_maker('EndOfWord'), context='Editor',
+        next_word = config_shortcut(cb_maker('NextWord'), context='Editor',
                                     name='Next word', parent=self)
 
         kill_line_end = config_shortcut(self.kill_line_end, context='Editor',


Test patch: