0

I want to translate characters in vim like with the command line tool tr or with sed:

$ echo 'foo bar' | sed 'y/for/tes/'
tee bas

So I want to replace all occurrences of certain characters with other characters.

romainl
  • 186,200
  • 21
  • 280
  • 313
kefomo
  • 27
  • 5

2 Answers2

0

I don't know of a way you can do this with vim out of the box, but the plugin vim-abolish enables something along these lines:

:S/{f,o,r}/{t,e,s}/g

This will do the same thing as the sed command you posted.

johnmastroberti
  • 847
  • 2
  • 12
0

You can filter the content of the buffer through arbitrary external commands with :help :range! so you can simply use the tools you are used to:

:%!sed 'y/for/tes/'
:%!tr for tes

See also :help ! and :help !!.

romainl
  • 186,200
  • 21
  • 280
  • 313