A simple method for automatically removing spaces at the end of a line using vary. vim in python encoding

Source: Internet
Author: User
Tags in python

I have always wanted to change to emacs, but it is hard to work efficiently, so vim has not completely abandoned it. My colleagues who want to be python may have the same troubles:

When maintaining others' code, it is found that many tabs and spaces are mixed or the spaces at the end of the line are not deleted.

I may not have noticed this problem before, that is, consciously using the ed mode: % s/s + $/g and: retab. Recently, the boss reminded me: he asked me if vim can be set to automatic mode? With my understanding of vim, it will certainly not be involved in personal editing, so it is possible to use the hook method.

This is my vary. vim principle: the command is automatically executed when the file is saved (: w. in fact, I think you may ask, why is it when I save it, not when I open it? Which will be discussed below
For installation configuration, see README of the project.

After installation, if not configured, it only takes effect for the python language by default-the team and language style are different.
Modify my vim plugin

I have been wondering which method is more reasonable (when the file is opened and modified or saved). By default, I save it, but you can actually modify my autocmd command:

The code is as follows: Copy code
Autocmd BufReadPost *: call StripTrailingWhite ()
Autocmd BufReadPost *: call RetabIndents ()


Indicates that the modification is made before the file is opened, and the modified result is displayed to you.

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.