2

In remove unwanted spaces page in vim wikia, it says:

However, this is a very dangerous autocmd to have as it will always strip trailing whitespace from every file a user saves. Sometimes, trailing whitespace is desired, or even essential in a file so be careful when implementing this autocmd

Why is it so? Is there a situation where it's necessary to have trailing spaces in the end of a line?

4

Is there a situation where it's necessary to have trailing spaces in the end of a line?

The two most common that I encounter are:

  • In the original Markdown you need to use two spaces at the end of line to signal a hard newline (in "GitHub flavoured Markdown" this does nothing, though, since this always adds a newline).

  • For emails the marker for the start of a signature is --<Space>.

There may be other situations as well.

  • format=flowed for emails – Christian Brabandt Mar 16 '17 at 19:14
  • 1
    Vim itself, with inoremap foo bar . – muru Mar 17 '17 at 2:51

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.