On Sat, Nov 7, 2009 at 12:19 PM, Matteo Riva <[email protected]> wrote:
> I would like to add custom functions to files in the browser window,
> like running a script that inserts the correct XHTML tag when used on an
> image, or inserting require() lines on the selected module and so on.
>
> Is it possibile with NERDTree or is there any other browser plugin that
> supports this?
Posting the solution I came up with in case it may be of interest to
other vim users.
file: ~/.vim/nerdtree_plugin/my_plugin.vim
call NERDTreeAddKeyMap({
\ 'key': 'b',
\ 'callback': 'NERDTreeInsertImage',
\ 'quickhelpText': 'Insert XHTML tag of image' })
function! NERDTreeInsertImage()
let n = g:NERDTreeFileNode.GetSelected()
let filepath = n.path.str()
if n != {}
let @i = system("~/perl/image.pl " . filepath)
normal ^W"ip
endif
endfunction
it adds a mapping to key `b` and runs the perl script using the full
file path as argument. Of course ^W is inserted with <C-v><C-w>.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---