Questions tagged [vim-syntax-highlighting]

This is reserved for vim questions which focus on syntax highlighting or colorscheme files.

Vim has a rich syntax highlighting system. Syntax files can be found via :e $VIMRUNTIME/syntax and colorschemes can be found in :e $VIMRUNTIME/colors. These files use special vim commands to color and syntax-highlight different filetypes within vim.

This tag should be used if you have questions specifically about syntax highlighting in vim, since these questions are quite different from standard vim commands and tasks. Make sure you are reporting the correct :echo &filetype in your question and that you have set :syntax on.

If you are trying to add syntax highlighting to a non-standard filetype, then place the downloaded syntax in your ~/.vim/syntax folder and name it <filetype>.vim. Then in your ~/.vimrc, use au BufRead,BufNewFile *.<extension> setl ft=<filetype> where <extension> is the extension of the filetype and <filetype> is the name you saved the syntax file as.

For more information on vim syntax highlighting see :help syntax in vim, which provides some excellent documentation.

372 questions
129
votes
7 answers

Enable Vim Syntax Highlighting By Default

I know how to turn syntax highlighting on and off in vim by running this in the editor: :syntax on/off But I want syntax highlighting to be enabled by default, so I don't have to turn it on every time I run vim. How do I do this?
lilroo
  • 2,631
  • 7
  • 22
  • 31
87
votes
5 answers

Syntax highlighting in vim for python

How do I do I set the syntax highlighting in Vim 7 for python? I would like to set my own colorschemes, and syntax highlighting for a type of code file.
hidroto
  • 1,053
  • 2
  • 9
  • 9
78
votes
12 answers

How to highlight Bash scripts in Vim?

My Vim editor auto highlights PHP files (vim file.php), HTML files (vim file.html) and so on. But when I type: vim file and inside it write a Bash script, it doesn't highlight it. How can I tell Vim to highlight it as a Bash script? I start typing…
never_had_a_name
  • 80,383
  • 96
  • 257
  • 374
74
votes
11 answers

class & function names highlighting in Vim

I just recently set up my Vim environment from Textmate, after becoming addicted to its modal input. However, syntax highlighting seems to be not so beautiful in Vim. I code in C++ and since the function call and class names can't be highlighted,…
59
votes
11 answers

Add GoLang syntax highlighting for VIM

I'm trying to add Go language syntax highlighting to VIM on ubuntu with resources and direction supplied here http://go-lang.cat-v.org/text-editors/vim/. Go comes with a go.vim file that contains syntax settings for VIM and the above page offers the…
rocketas
  • 1,569
  • 3
  • 16
  • 29
49
votes
5 answers

Javascript syntax highlighting in vim

Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting. Are there any…
Steve M
  • 10,311
  • 12
  • 48
  • 63
46
votes
9 answers

Vim Syntax Highlighting does not work

I've installed a fresh Arch Linux system on my laptop and downloaded the vim package. I haven't altered the .vimrc file, but the syntax highlighting doesn't seem to work with any of the languages I tried (Python, Ruby, CSharp, C...). Auto formatting…
Gilad Naaman
  • 5,828
  • 14
  • 48
  • 78
36
votes
4 answers

TypeScript syntax highlighting in vim

I installed the typescript plugin via git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vim and inserted au BufRead,BufNewFile *.ts setfiletype typescript into by ~/.vim.rc. Linting via Syntastic and…
Nico Schlömer
  • 37,093
  • 21
  • 139
  • 189
33
votes
8 answers

Vim syntax highlighting with $ and lstlisting's lstinline

If I use the inline version of lstlisting as shown: \lstinline{!$omp parallel for} the syntax highlighting in vim goes wrong, and the remainder of the latex file is coloured red as if it is all part of the code listing. It's the dollar $ which…
user2023370
  • 9,597
  • 5
  • 41
  • 74
31
votes
4 answers

assembly vim syntax highlighting

The default assembly syntax file didn't work well and searching the web about gas assembly I found nothing about a gas (AT&T) syntax file for vim. Has anyone found this? I can't write my own syntax…
Pwn
  • 3,051
  • 11
  • 35
  • 42
29
votes
4 answers

Vim inconsistently syntax highlighting bash files

When I open some bash script files with vim it sometimes identifies them as conf files, that's okay, I can just correct that by setting the filetype to sh with :setf sh. That great, except I've noticed that this doesn't fix things entirely: Notice…
Peter Coulton
  • 50,723
  • 11
  • 51
  • 70
27
votes
2 answers

How to set a custom color to folded highlighting in .vimrc (for use with putty)

Adding the following to .vimrc works :hi Folded ctermbg=Grey but it's still too bright and prominent, so we want to specify a more specific color triplet instead, like so: :hi Folded ctermbg=#A0A0A0 but vi won't accept it: Error detected while…
silvernightstar
  • 1,745
  • 3
  • 17
  • 23
19
votes
5 answers

How to avoid syntax-highlighting for large files in vim?

Huge files take forever to load and work with in vim, due to syntax-highlighting. I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless.
Paul Oyster
  • 2,127
  • 3
  • 17
  • 13
18
votes
5 answers

Razor .cshtml syntax highlighting for vim?

I'm looking for a .cshtml vim syntax file. Are there any projects that haven't made it to www.vim.org?
John Weldon
  • 37,037
  • 10
  • 91
  • 126
18
votes
2 answers

How to syntax highlight fragments of code in one language embedded in the source code in another language in Vim?

I have a custom XML file format which can contain blocks of code within certain tags. For example: select * from foo ...
HS.
  • 14,004
  • 8
  • 36
  • 46
1
2 3
24 25