Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to preview :g commands #7

Closed
AckslD opened this issue Aug 15, 2022 · 9 comments
Closed

How to preview :g commands #7

AckslD opened this issue Aug 15, 2022 · 9 comments

Comments

@AckslD
Copy link

AckslD commented Aug 15, 2022

Can this plugin be used to preview :g? For example lets say I have the buffer:

foo
bar
barx
foo
xbar

and I want to delete any line containing bar which could be done with :g/bar/d<CR>. However if I add the entry G = { cmd = 'g' } to the config of this plugin. It only previews the command on the current line when I type :G/bar/d, even though :g acts on all lines.

@smjonas
Copy link
Owner

smjonas commented Aug 15, 2022

That's a nice usecase! I have now fixed a few bugs on the main branch (note that visualizing deletions won't work on main now, I'll get to that once I have finished work on the hl_improvements branch :D). Please try changing your command to G = { cmd = 'g' , hl_range = { 1, -1, kind = "absolute" } } (edit: it should be hl_range instead of range).

@AckslD
Copy link
Author

AckslD commented Aug 15, 2022

Thanks for a quick reply! I tried your suggestion but now I don't get any preview, but maybe that's related to deletions not working as you mentioned since :g/bar/d will only delete?

@smjonas
Copy link
Owner

smjonas commented Aug 15, 2022

Sorry, my earlier fix was a bit too rushed 😄 I have now fixed several bugs related to the handling of ranges, could you try again with the latest commit? Highlights should now also work again and your other issue is hopefully resolved too (not tested though).

@AckslD
Copy link
Author

AckslD commented Aug 16, 2022

Seems to not have done it unfortunately, I'm getting the original behaviour for both this and #6 now.

@smjonas
Copy link
Owner

smjonas commented Aug 16, 2022

Ok, for this issue, please change range to hl_range, that was a typo in my earlier comment. I reopened your other issue :)

@AckslD
Copy link
Author

AckslD commented Aug 16, 2022

Ah! Yes this works, thanks ❤️ 🚀

@smjonas
Copy link
Owner

smjonas commented Aug 16, 2022

I noticed there was pretty bad performance when using your G command in large files. I have now added hl_range = { kind = "visible" } to only preview visible lines in the current buffer which speeds up things dramatically!

@AckslD
Copy link
Author

AckslD commented Aug 16, 2022

Ah that's awesome!

@uloco
Copy link

uloco commented Nov 15, 2023

This is really nice. Is there a way to also highlight the found patterns like :g does at first, before applying the command? @AckslD @smjonas

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

No branches or pull requests

3 participants