How to setup vim for Drupal

Who needs a slow and expensive IDE when you can have a high performance text editor that does nearly the same job for free? I was always frustrated using heavy java-based editors like Eclipse and NetBeans. They were slow and bulky and always seemed to get in the way of my productivity. Since I started working as a Drupal developer a few years ago, I've always wanted a fast editor that just worked and didn't get in my way. I also wanted to use it on any system or operating system including servers. Enter vim. In this article, I will show you how I set up vim to be optimized for Drupal development. The place to go to get started is here. I did a few things differently than their recommended installation. I wanted a way to keep it under version control in case some of the projects were updated. See below:

  • Prerequisites:
    • Windows:
      Install vim.
      Install git.
      Install drush.
      Open Command Prompt (NOT Git Bash) and Run as administrator:
      C:\> cd \Program Files (x86)
      C:\> wget http://prdownloads.sourceforge.net/ctags/ctags58.zip
      C:\> unzip ctags58.zip
      C:\> rm ctags58.zip
      C:\> cd Drush\Php
      C:\> go-pear (enter all defaults)
      C:\> regedit /s PEAR_ENV.reg
      C:\> pear install PHP_CodeSniffer
      *** Do NOT close this Command Prompt session window. ***
      Add C:\Program Files (x86)\ctags58 to the end of the path here:
      My Computer > Properties > Advanced (system settings) > Environment Variables > Path under System variables.
      Open Git Bash (NOT Command Prompt):
      $ cd
      $ echo "export PATH=\"$PATH:/c/Program Files (x86)/ctags58\"" >> ~/.bashrc
      $ echo "export PATH=\"$PATH:/c/Program Files (x86)/Drush/GnuWin32/bin\"" >> ~/.bashrc
      $ source ~/.bashrc
      $ ctags --help
      $ git clone --branch 7.x-2.x http://git.drupal.org/project/coder.git
      See coder contrib module
      Return to Command Prompt session window:
      C:\> cd \Windows
      C:\> wget http://www.nirsoft.net/utils/nircmd-x64.zip (or nircmd.zip)
      C:\> unzip nircmd-x64.zip (or nircmd.zip)
      C:\> rm nircmd-x64.zip (or nircmd.zip)
      C:\> nircmd shortcut "%HOMEPATH%\coder\coder_sniffer\Drupal" "C:\Program Files (x86)\Drush\Php\PEAR\PHP\CodeSniffer\Standards" Drupal

    • Mac OSX:
      Install pear.
      $ cd
      $ brew install ctags git
      $ sudo pear install PHP_CodeSniffer
      $ git clone --branch 7.x-2.x http://git.drupal.org/project/coder.git
      See coder contrib module
      $ sudo ln -s ~/coder/coder_sniffer/Drupal /usr/local/pear/share/pear/PHP/CodeSniffer/Standards/Drupal
    • Debian based:
      $ cd
      $ sudo apt-get install exuberant-ctags git php-pear vim
      $ sudo pear install PHP_CodeSniffer
      $ git clone --branch 7.x-2.x http://git.drupal.org/project/coder.git
      See coder contrib module
      $ sudo ln -s ~/coder/coder_sniffer/Drupal /usr/share/php/PHP/CodeSniffer/Standards/Drupal
    • Redhat based:
      $ cd
      $ sudo yum install ctags git php-pear vim-enhanced
      $ sudo pear install PHP_CodeSniffer
      $ git clone --branch 7.x-2.x http://git.drupal.org/project/coder.git
      See coder contrib module
      $ sudo ln -s ~/coder/coder_sniffer/Drupal /usr/share/pear/PHP/CodeSniffer/Standards/Drupal
  • All platforms:
    Open terminal (or Git Bash in Windows):
    $ wget drupalvim.sh.txt
  • $ mv drupalvim.sh.txt drupalvim.sh
    $ chmod +x drupalvim.sh
    $ ./drupalvim.sh

Happy vimming!

Syndicate

Syndicate content