Genivia / ugrep

NEW ugrep 7.0: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.64k stars 112 forks source link

support vi-mode keymaps in the interactive mode #291

Closed haolian9 closed 1 year ago

haolian9 commented 1 year ago

Hi, i got intrigued by the --query mode. As a neovim guy myself, i had dreamed about this feature while using grep, git grep. Though using emacs fasion keymaps (especially for <enter> to move selection down one line, ^q to quit) in a neovim floating terminal window goes against my muscle memory. I have read through the readme and GH issues but found no mentions about this, and no way to change the default keymaps; From what i obversed in the interactive mode, it has two modes: insert and select. I believe the vi-mode fits it naturally.

So do you think it's a good idea to get vi-mode into ugrep? just like bash's set -o vi.


i dont have a comprehensive keymaps for the vi-mode, but here are what i used to use:

visual:
* i/<esc>: insert mode
* j/k:     (un)select next/prev line
* o:       go to the other side of selection region
* q/ZZ:    quit

insert:
* <esc>: visual mode
* <c-u/w/a/h/...>
haolian9 commented 1 year ago

i dont know much about cpp, but i think i found the code that controls how the input keys being handled: https://github.com/Genivia/ugrep/blob/a779c64a1453c227c7b2cdcb2c9f0d1118f38a7e/src/query.cpp#L932. the keys are hard coded, so it's not too easy to support vi mode. and yeah i can certainly change this part of code by my needs.