How To Create ASCII Drawings in Vim Editor (Draw Boxes, Lines, Ellipses, Arrows Inside Text File)

by SathiyaMoorthy on December 16, 2009

Create ASCII drawings inside Vim EditorYou can create line drawings in Vim editor using the Vim DrawIt! plugin. You can draw flow charts, ER diagrams, or any other diagrams that can be created as line drawing inside a text editor using this plugin.

2 Steps to install drawit.vim

Step 1: Download latest version of the plugin from vim.org

Download the plugin from vim.org

$ cd ~
$ wget -O DrawIt.vba.gz http://www.vim.org/scripts/download_script.php?src_id=8798

Step 2: Install the DrawIt! Vim plugin

$ cd ~
$ vim DrawIt.vba.gz

:so %
:q

5 Powerful Features of Vim Editor DrawIt! Plugin

  • \di will turn on the Drawit! plugin
  • \ds will turn off the Drawit! plugin

Feature 1: Draw as you Navigate inside Vim Editor

From the Vim editor, when you navigate using arrow keys (left, right, up and down) it will draw boxes or lines appropriately as per your navigation.

Following is an example of a simple CPU-Input-Output diagram that was drawn inside Vim editor in just few seconds using only navigation keys to draw the boxes and lines.

Vim Editor DrawIt! Plugin - Draw left, right, up, down and slanting lines

Fig: Text diagram created inside Vim editor in few seconds

Feature 2: Drawing a Box inside Vim Editor (in Visual Mode)

Step 1: Select a region using visual selection.

Draw boxes on a blank filled areas inside a text file

Fig: Visual selection of area to draw a box inside Vim editor

Step 2: Draw box by pressing \b

ASCI Diagram inside a text file using Vim Editor Draw It plugin
Fig: Box diagram created automatically based on selected area inside text file

Feature 3: Drawing Ellipse inside Vim Editor (in Visual Mode)

Step 1: Select a region using visual selection.

Step 2: Draw ellipse by pressing \e

Draw Circle, Rectangle, Triangle or Ellipse inside a Vim Editor Text file
Fig: Ellipse diagram created automatically based on selected area inside text file

Feature 4: Draw Arrows inside Vim Editor

Use the following key strokes to draw the corresponding arrows mentioned below.

  • > left arrow
  • \> fat left arrow
  • < right arrow
  • \< fat arrow
  • ^ up arrow
  • \^ fat up arrow
  • V down arrow
  • \V fat down arrow

Feature 5: Draw Slanting Lines inside Vim Editor

Slanting lines is — front slash and back slash. Use the following key strokes to draw the corresponding slanting lines

  • PageDown – Draw \ move down and right
  • End – Draw / move down and left
  • PageUP – Draw / move up and right
  • Home – Draw \ move up and left

Recommended Reading

Vim 101 Hacks, by Ramesh Natarajan. I’m a command-line junkie. So, naturally I’m a huge fan of Vi and Vim editors. Several years back, when I wrote lot of C code on Linux, I used to read all available Vim editor tips and tricks. Based on my Vim editor experience, I’ve written Vim 101 Hacks eBook that contains 101 practical examples on various advanced Vim features that will make you fast and productive in the Vim editor. Even if you’ve been using Vi and Vim Editors for several years and have not read this book, please do yourself a favor and read this book. You’ll be amazed with the capabilities of Vim editor.


Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 10 comments… read them below or add one }

1 ged December 16, 2009 at 3:02 am

Thats cool and can be useful when you want to show someone your idea through diagram but there are no MS Visio, Krita or Dia installed on machine and vim is. Thanks a lot, it is quite easy to learn and use.

2 bosha December 16, 2009 at 4:42 am

Thanks man. It’s really useful.

3 Berry December 16, 2009 at 8:58 am

In Feature 5, I think the keys in the number pad match the direction very well. But If I use Notebook, which have no numpad, can I use other keys instead?

4 Tim December 16, 2009 at 9:08 am

With the visual commands, I couldn’t get the \f and \s didn’t work as I expected.

In Vim, is there a way to search all open buffers or a directory and then create a window with a clickable jump list of the results (file and context)?

5 rakesh uv December 18, 2009 at 12:10 am

GOOD one !!

6 Ramesh Natarajan December 19, 2009 at 12:53 pm

@Ged, bosha, rakesh,

I’m glad you liked this article. Thanks for your nice comments.

@Berry,

Yes. You can use those keys (pagedown, end, pageup, home) from the notebook keyboard also.

@Tim,

\s is filling up the space as expected.

Steps:
———
Select specific lines in visual mode,
press \s which will append spaces.

You are right. \f is not working as expected in the visual mode. I’m not sure whether this is a bug in the plugin (or) something else. I’ll do some research on this topic later.

7 Jagdish Chhailkar September 2, 2010 at 1:43 am

I am trying to install DrawIt.vba i.e. drawing tool in vim. I am unable to install it. I am using RHEL 4. In root login i have the file called DrawIt.vba available. I am doing as follows:
# vim DrawIt.vba –> it opens the file in vim
If i issue :so % then i am getting error in line 2 as follows :
Error detected while processing /root/DrawIt.vba:
line 2:
E492: Not an editor command: UseVimball
Hit ENTER or type command to continue
can you please guide how to install this?

Jagdish Chhailkar

8 Ajit March 10, 2011 at 8:04 am

I could install the plugin but I am finding it difficult to start the plugin.Where do I have to run the command \di.Can you please tell me ramesh.

Thanks,Ajit

9 ged March 10, 2011 at 12:00 pm

Hi, Ajit.

There is some issue with plugin and sometimes you need to type in \di twice to start drawing. You should type in \di in command mode (if you are in another mode like input or visual you should press Esc key to enter command one). After \di executes you’ll see “[DrawIt]” at the bottom of screen. Now you could type \b (draw rectangle) or another command to draw appropriate figure. After typing \b use arrow keys to draw. To stop drawing type in \ds and you’ll see [DrawIt Off] that indicates you leave drawing mode.

Hope it helps you.

10 Ajit March 11, 2011 at 2:13 am

Ged,
That helped me get started.I was able to get into the drawit mode and try few stuff but I think I will definitely need some time to get a hang of it :) .Thanks for the comment though.

Ajit

Leave a Comment

Previous post:

Next post: