vim delete the end of each line begins with a space

Remove the extra space

end of the line: $ 
beginning of the line: ^
space: \ s

end of the line spaces: \ s \ + $
beginning of the line spaces: ^ \ + \ s


Some people think that the space at the end of the line is useless, wasteful and unsightly. To remove the extra spaces behind each of these lines, you can
execute the following command:

:% S / \ S \ + $ //

line range is "%", so it works on the whole file. "substitute" match mode command is
"\ s \ + $". This indicates the end of line ($) before one or more (\ +) space (\ s). We will look at how to
write such a model.
Replace command "to" section is empty: "//." This will delete those whitespace characters to match.

Another use of spaces in front of Tab characters. Usually this can be deleted without affecting the format. But this is not always
kind! So, you better manually delete it. Execute the following command:

/

You could not see anything, in fact, this is a space and a TAB key. Corresponds to "/ <Space> <Tab> ". Now,
you can use the "x" to delete extra spaces, and to ensure that the format has not changed. Then you can use the "n" to find the next
position and repeat the operation.

 

Turn: https://my.oschina.net/damoco/blog/673217

Guess you like

Origin www.cnblogs.com/sweet22353/p/12123446.html