开发者

Vim: copy/delete line from the first none blank character to the last none blank character

开发者 https://www.devze.com 2023-03-02 07:53 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消