clever-f.vim icon indicating copy to clipboard operation
clever-f.vim copied to clipboard

f and t in macros

Open nathanbraun opened this issue 10 years ago • 7 comments

It doesn't look like f and t work in user recorded macros, example:

qqfaq

would record a macro that moves to the next 'a' in a line. If I do that, then move to another line and call it via:

@q

nothing happens. Is this something that could be added? Great plugin, thanks!

nathanbraun avatar Feb 24 '15 22:02 nathanbraun

Hi, @nathanbraun

Sorry for the delay :sweat_drops:

I tried qqfaq -> @q and it seemed to work well in my environment (OS X 10.10 and Vim 7.4p383). Could you please tell me your environment to reproduce this issue?

rhysd avatar Mar 01 '15 16:03 rhysd

6 years later I can confirm it does not work well with macros - if you use f 2x in row. eg:

use 'macro_wont/work'

We have cursor on beginning of line and macro is: go forward to second quote, and then paste text in there. On replaying macro we should get: use 'macro_wont/work'PASTE

But we get no result at all. Macro is: f'fp @rhysd hope u can make it work since plugin is great

JoseConseco avatar Apr 18 '21 22:04 JoseConseco

@JoseConseco Would you explain your sequence with what you typed? I want to reproduce exactly the same issue.

My understanding is:

  1. Save the following contents as foo.txt
  2. Open Vim
  3. qq
  4. f'f (move to the second quote)
  5. p (paste something)
  6. q (stop recording macro)
  7. Go to next line
  8. @q
use 'foo/bar'
use 'foo/bar'

Is this correct?

rhysd avatar May 04 '21 04:05 rhysd

Yes see below - first I record qq macro with - f'f action. Then I try to re-run it with @q

https://user-images.githubusercontent.com/13521338/117019060-5bad9680-acf5-11eb-8e8d-8bc46d65ae3a.mp4

Cursor goes to completely wrong place - it goes bottom line at the end of video - after running the macro. In any case I switched to vim-sneak so if you are not longer working on developing this plugin then that is ok. Also I'm not sure if that changes anything but I used P for pasting.

JoseConseco avatar May 04 '21 14:05 JoseConseco

I can also confirm that there are instances where clever-f does not work with macros correctly.

It'd be fine for me if clever-f is disabled during macro recording / replay.

W4RH4WK avatar May 27 '21 09:05 W4RH4WK

There might be a solution in this comment thread: https://github.com/ggandor/lightspeed.nvim/issues/7

jam1015 avatar Sep 10 '21 18:09 jam1015

For reference to whoever has the same issue, this is what I use which works just fine. (Analog to the issue of lightspeed.) It disables the plugin during both running and the execution of plugins.

" make sure to set this, otherwise it won't work
let g:clever_f_not_overwrites_standard_mappings = 1

nmap <expr> f reg_recording() .. reg_executing() == "" ? "<Plug>(clever-f-f)" : "f"
nmap <expr> F reg_recording() .. reg_executing() == "" ? "<Plug>(clever-f-F)" : "F"
nmap <expr> t reg_recording() .. reg_executing() == "" ? "<Plug>(clever-f-t)" : "t"
nmap <expr> T reg_recording() .. reg_executing() == "" ? "<Plug>(clever-f-T)" : "T"

cd-a avatar Feb 17 '22 16:02 cd-a