开发者

Removing trailing whitespaces same as vim [closed]

开发者 https://www.devze.com 2023-03-05 13:56 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Based on this vimcast I changed my .vimrc file.

http://vimcasts.org/episodes/tidying-whitespace#highlighter_963342

Now every single time I touch a file that file has a number of changes related to trailing whitespaces. In one single sweep I want to remove all the trailing whitespaces.

It is trickier though.

Make sure that you don't remove end of line character. vim code takes care of that.

if a line does not have trailing whitespace then that line should not be marked as ch开发者_运维技巧anged by git.


I'm having a hard time interpreting your question -- not sure where git enters in -- but assuming you're looking for a shell command to remove trailing whitespace from each line:

sed 's/[[:space:]]\+$//'

To visually confirm that it's removing whitespace:

cat -E afile
sed 's/[[:space:]]\+//' afile | cat -E


git config --global apply.whitespace nowarn

http://help.github.com/git-cheat-sheets/

0

精彩评论

暂无评论...
验证码 换一张
取 消