After researching, I found a solution that seems to do exactly what I wanted. This piece of code will be inserted into the file under ~/.vim/nerdtree_plugin (or the equivalent directory on other operating systems):
call NERDTreeAddKeyMap({ \ 'key': 'b', \ 'callback': 'NERDTreeInsertImage', \ 'quickhelpText': 'Insert XHTML tag of image' }) function! NERDTreeInsertImage() let n = g:NERDTreeFileNode.GetSelected() if n != {} let @i = system("~/perl/image.pl " . n.path.str()) normal ^Wp"ip endif endfunction
it adds a mapping to key b , in which the NERDTreeInsertImage() function is NERDTreeInsertImage() , which takes the full path to the selected file in the browser and passes it as an argument to my perl script. Of course, ^W inserted as <CV><CW> .
Hope this can be useful for some other Vim users :)
@romainl is a very simple Perl script (ImageMagick module required):
#!/usr/bin/perl use strict; use warnings; use Image::Magick; my $source = $ARGV[0]; my $img = Image::Magick->new; $img->Read($source); my ( $width, $height ) = $img->Get('width', 'height'); print qq
source share