Visual block insert/append line breaks?
This is failing for me and I expected it to work. Let's say I have a file full of data like this:
absolute_length_data:variable_length_data
Many, many lines of it. My mission: create line pairs of absolute length data and variable length data. It's not a clear-cut separator character; imagine that the colon separator can appear 0 or n times in the absolute length data, and it can also appear 0 or n times in the variable length data.
I had hoped that I could Ctrl-v and then find the absolute length separator, move down to block highlight all the lines I want to separate, and then A<CR><Esc> to break the lines up. But it only seems to insert on the first line of the visual block (tested with Vim up to 7.4.52). If I did it as a literal (A<C-v><CR>) vim shows the ^M in the line instead of making a linebreak, even though I can :%s/foo/<C-v><CR>/ and that replaces foo with linebreaks.
I ultimately accomplished my goal by doing a macro with position counting, but I still am curious as to why the visual block append didn't work, or how I could make that strategy work.
Posted Oct 14, 2013, 4:26 PM UTC
I assume you know the column number, then? Simply do this:
where ## is the column number.
That's cool. I always forget that you can do a lot of magic with vim regex.