It seems you don't need to use sed or substitute at all. Just use the change (c
) command. From the documentation:
Visual-block change *v_b_c*
All selected text in the block will be replaced by the same text string. When
using "c" the selected text is deleted and Insert mode started. You can then
enter text (without a line break). When you hit <Esc>, the same string is
inserted in all previously selected lines.
The key here is, "When you hit <Esc>
, the same string is inserted in all previously selected lines." So, all you have to do is block select the cron
text, press c, type at
, exit insert mode and you will get your desired result of replacing each cron
in the block with at
.
If you really want to run a substitution command on a block, I would cut and paste the block to some blank lines, run your substitution on those lines, and then cut and paste the resulting block back to its original location.
The problem with the command you have in your question is you are trying to use the external sed
, and the s
command in sed
doesn't accept a c
flag.