I am looking to make some code easier to read by taking something like this:
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 ....
and adding new lines to create increments of 8:
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44 ....
Anyone know any vim magic that will allow me to do this with specifically selected lines?
vim Inserting text Insert text into multiple lines at once Press Ctrl + v to enter into visual block mode. Use ↑ / ↓ / j / k to select multiple lines. Press Shift + i and start typing what you want. After you press Esc , the text will be inserted into all the lines you selected.
Step 1: Move the cursor to the line from where you would like to insert the text. Step 2: Hit Ctrl + V to enter into Visual Block and use cursor to select the first column till line where you want to stop inserting the text. Step 3: Hit Shift + i to enter into insert mode .
This is not the prettiest solution and I am sure that it can be cleaned up / simplified some. First select the text and then enter this command:
:'<,'>s/\(\S\+,\s*\)\{8}/&\r/g
This outputs something like this:
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44, 0x44, 0x44, ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With