Skip to content

:Redact does not work #3

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

Closed
Ploppz opened this issue Dec 30, 2017 · 5 comments
Closed

:Redact does not work #3

Ploppz opened this issue Dec 30, 2017 · 5 comments

Comments

@Ploppz
Copy link

Ploppz commented Dec 30, 2017

When I first select some text in Visual mode, then type :Redact and enter, I am just in some : prompt, and nothing else happens.

When I try :Redact! (on text that is not 'redacted'):

E15: Invalid expression: <range>) | else | call redacted#redact(1) | endif             
E116: Invalid arguments for function redacted#clear

I installed it using plugged: Plug 'dbmrq/vim-redacted'.

@dbmrq
Copy link
Owner

dbmrq commented Dec 30, 2017

That's weird. From those errors it seems there's a problem with the Redact command definition, but I can't see why. What happens if you just run command! -range=0 -bang Redact if <bang>0 == 1 | call redacted#clear(<range>) | else | call redacted#redact(1) | endif yourself?

Edit: also try command! -range=0 -bang Redact if <bang>0 == 1 | call redacted#clear(0) | else | call redacted#redact(1) | endif and see if it makes any difference. You can also try calling the functions directly… select some text and do :'<,'>call redacted#redact(1) to redact and then :call redacted#clear(0) to clear, let's see how that goes.

@Ploppz
Copy link
Author

Ploppz commented Dec 30, 2017

First selecting some text then calling :command! -range=0 -bang Redact if <bang>0 == 1 | call redacted#clear(<range>) | else | call redacted#redact(1) | endif, it said no range allowed. If I don't select beforehand, nothing happens.

:'<,'>call redacted#redact(1) did indeed hide what was selected, but also all ocurrences of that exact text elsewhere in the buffer.

By the way, I am using neovim, version 0.2.2

@dbmrq
Copy link
Owner

dbmrq commented Dec 30, 2017

That first one just declares the Redact and Redact! commands, so you shouldn't select a range. If you do that and then try running those commands, does it work?

And yes, :'<,'>call redacted#redact(1) should be the exact same thing as :Redact; it does hide every occurrence of the text on the buffer. To only hide specific instances would make things a lot more complicated and I don't think it's worth the trouble for now.

@Ploppz
Copy link
Author

Ploppz commented Dec 30, 2017

Ok, your first command! command did not work (same as earlier). The second command! command made it work as expected, as well as '<,'>call redacted#redact(1).

@dbmrq
Copy link
Owner

dbmrq commented Dec 30, 2017

Aha! I'm not sure why this is happening, maybe it's something about neovim (I only tested on Vim 8), but apparently you're having some trouble with the <range> syntax in call redacted#clear(<range>).

So you can add that second command (command! -range=0 -bang Redact if <bang>0 == 1 | call redacted#clear(0) | else | call redacted#redact(1) | endif) to your vimrc (or whatever the equivalent is in neovim, I never remember). The only problem is that the original command will clear just the selection if something's selected in visual mode, or the whole text if nothing's selected. This second version will clear the whole file no matter what. You can define a different command to clear just the selected text: :command! DifferentCommand call redacted#clear(1).

I don't know why the first command isn't working for you, if it really is related to neovim, or how to fix it, so I'll close this for now. Feel free to reopen the issue if you find out anything relevant. :)

@dbmrq dbmrq closed this as completed Dec 30, 2017
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

2 participants