Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim not highlighting syntax for bash scripts (msysgit version)

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.

like image 207
Adam Dymitruk Avatar asked Jun 23 '11 05:06

Adam Dymitruk


3 Answers

  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

like image 147
quabug Avatar answered Nov 14 '22 21:11

quabug


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
like image 2
Celsius1414 Avatar answered Nov 14 '22 21:11

Celsius1414


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.

like image 1
JFlo Avatar answered Nov 14 '22 22:11

JFlo