WordPress Vim Syntax Highlighting

May 22nd, 2011 — 9:18pm

Lately I have been doing a lot more work in WordPress. I primarily code in Vim, and it always bugged me there was no syntax highlighting for WordPress in Vim (or at least that I could find), so I decided to write one. I started off pulling all the functions from this page: http://codex.wordpress.org/Function_Reference. However I found this page to be pretty incomplete, so I continued to add functions to the file as I went along.

I decided to release the file to the public in case anyone is looking for WordPress syntax highlighting. Note, by no means is this file complete, but is a good base. Feel free to contact me to fill in any functions I am missing.

Find it on Github

To install, download and place in your .vim/syntax/ directory. Then load by running in vim:

:set syn=wordpress

Or place something like the following in your .vimrc file:

autocmd BufEnter *.php :set syn=wordpress

Category: Vim, Wordpress
Tags: 6 comments »

6 Responses to “WordPress Vim Syntax Highlighting”

  1. Patricio Jimenez

    Awesome!. Thank for plugin.

  2. William Oliveira

    Thank you so much! That’s awesome. Works like a charm! :-)

  3. Will

    So great, thank you.

    Just wanted to note that if you do multiple types of PHP projects and don’t want the WP syntax highlight on *.php, vim is kind enough to support project based .vimrc files. You can place `autocmd BufEnter *.php :set syn=wordpress` there. Here’s how to set it up: http://damien.lespiau.name/blog/2009/03/18/per-project-vimrc/

  4. Stefan Klopp

    Good tip Will, thanks!

  5. Darshan Sawardekar

    Hi Stefan,

    Wish I had found your plugin earlier! I’ve also built a similar syntax highlighter for WordPress.vim[1].

    Did you do this manually? It must have been a lot of work!

    I started with copy-pasting from the Codex Function Reference, but gave up in 10 minutes. Eventually I used phpdocumentor to scan WordPress Core and extract the meta from it instead.

    [1]: https://github.com/dsawardekar/wordpress.vim

  6. Stefan Klopp

    Great work Darshan, your plugin is miles more complete than mine. I didn’t do it by hand. I simply parsed the Codex function reference and parsed out all the function names.


Leave a Reply



Back to top