Vim doesn't highlight bash script syntax (msysgit version)

I use bash and vim that come with msysgit. I added the .vimrc file to my home folder, and most of the commands I execute. But syntax on 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 selection now works, but syntax on does not work. Msysgit installs its own vim and in the folder C:\Program Files (x86)\Git\share\vim\vim73\syntax it does not contain the bash.vim or sh.vim file. Other files are where conf.vim, gitcommit.vim and gitrebase.vim are even c.vim.

I guess so there is no backlight. Given that I cannot touch this folder (not ask), how can I change the .vimrc file to load the bash.vim file - and what is a good place to get it?

Any help is appreciated.

+6
source share
4 answers
  • search and download sh.vim via google or whatever you prefer.
  • move sh.vim to the $HOME/vimfiles/syntax/ directory, then when you open the shell script, it will take effect for this.

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

+6
source

Have you tried to enable the filetype plugin?

 :filetype plugin on 

Then, if your script syntax still does not color correctly, try manually overriding:

 :set ft=sh 
+2
source

I am not familiar with msysgit, but to answer your last question:

how can i modify the .vimrc file to load the bash.vim file

you can add:

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

This can be useful if you have an installed copy available and you do not want to keep your own copy.

+1
source

In my case, everything in ~ / .vim / view has been deleted. I was mkview under autocmd , so when I did not close vim and bash correctly, I think some files are corrupted. I found this problem by moving the files that were causing me problems in another directory and finding out that vim had no problems displaying their syntax correctly.

0
source

Source: https://habr.com/ru/post/891182/


All Articles