- Auto-Completion for the WordPress API
- WordPress Hooks Integration
- WP-CLI Integration
- Jump to Definition in WordPress Core
- UltiSnips Snippets
- Syntax Highlighting for WordPress PHP files.
- Markdown Syntax Highlighting for readme.txt
- PHPCS Syntax Checker integrated with WordPress Coding Standards
- Search in Codex
- Integration with WpSeek API.
- Readme.txt Auto Validation.
WordPress.vim extends phpcomplete.vim to provide Auto-Completions for WordPress PHP files. If you have phpcomplete.vim installed no additional configuration is required.
The demo below shows Auto-Completion of the WP_Query
class and other
API functions.
See :h wordpress-auto-completion
for more.
WordPress.vim has close integration with the WordPress action and filter
hooks. This feature uses ctags
and is further enhanced with the
presence of CtrlP.vim.
The demo below shows navigation to a few hooks with the ex commands
:Waction
and :Wfilter
and their CtrlP variants, :CtrlPaction
and
:CtrlPfilter
.
See :h wordpress-hooks-integration
for more.
WordPress.vim is closely integrated with WP-CLI. You can easily run
WP-CLI commands without leaving Vim. It maps the wp {command}
to Vim's
Ex commands of the form :W{command}
.
The demo below shows :Wscaffold plugin
in action. Also seen are the
:Weval
and :Wplugin
commands.
See :h wordpress-wp-cli
for more.
Jump to Core takes you to the implementation of a function in Core. You can easily move around the code base and return once you've figured out what you need.
The demo below starts out in a theme then jumps to different Core functions and finally returns back to the starting point.
See :h wordpress-jump-to-core
for more.
WordPress.vim comes with a few useful snippets to speed up common WordPress development tasks. Snippets require the UltiSnips snippets engine plugin to be installed.
A Snippet is like an interactive Web Form. Once you enter a Snippet you are put at the first placeholder. As you start typing the placeholder changes and also affects any dependent placeholders. You can cycle back and forth between placeholders and Escape out when done.
The demo below shows the theme header
snippet in action.
See :h wordpress-snippets
for more.
WordPress.vim extends the default PHP syntax highlighting with support for the WordPress API. Importantly it highlights the use of any deprecated function as Errors.
Note the highlighting of the deprecated is_taxonomy
function.
Additionally the readme.txt
found in WordPress files is highlighted as
Markdown.
See :h wordpress-syntax-highlighting
for more.
The :Wcodexsearch
Ex command provides searching for keywords on the Codex. When
arguments are omitted it uses the current Visual selection or the word
under the cursor to query for.
For faster searches, You can map this to a key sequence like, <leader>co
with,
:nnoremap <leader>co :Wcodexsearch<CR>
WordPress.vim integrates with the WpSeek API. This allows searching using the wpseek api directly from within Vim.
The demo below shows the :Wsimilar
Ex command in action.
see :h wordpress-wpseek-integration
for more.
The repository includes a minimal Vimrc for trying out WordPress.vim without affecting your existing Vim configuration. Plugin management is done with Vundle.
First backup your existing vimrc.
$ mv ~/.vimrc ~/.vimrc_backup
Then download the minimal vimrc to a temporary directory like
/tmp/wordpress_vim
.
$ mkdir -p /tmp/wordpress_vim
$ wget -O /tmp/wordpress_vim/vimrc https://raw.githubusercontent.com/dsawardekar/wordpress.vim/develop/examples/minimal_vimrc.vim
Link the tmp vimrc to your $HOME
vimrc.
$ ln -s /tmp/wordpress_vim/vimrc ~/.vimrc
Now start Vim.
The first time the vimrc
will download Vundle to the /tmp/wordpress_vim
directory and then
proceed to install the required plugins using Vundle. Plugins will be
installed in the subdirectory /tmp/wordpress_vim/bundle
.
Installation may take a few minutes. Once completed you will have a custom vim configuration separate from your existing one.
To move to your old configuration simply link your backup vimrc back to the
$HOME
vimrc.
1. With Vundle
Plugin 'dsawardekar/wordpress.vim'
2. With NeoBundle
NeoBundle 'dsawardekar/wordpress.vim'
3. With Pathogen
git clone https://github.com/dsawardekar/wordpress.vim ~/.vim/bundle/wordpress.vim
WordPress.vim requires Vim 7.3p97+ with Python support.
WordPress.vim uses Progressive Enhancement to enable/disable features. This means that the features that depend on other plugins/external tools are only enabled if their presence is detected. A missing requirement will not affect the behaviour of the rest of the plugin.
It is highly recommended to install the following plugins to get the best experience.
- phpcomplete.vim - Enables Auto-Completion
- SuperTab or YouCompleteMe - More intuitive Auto Completion & integration with UltiSnips
- UltiSnips - Enables Code Snippets
- php.vim - Better PHP Syntax Highlighting
- vim-markdown - Enables Markdown Syntax Highlighting of readme.txt
- open-browser.vim - Enables Search in Codex &
:Wtopics
launching. - CtrlP.vim - Enables Fuzzy matcher integration for WordPress hooks.
- Syntastic - For the PHPCS Syntax Highlighter Integration.
Additionally the following tools enhance WordPress.vim.
- WP-CLI - Enables :W ex commands & automatic WordPress path lookup.
- Exuberant CTags - Enables the Jump to Core Definition feature
To install ctags
,
- On Ubuntu, use
apt-get install exuberant-ctags
- On Mac, use
brew install ctags
WordPress.vim builds on top a number of other excellent Projects. Many Thanks in particular to,
- Shawn Biddle - for phpcomplete.vim
- Cristi Burcă - for WP-CLI
- Luke Gruber - for Riml
- Oliver Schlöbe - for the WpSeek API
- Sudar Muthu - for the Syntastic Integration.
WordPress.vim needs the help of the WordPress community to keep improving. Please consider joining this effort by providing new snippets, new features or bug reports.
If you find that a feature is missing or find a bug, please contact me or and add an issue to the issues tracker.
For further details on setting up a development environment for WordPress.vim and the implementation of the plugin see CONTRIBUTING.md.
WordPress Hook IntegrationDONEFind current word in CodexDONEHighlight ConstantsDONE- Improve snippets
Integrate with the wpseek.com APIDONE- Improve Javascript Support
Figure out how to run WP-CLI shell commands.DONE- WPSE integration.
MIT License. Copyright © 2014 Darshan Sawardekar.