clever-f.vim
clever-f.vim copied to clipboard
f and t in macros
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!
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?
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 Would you explain your sequence with what you typed? I want to reproduce exactly the same issue.
My understanding is:
- Save the following contents as
foo.txt - Open Vim
qqf'f(move to the second quote)p(paste something)q(stop recording macro)- Go to next line
@q
use 'foo/bar'
use 'foo/bar'
Is this correct?
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.
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.
There might be a solution in this comment thread: https://github.com/ggandor/lightspeed.nvim/issues/7
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"