Skip to content

Commit

Permalink
feat(char): tfTF now behave like clever-f when repeating the motion. F…
Browse files Browse the repository at this point in the history
…ixes #26
  • Loading branch information
folke committed Jun 22, 2023
1 parent 6e84716 commit 97c3a99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ Install the plugin with your preferred package manager:
- use a jump label, or use `;` and `,` to increase/decrease the selection
- **regular search**: search as you normally do, but enhanced with jump labels
- `f`, `t`, `F`, `T` motions:
- go to next match with `;` or repeat the motion character like `f`
- go to previous match with `,`
- highlights clear automatically when moving, changing buffers or pressing `<esc>`
- After typing `f{char}` or `F{char},` you can repeat the motion with `f`
or go to the previous match with `F` to undo a jump.
- Similarly, after typing `t{char}` or `T{char},` you can repeat the motion
with `t` or go to the previous match with `T`.
- You can also go to the next match with `;` or previous match with `,`
- Any highlights clear automatically when moving, changing buffers,
or pressing `<esc>`.
- `require("flash").jump(opts?)` opens **flash** with the given options
- type any number of characters before typing a jump label

Expand Down
8 changes: 6 additions & 2 deletions lua/flash/plugins/char.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ end

function M.parse(key)
-- repeat last search when hitting the same key
if M.visible() and M.motion == key then
key = ";"
if M.visible() then
if M.motion:lower() == key then
key = ";"
elseif M.motion:upper() == key then
key = ","
end
end
-- different motion, clear the state
if M.motions[key] and M.motion ~= key then
Expand Down

0 comments on commit 97c3a99

Please sign in to comment.