Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax highlighting bugs of VIM 7.3 for BASH scripts [closed]

I just upgraded OS from Ubuntu 8.04 to Ubuntu 12.04, as well as the corresponding VIM package. However, I found the syntax highlighting of newer VIM for BASH scripts is strange: (1) the colors of open and close parenthesis are different; (2) the color of comments seems wrong; (3) the BASH keyword in comment should not be highlighted. I have already add let g:is_bash=1 and syntax on into my ".vimrc" file. I am not sure whether this is a bug of VIM or something wrong of my settings. Any solutions to this problem? Thanks.

The screenshot of wrong syntax highlighting. enter image description here

The screenshot of corresponding correct syntax highlighting: enter image description here

The new (wrong) VIM version is: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:21:49) Included patches: 1-429

The old (correct) VIM version is: VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Sep 21 2009 11:21:42) Included patches: 1-245

like image 529
Yun Huang Avatar asked Dec 15 '22 22:12

Yun Huang


1 Answers

Firstly, all Bash syntax highlighters are broken in a thousand ways. This isn't unusual. You simply can't rely on editors to parse Bash correctly, the grammar just allows way too many complex possibilities. Vim does a better job than most.

Make sure you have the very latest syntax file from Dr Chip's page. It isn't always up-to-date in Vim.

I believe you're mostly noticing some basic error highlighting that was added at some point, which gets it wrong quite frequently and messes up your code with ugly red text. I noticed a new variable added a few versions back for disabling this that isn't documented yet. let g:sh_no_error=1 fixes up most of these issues for me.

As a side-note, anybody using terminal vim especailly with a 256-color scheme should really be using csapprox. Whenever I see screenshots of that weird light-blue color mixed with yellow it usually means csapprox isn't being used. I have no idea why it isn't included with vim and enabled by default.

like image 85
ormaaj Avatar answered Dec 21 '22 09:12

ormaaj