Let's consider our cursor at the first line, column zero
f' ....................... jumps to the first single quote
Use visual block selection to cut the three first lines
Ctrl-v ................... starts visual block selection
2j ....................... expands to the next two lines
$ ........................ makes selection expand to the end of the ...
You can do this with a macro. Start by placing your cursor at the very start of the file gg and then type the following:
This records a macro that will update a single line in the way you require. Then undo your changes uu and play the macro on every line of the file by entering the command:
How the macro works:
qq Start ...
You could use a substitution command like this one:
The command can be decomposed in these several parts:
% is the range of lines you want to apply the command to. % is all the lines in the buffer, check :h :range for more options
s/ [...] / [...] is the substitution which will replace the first part by a second ...
You could try this:
For more info, see:
Figure could be 5, 5.0, 5.00 or 5.000, 12345678.000, 3 digits at most. How can we define a more general grouped part?
Try a more permissive pattern:
:B from plugin vis.vim by DrChip: :B s/pattern/becomes/
This plugin provides a general command to make all colon commands to operate only on the visual block selection:
:'<,'>B s/\d*/\=printf('%.3f', str2nr(submatch(0))*0.7)
:Substitute for visual block from plugin csv.vim
For single-space separated data you have to initialize the plugin csv.vim manually as following:
$ vim mydata
:let g:csv_delim=' '
Now you can use the :Substitute command:
Select part of a column with a visual block (e.g. 5\n8) and then run
:'<,'>Substitute \d*/\=printf('%.3f', ...
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 ...