Tumbler41
Tumbler41

Reputation: 432

(VIM bug report?) Is there a reason that :so $MYVIMRC and filetype=unix shouldn't work together?

I was trying to reload my VIMRC with:

:so $MYVIMRC

However whenever I did my syntax highlighting would break. Everything just goes white as if you did a ":syntax off". After some experimentation I found out that if I removed:

set filetype=unix

from my vimrc that it would work just fine. Any good reason this should happen?

To further my confusion the only way to get the syntax highlighting back was to do a ":e". ":syntax on" does nothing.

Can anyone confirm that this happens to them or give me a reason as to why this is happening?

Upvotes: 1

Views: 46

Answers (1)

romainl
romainl

Reputation: 196466

  1. unix is not a valid value for 'filetype',

  2. therefore Vim tries to source a non-existing syntax script,

  3. therefore your syntax highlighting is broken.

Did you mean set fileformat=unix?

See :help 'filetype' and :help 'fileformat'.


'filetype' is set individually for each buffer.

Since your vimrc is sourced before any file is loaded, that option is not applied to any buffer and promptly overridden as soon as a file is loaded. Therefore you don't get that annoying side effect.

When you source your vimrc manually, set filetype=unix is executed again but now you already have a buffer loaded and your silly command overrides the buffer's filetype, resulting in a broken syntax highlighting.

I know some rules are dumb but "always read the relevant documentation before adding or changing anything to your config" is not.

Upvotes: 2

Related Questions