要实现这个功能也比较简单,www.vim.org上有两个相关的插件,一个是sketch.vim,一个是drawit.vim。
对于sketch.vim,看名字就知道,他主要是想实现草图的功能,所以使用鼠标来画图的,也可以实现一些很复杂的图形,但是有个缺点就是当快速的拖动鼠标的时候,直线会夹杂一些空白的地方,所以被我无情抛弃。
再来看drawit.vim,普通模式下 /di是启动,/ds是关闭,用上下左右键就可以进行直线绘图,用home,end,pgup,pgdn,就可以实现斜线的绘制~~总而言是还是非常棒.
Its easy to start and stop DrawIt: use
/di to start DrawIt and
/ds to stop DrawIt.
Supported Features
<left> move and draw left
<right> move and draw right, inserting lines/space as needed
<up> move and draw up, inserting lines/space as needed
<down> move and draw down, inserting lines/space as needed
<s-left> move left
<s-right> move right, inserting lines/space as needed
<s-up> move up, inserting lines/space as needed
<s-down> move down, inserting lines/space as needed
<space> toggle into and out of erase mode
> draw -> arrow
< draw <- arrow
^ draw ^ arrow
v draw v arrow
<pgdn> replace with a /, move down and right, and insert a /
<end> replace with a /, move down and left, and insert a /
<pgup> replace with a /, move up and right, and insert a /
<home> replace with a /, move up and left, and insert a /
/> draw fat -> arrow
/< draw fat <- arrow
/^ draw fat ^ arrow
/v draw fat v arrow
/a draw arrow based on corners of visual-block
/b draw box using visual-block selected region
/e draw an ellipse inside visual-block
/f fill a figure with some character
/h create a canvas for /a /b /e /l
/l draw line based on corners of visual block
/s adds spaces to canvas
<leftmouse> select visual block
<s-leftmouse> drag and draw with current brush (register)
/ra ... /rz replace text with given brush/register
/pa ... like /ra ... /rz, except that blanks are considered
to be transparent
Thank you for ranking DrawIt!