6

I'm using the bash and vim that come with msysgit. I've added the .vimrc file to my home folder and most of the commands there are executing. But syntax on is not.

This is the contents of my ~/.vimrc file:

set cul
hi CursorLine cterm=none ctermbg=darkgray ctermfg=white
syntax on

The current line and highlighting is now working, but the syntax on is failing. Msysgit installs it's own vim and in the C:\Program Files (x86)\Git\share\vim\vim73\syntax folder, it does not contain a bash.vim or sh.vim file. Other files are in there like conf.vim, gitcommit.vim and gitrebase.vim - even c.vim.

I'm guessing this is why there is no highlighting. Given that I can't touch that folder (don't ask), how can I change my .vimrc file to load up a bash.vim file - and what's a good place to get one?

Any help is appreciated.

11
  • does ":set syn=sh" turn the highlighting on? Commented Jun 23, 2011 at 5:16
  • ok, can you see ANY syntax highlighting? On a C file (since it seems to have c.vim)? With or without forcing with ":set syn=c" ":syn on" Commented Jun 23, 2011 at 5:22
  • can try on superuser, the user there should have the better answer Commented Jun 23, 2011 at 5:35
  • I see syntax hilighting when I commit or rebase interactively. Seems that the files in the directory I mention are doing their job. Commented Jun 23, 2011 at 5:35
  • there exists a c.vim file in there and sure enough, when I open a .c file, it's highlighted. Commented Jun 23, 2011 at 5:40

4 Answers 4

6
  1. search and download sh.vim via google or anything else you prefer to.
  2. move sh.vim to $HOME/vimfiles/syntax/ directory, then when you open a shell script it'll take effect for that.

http://vimdoc.sourceforge.net/htmldoc/usr_44.html#44.11

Sign up to request clarification or add additional context in comments.

1 Comment

For the record it's $HOME/vimfiles/syntax/, and syntax files can be found here or directly sh.vim.
2

Have you tried enabling the filetype plugin?

:filetype plugin on

Then, if your script syntax still doesn't colorize properly, try manual override:

:set ft=sh

Comments

1

I'm not familiar with msysgit, but to answer your final question:

how can I change my .vimrc file to load up a bash.vim file

you should be able to add:

if filereadable(expand("$HOME/some/path/bash.vim"))
    execute "source " . "$HOME/some/path/bash.vim"
endif

This might be useful if you have a reachable installed copy and don't wish to maintain your own copy.

Comments

0

In my case deleting everything in ~/.vim/view helped. I had mkview under autocmd, so when I did not shut down vim and bash properly, I think some files got corrupted. I found this problem by moving the files that were giving me trouble in another directory and finding out that vim had no problem showing their syntax properly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.