Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday May 01, 2008
03:31 AM

Debugging Vim Scripts

[ #36297 ]

Working a vim plugin someone sent me to test and it turns out to be buggy ... but only on Solaris. My MacBook has no such problem. Since I promised to debug it if it's not reproduceable. So to do that I'm working through the code, line by line, only to discover how limited my vim knowledge really is.

This little mapping will help with that. If, and only if, you are in a file which vim thinks has a 'vim' filetype, it will remap 'K' to automatically display help for any keyword the cursor is on. It's a much faster way of figuring things out (and it's actually in a filetype plugin rather than my .vimrc).

au! FileType vim :noremap K :exe "help " . expand("<cword>")<cr>

On a side note, I'm getting so irritated with vim that I started playing with Emacs. That led me quickly back to vim :(

Vim: making easy things possible and hard things Herculean.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • If, and only if, you are in a file which vim thinks has a 'vim' filetype ...

    However once you've edited a Vim file the mapping will persist and continue to apply to later non-Vim files that you edit. The fix is to make it a buffer-local mapping:

    au! FileType vim :noremap <buffer> K :exe expand("help <cword>")<cr>
  • From my .vimrc:

    autocmd FileType {vim,help} setlocal keywordprg=:help

    I’m not sure there’s any real advantage to this method, since apparently keywordprg is only used for the “K” command anyway, but hey, it’s the blessed way…