Created
April 26, 2011 12:52
-
-
Save groenewege/942208 to your computer and use it in GitHub Desktop.
vim - insert image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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