Using only vim's motions and yanking/pasting.. Given the file contents of..
1234567890abcdef
qwertyuiopasdfgh
With the cursor on q, 10x
, file becomes:
1234567890abcdef
asdfgh
Move the cursor to the first line (using k
will do it), then do 10yl
(yank 10 characters, right)
Then move back down one line, j
, and paste P
(upper case, to paste under cursor) and the file becomes:
1234567890abcdef
1234567890asdfgh
In short, starting with the cursor on q:
10xk10yljP
..which you could paste in, or assign to a macro
It would be shorter if there was an obvious shortcut to paste by overwriting, but I couldn't find such a thing
One other option is an incredibly obscure looking regex search/replace..
Visual-line select the two target lines, and run the following search-and-replace:
:'<,'>s/\(\(.\{10\}\).*\)\n\(.\{10\}\)\(.*\)$/\1\r\2\4/
Basically it grabs..
\1
- the entire first line
\2
- the first 10 characters (in a nested group)
- a linebreak
\3
- the first ten characters of line two
\4
- the rest of the second line
Then it constructs the two lines as \1\n\2\4
- complete first line, linebreak, first 10 characters of first, remainder of second