Vim deletes spaces at the beginning and end of each line.

Source: Internet
Author: User
Delete unnecessary Spaces

End of line: $
Beginning of line: ^
Space: \ s

Space at the end of the line: \ s \ + $
Space at the beginning of the line: ^ \ + \ s

Some people think that the space at the end of a row is useless and ugly. To delete unnecessary spaces behind these lines, you can
Run the following command:

: % S/\ s \ + $ //

The command specifies that the range is "%", so this will apply to the entire file. The matching mode of the "substitute" command is
"\ S \ + $ ". This indicates one or more (\ +) spaces (\ s) before the end of the line ($ ). What will we introduce later?
Write this mode.
The "to" part of the replacement command is empty :"//". In this way, the matching spaces are deleted.

Another unused space is the character before the tab. This can be deleted without affecting the format. But this is not always the case
Sample! Therefore, you 'd better manually delete it. Run the following command:

/

You can't see anything. In fact, this is a space and a tab key. It is equivalent to "/<space> <tab> ". Now,
You can use "X" to delete unnecessary spaces and ensure that the format is not changed. Then you can use "N" to find the next
And repeat the operation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.