Okay the /usr/share/vim/vim74/syntax/sh.vim file that came with my system was apparently buggy, so I want to replace it with the version by "Dr. Chip"

I know that I really should not edit the files under /usr/share/vim/ directory, so can I 'override' the buggy version with the new version by simply sticking the (new) sh.vim file somewhere?

  • Add it to ~/.vim/syntax?
    – muru
    Jun 30 '15 at 12:16
  • 1
    The version in /usr/share/vim/vim74/syntax is by "Dr. Chip" too. It's just an older version of the file.
    – jamessan
    Jun 30 '15 at 14:31
  • Yep, the one already existing is much older than the one available on Dr. Chip's site. I forgot exact version, but IIRC the "Last Change" was in 2013 or something.
    – pepoluan
    Jul 1 '15 at 4:47

When you enter the command :help syn-file they say:

  1. Create your user runtime directory. You would normally use the first item of the 'runtimepath' option. Example for Unix: mkdir ~/.vim

  2. Create a directory in there called "syntax". For Unix: mkdir ~/.vim/syntax

  3. Write the Vim syntax file. Or download one from the internet. Then write it in your syntax directory. For example, for the "mine" syntax: :w ~/.vim/syntax/mine.vim

Now you can start using your syntax file manually: :set syntax=mine You don't have to exit Vim to use this.

I think that should do the trick for your problem.

Also I'm not sure how buggy is your original file but this answer may interest you. For the tl;dr version: including the first line #!/bin/bash (or whatever is the shell you're using) helps vim to determine which syntax should be used (but I don't know if it is relevant in your case).

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.