sponsor Vim development Vim logo Vim Book Ad

DrawIt! : Ascii drawing plugin: lines, ellipses, arrows, fills, and more!

 script karma  Rating 1295/469, Downloaded by 27692  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
 
script type
utility
 
description
DrawIt is a plugin which allows one to draw lines left, right, up, down, and along both slants. Optionally one may "cap" the lines with arrowheads.  One may change the horizontal, vertical, slant, and crossing characters to whichever characters one wishes.

Its easy to start and stop DrawIt: use

   \di to start DrawIt and
   \ds to stop  DrawIt.

The alpha/beta version is available at  http://www.drchip.org/astronaut/vim/index.html#DRAWIT.

When DrawIt has been started you may use the number pad to leave a trail of dashes, vertical bars, etc.  The lines will be expanded as needed to accomodate your drawing.  DrawIt can also draw boxes and ellipses on a blank-filled area (DrawIt can produce these) which can be useful for drawing boxes around comments.

Viart's <drawing.vim> has been merged with the original DrawIt (vimscript#11) (by permission).  Use visual-block selection to specify starting and ending positions and a Bresenham line drawing algorithm will be used to connect the two.  DrC has written an ellipse-drawing Bresenham-style procedure: again, use the visual block selection to specify a box to contain the ellipse and \e to trigger the ellipse drawing.

DrawIt incorporates an "erase" mode, toggled by the <space> key, that will leave a trail of blanks behind and under the cursor as it is moved by the number pad.  Using the shift-arrow keys, DrawIt will move the cursor, expanding lines and inserting spaces as needed, without changing underlying text.

DrawIt is now in the vimball format, which is understood by the new Vim 7.0 release.  After decompressing the DrawIt.vba.gz file, edit it with Vim, and then source it (:so %).  The components of DrawIt will then be placed where they belong, based on your Vim's runtimepath.

DrawIt records many user options that affect DrawIt and all maps that starting DrawIt creates.  When DrawIt is terminated it restores the user's maps and options.  DrawIt's number pad maps will expand the file as necessary to accomodate the drawing, automatically.

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!
 
install details
DrawIt! is now distributed as a vimball (see :help vimball)

vim DrawIt.vba.gz
:so %
:q

and that's all!

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
DrawIt.vba.gz 13 2013-11-25 7.3 Charles Campbell improved string length handling for multi-character characters
various bug fixes
DrawIt.vba.gz 12 2013-03-12 7.0 Charles Campbell A few bug fixes
DrawIt.vba.gz 11 2012-06-18 7.3 Charles Campbell New: utf-8 and cp437 box drawing characters
New: "fat" arrows use utf-8 characters when available
Various bugfixes
DrawIt.vba.gz 10 2008-06-12 7.0 Charles Campbell Fixed a bug with text brushes and ctrl-leftmouse.
DrawIt.vba.gz 9 2007-10-10 7.0 Charles Campbell Bugfix: Johann-Guenter Simon fixed a bug with s:DrawErase()
DrawIt.vba.gz 8 2007-07-26 7.0 Charles Campbell * Changed "Holer" to "Canvas" and implemented AutoCanvas (which works real well with set ve=all)
* use ctrl-leftmouse to select visual-blocks
* floods can now be done inside an ellipse
* Extended DrawIt to allow users to specify their ellipse drawing with b:di_ellipse
* DrawIt's maps are now all <buffer> (local) instead of global
* Bug fixe fixed multi-character user map restoration
DrawIt.vba.gz 7 2006-04-13 7.0 Charles Campbell DrawIt now uses autoload feature of vim 7.0 , so vim7.0 is required!
DrawIt now supports brushes: use visual block to select a brush, then use :SetBrush a (for example).  Blanks are transparent.  Use shift-leftmouse to draw with the current brush.
Various bugfixes.
DrawIt.tar.gz 02242003 2003-02-24 6.0 Charles Campbell The latest DrawIt now provides a fill function.
\f will ask for a character to fill the figure
surrounding the current cursor location.  Plus
I suggest reading :he drawit-tip for those whose
home/pageup/pagedown/end keys aren't all working
properly with DrawIt.
ip used for rating: 3.131.13.194

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github