Vim: copy/delete line from the first none blank character to the last none blank character
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?开发者_运维问答
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_
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.
精彩评论