1

I have some code that I want to 'censor'. For example, I have secret token in a source code 1f85ez and I want to replace it with xxxxxx

Now I do it with viwrx command. Is there way to make such a substitution without visual mode?

5
  • 2
    You could make a mapping for it... other possible solutions seem too clunky. (Counting works, e.g. 5rx, but takes so much time.) What’s wrong with visual mode? You could always write a new operator that replaced whatever was operated on! Then e.g. yriwx would do the trick (similar to how surround.vim functions). But again, at this point, what’s wrong with visual mode?
    – D. Ben Knoble
    Dec 27, 2018 at 14:39
  • I'm not sure I understand your problem. Can't you just :s/1f85ez/xxxxxx/g ? What is your particular situation that makes this solution not good enough? Please give us more details, that might help us find the best solution.
    – msb
    Dec 28, 2018 at 6:13
  • @D.BenKnoble nothing wrong, I guess. Thanks. Dec 28, 2018 at 8:38
  • @msb yep, but if you have 60 characters (not 6) it's not a good way to make such a substitution. Dec 28, 2018 at 8:39
  • :exec "s/" . expand("<cword>") . "/" . repeat('x', strlen(expand("<cword>"))) :p ;)
    – B Layer
    Dec 30, 2018 at 11:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.