Skip to content

Support Ctrl Modifier for Word Navigation and Deletion in Text Areas#5394

Open
iskandergaba wants to merge 1 commit intojesseduffield:masterfrom
iskandergaba:support-ctrl-modifier
Open

Support Ctrl Modifier for Word Navigation and Deletion in Text Areas#5394
iskandergaba wants to merge 1 commit intojesseduffield:masterfrom
iskandergaba:support-ctrl-modifier

Conversation

@iskandergaba
Copy link

PR Description

Unlike lazygit, most text editors and TUIs support Ctrl based key bindings for word navigation and deletion. They also support forward word deletion. As a heavy user of these key bindings, I wanted to extend their support to lazygit to switch between tools more easily.

I am sure that I am not the only one who would appreciate this, and in any case, this extension does not break any preexisting key bindings.

Changes:

  • Ctrl+Left / Ctrl+Right: Move cursor one word left/right (alongside existing Alt+Left/Right and Emacs-style Alt+B/Alt+F)
  • Ctrl+Backspace: delete word to the left (alongside existing Alt+Backspace and Ctrl+W)
  • Ctrl+Delete / Alt+D: Delete word to the right (new; no equivalent existed before)

Note:

ModCtrl was previously disabled in gocui with a comment stating it didn't work with keyboard keys. This comment was written 5 years ago and mentions tcell.v1 while the project is currently using tcell.v2, so I suspect it is a bit legacy now, but I would like it if the maintainers double-checked that part. I managed to make ModCtrl work by patching tcell_driver.go to preserve it for right/left and deletion key events while keeping it stripped from all other ones, as before.

Please Check If the PR Fulfills these Requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalized (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant