About Me

Training

Develop With Passion® - Developer Bootcamp

Subscribe

Getting Syntax Highlighting For You Powershell Scripts (GVim)

Written September 12, 2008 at 07:00 MDT Tagged tools

I was asked this question at my last course so I thought I would share the answer with everyone!!
To get syntax highlighting for the powershell scripts that I edit I first downloaded a set of syntax files provided by Peter Provost. You can download the files from here:
http://www.vim.org/scripts/script.php?script_id=1327 (Syntax File)
http://www.vim.org/scripts/script.php?script_id=1815 (Indent File)
http://www.vim.org/scripts/script.php?script_id=1816 (File Type Plugin)
Once I had copied those files into the appropriate folders:
$VIMRUNTIME\syntax
$VIMRUNTIME\indent
$VIMRUNTIME\ftplugin
I had to edit my $VIMRUNTIME\filetype.vim and add the following line:
" Powershell
au BufNewFile,BufRead *.ps1 setf ps1
With that done I can open up a powershell file and get syntax highlighting.
Question for the long time Vim users. Can I not just place the files in the appropriate folders and have gvim automatically pick them up without having to edit the filetype.vim file?
Develop With Passion!!