Giter Club home page Giter Club logo

Comments (2)

junegunn avatar junegunn commented on September 27, 2024 1

Thanks for suggestion.

I don't see myself implementing it, as I think mode switching is overkill for fzf where you don't spend a lot of time editing your query. I think this holds true for most of the other users, they wouldn't spend more than a few seconds inside fzf 90% of the time; open fzf, type in a few characters, and you get the best match at your hand, press enter. So I don't think it's worth the effort, but if anyone's interested in implementing it, I can review the patch though there's no guarantee that it'll finally land on fzf.

FWIW, I've been using Vim for many years by now, and I can safely say that I know one or two things about it, but I don't use vi-mode on command-line because I feel Emacs-style bindings work better for input prompts. I wasn't familiar with all the bindings, but after properly learning them, I realized I was severely underutilizing them, and they can be more efficient than vi-mode in quick editing mode.

  • CTRL-W and CTRL-U to quickly delete word and line
  • CTRL-A and CTRL-E to move cursor to the front and to the back
  • ALT-B and ALT-F for word-wise movement
  • ALT-BS and ALT-D for deleting a word backward and forward
  • CTRL-B, CTRL-F to move cursor by a column, CTRL-D to delete a character
  • And CTRL-Y to paste the previously deleted chunk.

And fzf implements all of these.

Even if we incorporate some readline library, implementing it properly won't be trivial, because fzf allows full customization of the keys via --bind and it's going to be a lot of work to reconcile the two systems.

from fzf.

thjbdvlt avatar thjbdvlt commented on September 27, 2024

hello! i've made a mini python script that generates bindings for a pseudo vi-mode from a config file (because i have no alt key, and dislike ctrl because of an idiosyncratic keyboard).
it's a really quick-and-dirty solution but well i can't do better and impact on performance is not terrible in my experience (it produces a veeeery long binding).
i really like using fzf like this (escape, then j/k to go down/up, c for delete, i/a/I/A for insert mode, and so on). it's here on github: thjbdvlt/fzf-vi-mode

here is how the config file could look:

[mode]
escape = esc
insert_before = i
insert_after = a 
insert_end_line = A
insert_beginning_line = I

[normal]
j = down
k = up
s = jump
p = toggle-preview
h = backward-char
l = forward-char
e = forward-word
b = backward-word
d = clear-query
y = execute(echo {} | xsel -b)
E = preview-half-page-down
U = preview-half-page-up
c = cancel
x = forward-char+backward-delete-char
X = backward-delete-char

[insert]
® = backward-kill-word
change = top
backward-eof = abort

and here is the bindings for this config file:

--bind=j:down,k:up,s:jump,p:toggle-preview \
--bind=h:backward-char,l:forward-char,e:forward-word,b:backward-word \
--bind=d:clear-query \
--bind='y:execute(echo {} | xsel -b)' \
--bind=E:preview-half-page-down,U:preview-half-page-up \
--bind=c:cancel,x:forward-char+backward-delete-char \
--bind=X:backward-delete-char \
--bind=start:enable-search+unbind(e,j,s,p,h,l,é,b,d,y,E,U,c,x,X,i,a,A,I)  \
--bind=i:enable-search+unbind(j,k,s,p,h,l,e,b,d,y,E,U,c,x,X,i,a,A,I) \
--bind=a:enable-search+unbind(j,k,s,p,h,l,e,b,d,y,E,U,c,x,X,i,a,A,I)+forward-char \
--bind=A:enable-search+unbind(j,k,s,p,h,l,e,b,d,y,E,U,c,x,X,i,a,A,I)+end-of-line \
--bind=I:enable-search+unbind(j,k,s,p,h,l,e,b,d,y,E,U,c,x,X,i,a,A,I)+beginning-of-line \
--bind=esc:disable-search+rebind(j,k,s,p,h,l,e,b,d,y,E,U,c,x,X,i,a,A,I) \
--bind=®:backward-kill-word,change:top,backward-eof:abort

from fzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.