[Bug 26165] New: Support moving between words in prompt with ctrl+left/right

Bug ID 26165
Summary Support moving between words in prompt with ctrl+left/right
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter ori@avtalion.name
CC llvm-bugs@lists.llvm.org
Classification Unclassified

As mentioned in the following mailing list thread, LLDB should have built-in
support for hotkeys for moving between words, specifically ctrl+left/right.


This is a very common use-case, particularly useful when editing long lines of
text (such as when typing commands in the Swift REPL, based on LLDB). At the
moment, LLDB spits out ;5C and ;5D which causes even more problems, forcing you
to delete those errant characters.

These are the two bindings I'm suggesting, taken from my ~/.editrc:
 bind "\e[1;5C" em-next-word
 bind "\e[1;5D" ed-prev-word

These specific commands match how both Bash and Emacs handle ctrl+left/right.
Ctrl+right moves the cursor forward, stopping directly after the last letter of
the current word.
Ctrl+left moves the cursor back to the first letter of the closest word.

Vi's behavior is a bit different, always moving forward/back to the start of a
word. For "vi-mode", these seem to fit:
  bind "\e[1;5C" vi-next-word
  bind "\e[1;5D" vi-prev-word

(ed-prev-word and vi-prev-word call different functions in libedit, with
slightly different code, but behavior seems to be identical.)