The solution I learned today (thanks to CMS who answered this question) is to use VIM's text object motions.
Put the cursor in the entry to copy, and type the following in command mode: yat
:
y
yanks according to the following movement.
at
selects the current tag.
Note that if the cursor is inside the "ArrayType" tag, then that's what will be yanked.
Also note that this won't yank the entire lines. Only from the opening brace of the opening tag to the closing brace of the closing tag. This may cause alignment issues if you're not careful.
One way to get around this is by pasting with :put
instead of just p
, like this: yat:put
.
Note that this won't preserve indentation, because the XML entry wasn't yanked as a whole line.
Another way to do it is: vatVy
:
v
enters Visual Mode.
at
is as above.
V
switches to Line Visual mode and selects the entire line.
y
yanks the selection.