This project customizes the vim text editor for editing Drupal-related files. Who needs an IDE?

This project started as a single vimrc file, but that made it difficult to use Vim for non-Drupal work. The project now is plugin-based for ease of use and extension.

We have extensive documentation, including installation instructions.

See also the Configuring vim page in Drupal.org handbook, although most of the suggestions there have already been incorporated into this project.

Installation for the impatient

$ drush @none dl vimrc
$ drush help vimrc-install
$ drush -v vimrc-install <options>

The following screenshot is described on the Insert-mode features page in our section of the developers' handbook.

Screenshot of vim in action with omni-completion

As of this writing, the project includes the following files. (See README.txt for a complete, updated list.)

ftplugin/drupal.vim
This sets several vim options to appropriate values for editing PHP files, to make it easier to follow Drupal coding standards. It also defines the following mappings:
\da
Look up the API docs for a drupal function under the cursor and open it in a web browser.
\dc
Same as \da but use http://drupalcontrib.org/.
\dda
Look up the API docs for a drush function under the cursor and open it in a web browser.
\dv
Get the value of the drupal variable under cursor. (Requires drush.)

You can define the maplocalleader variable to be something other than the default if you do not want these maps to start with a backslash.

To start a documentation block, type /**<CR>. The indent and the leading * will be added. To close the block, type <CR>/. For // style comments, the comment leader will be inserted on new lines; to remove it at the end of the comment, use <C-U>. To adjust line breaks in any comment, use gq.

plugin/drupal.vim
The file plugin/drupal.vim sets several options. These will apply whether or not you are editing Drupal-related files. In addition, it sets filetype detection and ftplugin support on; sets global variables used by the PHP syntax file; defines several key mappings; and it highlights trailing whitespace and comment lines longer than 80 characters in PHP and CSS files.
doc/drupal.txt
Vim help file. If the entire project is installed as ~/.vim, so the help file is at ~/.vim/doc/drupal.txt, then you can read the docs within vim using
    :helptags ~/.vim/doc
    :help drupal

The :helptags line only needs to be done once, when you install (or update) the help file. See :help :helptags.

ftdetect/drupal.vim
This file contains autocommands that recognize .module, .php, .install, .inc, .profile, .theme, .engine, and .test files as PHP and .info, .make, and .build files as Drupal ini.
README.txt
Installation instructions, etc.
autoload/drupal.vim
Code for addding GUI menus to vim.
compiler/coder.vim
Support for code clean-up using the Coder module.
drupal*.tags
Tags files to support code navigation and omni-copletion.
ftplugin/drini.vim
Mappings and settings for editing Drupal ini files.
snipmate/*/php.snippets
Support for the href="https://github.com/msanders/snipmate.vim">snipMate plugin for
vim.
syntax/*.vim
Syntax highlighting for Drupal PHP and ini files.
vimrc_*.vim
Example vimrc files for those who have never bothered to customize vim.

Project information

  • Created by webchick on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    Look for the shield icon below.

Releases