Skip to main content
added 300 characters in body
Source Link
muru
  • 25.1k
  • 8
  • 83
  • 144

You'll probably have to do a double substitution:

s/\v\d+\.\d+/\=substitute(submatch(0),'.',' ','g')/g

This uses an expression for the replacement (:h sub-replace-expression), which simply replaces every character in the matched string (submatch(0)) with a space (subtitute(..., '.', ' ', 'g')).

Or, repeat :

s/\v\d+\.\d+/\=repeat(' ', len(submatch(0)))/g

Perhaps simplest of all would be to use visual selection based on searching. First, search for /\v\d+\.\d+ to get the floating point numbers, then press gn to visual select the next matching one. Then do (r, then space) to replace all the selected characters with spaces. Use as a macro.

You'll probably have to do a double substitution:

s/\v\d+\.\d+/\=substitute(submatch(0),'.',' ','g')/g

This uses an expression for the replacement (:h sub-replace-expression), which simply replaces every character in the matched string (submatch(0)) with a space (subtitute(..., '.', ' ', 'g')).

Or, repeat :

s/\v\d+\.\d+/\=repeat(' ', len(submatch(0)))/g

You'll probably have to do a double substitution:

s/\v\d+\.\d+/\=substitute(submatch(0),'.',' ','g')/g

This uses an expression for the replacement (:h sub-replace-expression), which simply replaces every character in the matched string (submatch(0)) with a space (subtitute(..., '.', ' ', 'g')).

Or, repeat :

s/\v\d+\.\d+/\=repeat(' ', len(submatch(0)))/g

Perhaps simplest of all would be to use visual selection based on searching. First, search for /\v\d+\.\d+ to get the floating point numbers, then press gn to visual select the next matching one. Then do (r, then space) to replace all the selected characters with spaces. Use as a macro.

Source Link
muru
  • 25.1k
  • 8
  • 83
  • 144

You'll probably have to do a double substitution:

s/\v\d+\.\d+/\=substitute(submatch(0),'.',' ','g')/g

This uses an expression for the replacement (:h sub-replace-expression), which simply replaces every character in the matched string (submatch(0)) with a space (subtitute(..., '.', ' ', 'g')).

Or, repeat :

s/\v\d+\.\d+/\=repeat(' ', len(submatch(0)))/g