Support backward/forward by word with ctrl+<-/->

This commit is contained in:
xiaofan hu 2018-09-12 15:01:28 +02:00
parent 2972be24d4
commit 2ce07eb6d6
2 changed files with 42 additions and 34 deletions

View File

@ -7,16 +7,16 @@ Notice: `Meta`+`B` is equals with `Alt`+`B` in windows.
* Shortcut in normal mode
| Shortcut | Comment |
| ------------------ | --------------------------------- |
| ------------------------- | --------------------------------- |
| `Ctrl`+`A` | Beginning of line |
| `Ctrl`+`B` / `←` | Backward one character |
| `Meta`+`B` | Backward one word |
| `Meta`+`B` / `Ctrl`+`←` | Backward one word |
| `Ctrl`+`C` | Send io.EOF |
| `Ctrl`+`D` | Delete one character |
| `Meta`+`D` | Delete one word |
| `Ctrl`+`E` | End of line |
| `Ctrl`+`F` / `→` | Forward one character |
| `Meta`+`F` | Forward one word |
| `Meta`+`F` / `Ctrl`+`→` | Forward one word |
| `Ctrl`+`G` | Cancel |
| `Ctrl`+`H` | Delete previous character |
| `Ctrl`+`I` / `Tab` | Command line completion |

View File

@ -101,9 +101,17 @@ func escapeExKey(key *escapeKeyPair) rune {
var r rune
switch key.typ {
case 'D':
if key.attr == "1;5" {
r = MetaBackward
} else {
r = CharBackward
}
case 'C':
if key.attr == "1;5" {
r = MetaForward
} else {
r = CharForward
}
case 'A':
r = CharPrev
case 'B':