你怎么能自动删除在vim尾随空格 [英] How can you automatically remove trailing whitespace in vim

查看:340
本文介绍了你怎么能自动删除在vim尾随空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到结尾的空白错误试图犯git的一些文件。

I am getting 'trailing whitespace' errors trying to commit some files in git.

我想我之前保存Python文件,自动向右删除这些尾随空格字符。

I want to remove these trailing whitespace characters automatically right before I save python files.

您可以配置VIM做到这一点?如果是这样,怎么样?

Can you configure vim to do this? If so, how?

推荐答案

我找到了答案<一个href=\"http://vim.wikia.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace\">here.

添加以下到我的.vimrc文件的伎俩。

Adding the following to my .vimrc file did the trick.

autocmd BufWritePre *.py :%s/\s\+$//e

这篇关于你怎么能自动删除在vim尾随空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆