Debugging in VIM

From Koha Wiki

Jump to: navigation, search
Koha > Technical


Debugging Perl CGI mode with VIM

Install the plugin VIM Vdebug

With pathogen

  • Download the plugin
cd ~/.vim/bundle
git clone
  • Add the following line to vimrc
call pathogen#helptags()
  • You can now access Vdebug using the following command
:h Vdebug

Note:Vdebug require vim with compiled in python support. If you're useing Debian Wheezy, then the 'default' vim package does not have this. You can try vim-nox instead ;)

Install Perl module "remote debugging"

This module is provided by ActiveState at the following address [1]

tar xzf Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86.tar.gz

Edit the Apache vHosts

It is necessary to add some environment variables and change the PERL5LIB variable in the virtualhost:

SetEnv PERL5LIB "/home/koha/src:/home/koha/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86"
SetEnv PERL5DB "BEGIN { require q(/home/koha/Komodo-PerlRemoteDebugging-4.4.1-20896-linux-x86/}"
SetEnv PERLDB_OPTS "RemotePort=localhost:9000"
SetEnv DBGP_IDEKEY "whatever"
SetEnv PERL5OPT "-d"

Restart Apache

Start a debug session

In Vim, open the perl script to debug and press <F5>. From there, you have 20 seconds to launch the web page through a browser. If all went well, 3 new windows open in Vim: you are in debug mode!

Commands available to you in debug mode

<F2> Step over
<F3> Step in
<F4> Step out
<F5> Run
<F6> Stop/Close
<F9> Run to cursor
<F12> Evaluate variable under cursor

See :h Vdebug for more information

Developer handbook

Personal tools