写一个zbjxb.vim文件,并将该文件放到vim的plugin目录。
linux下一般是/usr/share/vim/vim74/plugin/.
linux下代码为:
function Dot(format)
let fmt = a:format
let cmd = 'dot'
let opt = ' -T' . fmt . ' -o '
let currfile = expand('%:p')
let outfile = currfile . '.' . fmt
silent execute '!start ' . cmd . ' "' . currfile . '" '. opt . ' "' . outfile . '" '
endfunction
windows下代码为:
function Dot(format)
let fmt = a:format
let cmd = '"C:\Users\Guest\Downloads\Program Files (x86)\Graphviz2.30\bin\dot.exe"'
let opt = ' -T' . fmt . ' -o '
let currfile = expand('%:p')
let outfile = currfile . '.' . fmt
silent execute '!start ' . cmd . ' "' . currfile . '" '. opt . ' "' . outfile . '" '
endfunction
编写完成后执行vim命令,即可在该dot文件所在目录下生成一张图片:
:call Dot("png")
或者
:call Dot("svg")
:call Dot("pdf")
函数里的代码也可以一行一行的执行
:echo command
另:在windows上编辑好的dot文件,在linux上执行时,可能会有错误发生,需要在vim里执行
:set fileformat=unix
:w
我之所以要在linux上执行这些dot文件,是由于windows版本的dot似乎不支持中文。