jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.99k stars 1.85k forks source link

Navigate by word in prompts #795

Open StefanMich opened 4 years ago

StefanMich commented 4 years ago

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):

jesseduffield commented 4 years ago

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

joejoe87577 commented 4 years ago

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.

murphy66 commented 3 years ago

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

mloskot commented 1 year ago

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).

Armadillidiid commented 1 year ago

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.

fengjianyun commented 8 months ago

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

stefanhaller commented 8 months ago

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.

fengjianyun commented 8 months ago

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.