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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this community
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?: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.:exec "s/" . expand("<cword>") . "/" . repeat('x', strlen(expand("<cword>")))
:p ;)