Opposite of J
In VIM you can use the command J
to join to lines:
hello -> J -> hello goodday
goodday
Where the cursor is positioned somewhere on the ‘hello’ line.
But I often find myself wanting to use the opposite, I want ‘hello’ to be put after ‘goodday’. The cursor is now positioned on the ‘goodday’ line.
hello
goodday -> K -> goodday hello
The following mapping does that:
map K kddpkJ
In words:
- Go up 1 line:
k
- Delete the entire line:
dd
- Paste line below the current one:
p
- Go up again:
k
- Perform the join:
J
In less words: switch the lines and then do a join.
Read other posts