Skip to content

Instantly share code, notes, and snippets.

@groenewege
Created April 26, 2011 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groenewege/942208 to your computer and use it in GitHub Desktop.
Save groenewege/942208 to your computer and use it in GitHub Desktop.
vim - insert image
call NERDTreeAddKeyMap({
\ 'key': 'b',
\ 'callback': 'NERDTreeInsertImage',
\ 'quickhelpText': 'Insert XHTML tag of image' })
function! NERDTreeInsertImage()
let n=g:NERDTreeFileNode.GetSelected()
if n!={}
let path=escape(n.path.str(),' ')
let theWH=substitute(system('identify -format %wx%h "'.path.'"'),'\n','','')
if(path[0]=='/')
let path=Absolute2Relative(path)
endif
let theWH=substitute(theWH,'\([0-9]*\)x\([0-9]*\)','<img src="'.path.'" width="\1" height="\2" alt="" />','')
let @i = theWH
normal p"ip==
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment