On this page
Overview
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
On this page: Documentation | Prerequisites | Features | Screenshot
Documentation
After installation, most of the documentation on these pages (but not the screen shots) is available when running vim with the command
:help drupal.txt
If you notice any inconsistencies between these pages and the help files included with the project, please file an issue.
Prerequisites
This project is designed to work with vim version 7.0 or later, with at least the "normal" compilation options. While running vim, you can use the
:version
command; from a shell, you can use
$ vim --version
Either way, the first few lines of the output should tell you the version number and whether you have a "tiny", "small", "normal", "big", or "huge" version of vim. If you are currently using a tiny vim, upgrade to at least normal. You will be glad you did! It is worth asking your hosting provider to install a recent, full-featured version.
Vim is designed to play well with external programs, and we take advantage of that. For some features of this project, you will need to install other programs, such as exuberant ctags, drush, or phpcs. Most features do not need any extra programs. See the installation page for details.
Vim works on many platforms, and so do our scripts. We test them on Mac, Linux, and Windows.
Features
Feature requests are welcome! Currently, the Vimrc project includes the
following features. See the child pages for further explanation.
- Basic vim configuration
- Vim has many options, and we set many of them to suitable values for editing Drupal files. This includes options that affect indenting, documentation blocks, and line breaking. We have incorporated most of the suggestions from the Handbook page Configuring vim.
- Syntax highlighting
- By default, vim includes syntax definitions for PHP, javascript, and most other languages you might care to use. We have added highlighting for
.info
files, extra highlighting for documentation blocks, and we encourage you to follow Drupal coding standards by making trailing white space and comments over 80 characters display as errors. This screenshot shows the coreincludes/common.inc
andmodules/system/system.info
with the delek color scheme. - Magic
- If you are editing a file anywhere inside your Drupal installation, then vim is aware of which version of Drupal you have. If you are editing a project outside your Drupal installation, but inside the
myproject/
directory, vim will parsemyproject/myproject.info
to find the version. Remember: when you edit with vim, 'magic' is the default! - View documentation
- With a few keystrokes, you can view the definition of a Drupal core function in your own Drupal installation or on http://api.drupal.org. You can also jump to http://drupalcontrib.org/ or to the drush API site.
- Auto completion
- When editing a PHP file, vim can auto-complete PHP built-in functions, Drupal core functions, and functions defined in the current file. When editing a
.info
file, vim can auto-complete standard keywords. - Drush integration
- Invoke drush and save the output in a Vim window. This is wicked good if you want to see what modules are installed on your dev server but not your local one: just
:Drush @dev pm-list
,:Drush @local pm-list
and compare the two using Vim's diff mode! - GUI menus
- Many features can be accessed through Vim's menu system.
- Code snippets
- We include support for the snipMate plugin. For example, typing
hook_block
and then a tab character in a D7 module expands to
this outline:/** * Implements hook_block_info(). */ function calendar_block_info() { // Your code here } /** * Implements hook_block_save(). */ function calendar_block_save() { } /** * Implements hook_block_view(). */ function calendar_block_view() { } /** * Implements hook_block_configure(). */ function calendar_block_configure() { } /** * Implements hook_block_list_alter(). */ function calendar_block_list_alter() { } /** * Implements hook_block_info_alter(). */ function calendar_block_info_alter() { } /** * Implements hook_block_view_alter(). */ function calendar_block_view_alter() { } /** * Implements hook_block_view_MODULE_DELTA_alter(). */ function calendar_block_view_MODULE_DELTA_alter() { }
Screenshot
Here is a screenshot of vim editing a module file, with the definition of drupal_get_path()
in the upper window. On the left, the NERDTree plugin shows the ctools/
directory. On the right, the Tagbar plugin shows a list of functions defined in drupal/includes/common.inc
, the active buffer.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion