Reputation: 15917
Most time when I copy or delete some code in Vim use yy
or dd
, I also got the indent spaces. Is there a quick command that I can yank a line without leading or trailing spaces?
Upvotes: 6
Views: 405
Reputation: 992737
There's another way to solve your implied problem. After you yank line(s) into the buffer, you can then paste them using the appropriate indent using ]p
or ]P
. These paste commands automatically adjust the indent of the pasted line(s) to match the indent of the line where the cursor is.
Upvotes: 6
Reputation: 60463
I'm not a wizard, but:
^v$gey
works for me. You can always make an alias.
EDIT: here's a better one that doesn't rely on visual mode.
^yg_
Upvotes: 7