nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
177 stars 25 forks source link

Ctrl-left/right should jump by word #21

Closed towerofnix closed 6 years ago

towerofnix commented 6 years ago

In the existing node REPL (which uses readline, I think), pressing the left/right arrow keys while holding down control jumps the cursor to the end or beginning of a word, or to the next or previous word. (Take that sentence with a grain of salt; I don't know exactly how it works, but it's still a feature I make frequent use of.) See the following diagram for an example; each | is a stop where the cursor moves to when you press ctrl-left/right:

console.log("Hello, world!")
|      ||  | |    | |    |  |

The same stops are used when pressing left or right.

By the looks of it, the stops are placed at the first character of every word (which are alphanumeric, I think) and the first character of a chunk of symbols (e.g. ., (", ,, !)").