Skip to content

Better f as chimera of clever-f and vim-seek.#852

Merged
t9md merged 20 commits intomasterfrom
lazy-f
Sep 1, 2017
Merged

Better f as chimera of clever-f and vim-seek.#852
t9md merged 20 commits intomasterfrom
lazy-f

Conversation

@t9md
Copy link
Copy Markdown
Owner

@t9md t9md commented Aug 30, 2017

#851
#366 is Previous attempt to improve f, F, but removed because I didn't use it.
Now I also want re-evaluate #366.

TODO

  • highlight f char in current line.
    • Automatically clear highlight.
  • Allow f to find next line's char [CHANGED MIND]
  • repeat-find on sequential f.
  • allow smartcase/ignorecase for f
  • Can find both one-char(auto confirm by timeout), two-char.
    • Change find-char highlight color when auto-confirmed.
  • Configurable timeout
    • Provide timeout for smart-cased situation?(to use longer timeout when shift- modifier involved)

Note for experiment I did

I stopped optimistically going "let's introduce clever-f int vmp" mood.
Instead, I'm now experimenting several ideas to find best/better f.

  • Treat 2nd char as repeat-find

    • When move to a char, f a f allow 2nd a since 2nd f work as repeat-find.
    • I enhanced this idea to make 2nd any-char work as repeat-find.
      • So, f a a to move 2nd a, since 2nd a work as repeat-find, f b b to 2nd b and so on.
      • This require user-key-input intercept and compare key-input is equals to find-char.
      • If char was equal, invoke repeat-find.
  • Two char input to reduce possible matches(like vim-seek, vim-sneak).

    • Find by two char, and also allow 2nd-char-as-repeat-find
    • So f a b move cursor to ab, next b within timeout move cursor to 2nd ab
    • [Frustration] Sometime I want to jump by single char.
      • e.g. when try to move to a in (a) and a is enough, but require two char force me to type a).
      • Auto confirm by timeout?
      • Auto confirm if there is single match in line?

[current status] lazy-find

  • Command name is lazy-find.
  • Compromise two-char find and one char-find
    • f by TWO like vim-seek, vim-sneak
    • f by ONE-char by auto confirming on timeout(configurable)
    • Reuse f, F to repeat-find like clever-f.
  • highlighting find-char help pre-determine consequence of repeat.
    • After d f a, pre-determine text deleted by next ..
  • [Changed mind] I won't introduce treat-2nd-char-as-repeat-find feature for simplicity.

@t9md
Copy link
Copy Markdown
Owner Author

t9md commented Aug 30, 2017

clever-f-like

@t9md
Copy link
Copy Markdown
Owner Author

t9md commented Aug 31, 2017

lazy-f

@t9md t9md changed the title clever-f like feature Better f as chimera of clever-f and vim-seek. Aug 31, 2017
@jackcasey
Copy link
Copy Markdown
Contributor

Just my thoughts:
I think you are correct to abandon treat-2nd-char-as-repeat-find because something like f i i would be very ambiguous if you wanted to enter insert mode before the i or search for another i.

@t9md
Copy link
Copy Markdown
Owner Author

t9md commented Sep 1, 2017

[FINAL STATUS]: This is excerpt from CHANGELOG

  • New: [Summary] Now f is tunable. Better f as chimera of clever-f and vim-seek. #852.
    • Inspired pure-vim's plugins: clever-f, vim-seek, vim-sneak.
    • Highlighting find-char. It help you to pre-determine consequence of repeat by ;, , and ..
    • Aiming to get both benefit of two-char-find(vim-seek, vim-sneak) and one-char-find( vim's default ).
      • Even after two-char-find was enabled, you can auto-confirm one-char input by specified timeout.
    • Can reuse f, F, t, T as repeat-find like clever-f.
  • Config: [Detail] Following configuration option is available to tune f.
    • keymapSemicolonToConfirmFind: default false.
      • See explanation for findByTwoChars.
    • ignoreCaseForFind: default false
    • useSmartcaseForFind: default false
    • highlightFindChar: default true
      • Highlight find char, fadeout automatically( this auto-disappearing behavior/duration is not configurable ).
        • Fadeout in 2 second when used as motion.
        • Fadeout in 4 second when used as operator-target.
    • findByTwoChars: default false
      • When enabled, f accept TWO chars.
        • Pros. Greatly reduces possible matches, avoid being stopped at earlier spot than where you aimed.
        • Cons. Require explicit confirmation by enter for single char-input. You might mitigate frustration by.
          • Confirm by ;, easier to type and well blend to forwarding repeat-find( ; ).
            • Enable "keymap ; to confirm find motion"( keymapSemicolonToConfirmFind ) configuration.
            • e.g. f a ; to move to a( better than f a enter?). f a ; ; to move to 2nd a(well blended to default repeat-find(;)).
          • Enable auto confirm by timeout( See. findByTwoCharsAutoConfirmTimeout )
    • findByTwoCharsAutoConfirmTimeout: default 0.
      • "When findByTwoChars was enabled, automatically confirm single-char input on timeout( msec ).
      • 0 means no timeout.
    • reuseFindForRepeatFind: default false
      • When true you can repeat last-find by f and F(also t and T).
      • You still can use , and ;.
      • e.g. f a f move cursor to 2nd a.
    • My configuration( I'm still in-eval phase, don't take this as recommendation ).
      keymapSemicolonToConfirmFind: true
      findByTwoChars: true
      findByTwoCharsAutoConfirmTimeout: 500
      reuseFindForRepeatFind: true
      useSmartcaseForFind: true

Here is test spec for tunable-f

Clearer than explain in words.

describe "vmp unique feature of `f` family", ->
  describe "ignoreCaseForFind", ->
    beforeEach ->
      settings.set("ignoreCaseForFind", true)

    it "ignore case to find", ->
      set textC: "|    A    ab    a    Ab    a"
      ensure "f a", textC: "    |A    ab    a    Ab    a"
      ensure ";",   textC: "    A    |ab    a    Ab    a"
      ensure ";",   textC: "    A    ab    |a    Ab    a"
      ensure ";",   textC: "    A    ab    a    |Ab    a"

  describe "useSmartcaseForFind", ->
    beforeEach ->
      settings.set("useSmartcaseForFind", true)

    it "ignore case when input is lower char", ->
      set textC: "|    A    ab    a    Ab    a"
      ensure "f a", textC: "    |A    ab    a    Ab    a"
      ensure ";",   textC: "    A    |ab    a    Ab    a"
      ensure ";",   textC: "    A    ab    |a    Ab    a"
      ensure ";",   textC: "    A    ab    a    |Ab    a"

    it "find case-sensitively when input is lager char", ->
      set textC: "|    A    ab    a    Ab    a"
      ensure "f A", textC: "    |A    ab    a    Ab    a"
      ensure "f A", textC: "    A    ab    a    |Ab    a"
      ensure ",",   textC: "    |A    ab    a    Ab    a"
      ensure ";",   textC: "    A    ab    a    |Ab    a"

  describe "reuseFindForRepeatFind", ->
    beforeEach ->
      settings.set("reuseFindForRepeatFind", true)

    it "can reuse f and t as ;, F and T as ',' respectively", ->
      set textC: "|    A    ab    a    Ab    a"
      ensure "f a", textC: "    A    |ab    a    Ab    a"
      ensure "f",   textC: "    A    ab    |a    Ab    a"
      ensure "f",   textC: "    A    ab    a    Ab    |a"
      ensure "F",   textC: "    A    ab    |a    Ab    a"
      ensure "F",   textC: "    A    |ab    a    Ab    a"
      ensure "t",   textC: "    A    ab   | a    Ab    a"
      ensure "t",   textC: "    A    ab    a    Ab   | a"
      ensure "T",   textC: "    A    ab    a|    Ab    a"
      ensure "T",   textC: "    A    a|b    a    Ab    a"

  describe "findByTwoChars", ->
    beforeEach ->
      settings.set("findByTwoChars", true)

    describe "can find one or two char", ->
      it "can find by two char", ->
        set             textC: "|    a    ab    a    cd    a"
        ensure "f a b", textC: "    a    |ab    a    cd    a"
        ensure "f c d", textC: "    a    ab    a    |cd    a"

      it "can find by one-char by confirming explicitly", ->
        set                 textC: "|    a    ab    a    cd    a"
        ensure "f a enter", textC: "    |a    ab    a    cd    a"
        ensure "f c enter", textC: "    a    ab    a    |cd    a"

    describe "autoConfirmTimeout", ->
      beforeEach -> settings.set("findByTwoCharsAutoConfirmTimeout", 500)
      it "auto-confirm single-char input on timeout", ->
        set             textC: "|    a    ab    a    cd    a"

        ensure "f a",   textC: "|    a    ab    a    cd    a"
        advanceClock(500)
        ensure          textC: "    |a    ab    a    cd    a"

        ensure "f c d", textC: "    a    ab    a    |cd    a"

        ensure "f a",   textC: "    a    ab    a    |cd    a"
        advanceClock(500)
        ensure          textC: "    a    ab    a    cd    |a"

        ensure "F b",   textC: "    a    ab    a    cd    |a"
        advanceClock(500)
        ensure          textC: "    a    a|b    a    cd    a"

@t9md t9md merged commit 3965141 into master Sep 1, 2017
@t9md t9md deleted the lazy-f branch November 12, 2017 09:36
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.

2 participants