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

In most cases, when I copy or delete some code in Vim, use yy or dd , I also got spaces in the indent. Is there a quick command so that I can pull out a string without leading or trailing spaces?

+6
source share
2 answers

I am not a magician, but:

 ^v$gey 

works for me. You can always make an alias.

EDIT: here's the best that doesn't depend on the visual mode.

 ^yg_ 
+7
source

There is another way to solve your alleged problem. After you select lines in the buffer, you can insert them using the appropriate indentation using ]p or ]p . These insert commands automatically adjust the indentation of the nested line (s) to match the indentation of the line where the cursor is.

+6
source

Source: https://habr.com/ru/post/886991/


All Articles