TheSprintingEngineer
TheSprintingEngineer

Reputation: 319

Add syntax highlighting to certain file extensions for Vim by default

In my machine, files with the .sv extension opens up by default with the Verilog syntax highlighting scheme, however extension with .v or .vs don't. In gVim, I have to manually do :set syntax=verilog every time I open one of these files.

How do I make those file extensions .v or .vs open up in a Verilog syntax highlighting by default?

Upvotes: 10

Views: 30634

Answers (2)

This also worked for me. For some reason, the solution provided above didn't work

" Enable filetype detection, plugins, and indentation
filetype on
filetype plugin on
filetype indent on

" Set Verilog filetype for specific extensions
augroup verilog_ft
  autocmd!
  autocmd BufRead,BufNewFile *.v,*.vh set filetype=verilog
augroup END

Upvotes: 0

sidyll
sidyll

Reputation: 59307

Add an auto-command to your .vimrc to do that for you:

autocmd BufNewFile,BufRead *.v,*.vs set syntax=verilog

Upvotes: 18

Related Questions