Visual Block: Colon commands will still apply to whole lines
You find in the user manual section 10.3 'Command ranges' following note (almost at the end of :h 10.3
:
Note: When using Visual mode to select part of a line, or using CTRL-V
to select a block of text, the colon commands will still apply to
whole lines. This might change in a future version of Vim.
A substitute command operating on the whole line would look like
:'<,'>s/\(\d*\s*\)\(\d*\)\(\s*.*\)/\=printf('%d %.3f %d', submatch(1), str2nr(submatch(2))*0.7, submatch(3))
Alternative, filter lines through awk
:
:'<,'>!awk '{printf "\%d \%.3f \%d\n", $1, $2*0.7, $3}'
\%V
Please note the answer by @user938271 using the special atom \%V
in a pattern. This circumvents the limitation that colon commands work always on whole lines for the :substitute
command.