2

I am currently trying to edit a git hunk file (a diff: .git/addp-hunk-edit.diff), and to say to git that a line containing whitespace is unchanged it needs to have (a line with a single space) as its first character. The problem is that Vim removes all whitespace in otherwise empty lines as soon as I save the file!

This only happens on this file type, not for for instance .vimrc. How can I manually disable this behavior, and even better, permanently disable it for diff files?

  • MacVim 7.4.77, installed via Homebrew.
  • My .vimrc
5

Since there was nothing explicit in my .vimrc that acted on only-whitespace lines and the diff syntax file did no such thing either, this had to with my plugins somehow. I find out that I had an EditorConfig file in this project, and in it it had these lines:

[*]
# other
#stuff 
trim_trailing_whitespace = true

I then subsequently added a section for diff files

[*.diff]
trim_trailing_whitespace = false

and voila, everything works as intended :)

  • 2
    Good call. I knew it was editorconfig just by reading the title ;-) – romainl Jul 28 '16 at 9:28
  • You should accept your own answer. – henrebotha Feb 5 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.