I just learned about the shortcuts that allow you to manipulate ranges, e.g. :+5,+10co.
to copy after the current line.
I wondered if there is a way to copy and move at the start of the current line?
Currently I have to move the cursor at the end of the preceding line in order to attain the desired result.
To illustrate, given the following file, with the cursor being at line 5:
3 A
4 B
→ 5
6 C
7 D
Applying a copy via :+1,+2co.
results in the undesired empty line at line 5:
3 A
4 B
5
6 C
→ 7 D
8 C
9 D
Is there a way to copy at the start of the current line or is one limited to perform this command at the end of the preceding line?
a way to copy and move at the start of the current line
That does not make sense for linewise (Ex) commands: "copy" can add after or before the current line. But it does not replace existing lines (even empty ones). Either don't create unneeded empty lines, or delete them manually, or use "normal" commands. – Matt Nov 17 '19 at 11:17g_
is a motion to the last non-blank character of the current line and [count-1] lines downward. So if we doy2g_
we'll do a characterwise yank of two lines. Then we could do5Gp
to move cursor to line 5 and paste yanked text after it. IOW, one might find it easier to remove line 5 first and use your original commands... ;) – B Layer Nov 17 '19 at 12:44+1,+2co-1
or something like that. – Matt Nov 17 '19 at 12:47