lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Navigate by word in prompts

Open StefanMich opened this issue 5 years ago • 12 comments

Describe the bug In prompts with text fields (commit, checkout, etc..), I would like to navigate by word, which is implemented in most textfields other places (text editors, browsers, etc.). When I press ctrl + left arrow as I am used to, lazygit interprets the key combination as a shortcut which operates in the menu, and not in the text field

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Local branches'
  2. Press 'c' for checkout by name
  3. Type some text...
  4. Press ctrl + left arrow

Expected behavior Cursor moves to the beginning of the word

Desktop (please complete the following information):

  • OS: Ubuntu 19.10
  • Lazygit Version: build date=2020-04-10, build source=debian, version=0.18, os=linux, arch=amd64

StefanMich avatar Apr 20 '20 08:04 StefanMich

Agreed that this should be a thing. I'm not sure that termbox (one of our dependencies) supports those keys, but I'm assuming there must be some way to read them. Then it's just a matter of adding handlers for those keys in gocui's (another one of our dependencies)simpleEditor function

jesseduffield avatar Aug 23 '20 21:08 jesseduffield

Maybe you could extend this functionality and also use the home and end keys. We use a different naming convention for our branches and when checking out a branch it always means removing the "origin" from the name.

joejoe87577 avatar Sep 02 '20 09:09 joejoe87577

I made a pull request that adds this functionality: #1142

murphy66 avatar Jan 17 '21 14:01 murphy66

I have just some puzzling moments while not being able to move cursor by word with CTRL+Left/Right in the commit dialog. Or perhaps this issue is old now and there is a way to jump between words, instead of between characters?

Update: I've just checked Ctrl+B/F as per https://github.com/jesseduffield/lazygit/pull/2104 but it does not work for me either in version 0.38.2 on Windows (Git Bash).

mloskot avatar May 23 '23 15:05 mloskot

I have just some puzzling moments while not being able to move cursor by word with CTRL+Left/Right in the commit dialog. Or perhaps this issue is old now and there is a way to jump between words, instead of between characters?

Update: I've just checked Ctrl+B/F as per #2104 but it does not work for me either in version 0.38.2 on Windows (Git Bash).

Same over here. None of the keybinds work for me.

Armadillidiid avatar Jun 16 '23 18:06 Armadillidiid

Same here. And besides Ctrl + Arrow to move a word, I request also for Ctrl + Backspace / Ctrl + Del to remove a word.

fengjianyun avatar Feb 16 '24 08:02 fengjianyun

Move by word is mapped to alt + left/right, not ctrl. I'm relatively sure that this is because ctrl is not technically possible (unless the underlying tcell library implements https://github.com/gdamore/tcell/issues/671).

Delete word is available, and mapped to ctrl-w.

stefanhaller avatar Feb 16 '24 11:02 stefanhaller

Move by word is mapped to alt + left/right, not ctrl. I'm relatively sure that this is because ctrl is not technically possible (unless the underlying tcell library implements gdamore/tcell#671).

Delete word is available, and mapped to ctrl-w.

Thank you very much ! My Lazygit is 0.40.2 installed in WSL 2 (Ubuntu 20.04), I can confirm Ctrl + w works like a charm and move by words is Alt + Shift + Arrow.

fengjianyun avatar Feb 17 '24 21:02 fengjianyun