Emacs: picture-mode, ASCII Diagram

By Xah Lee. Date: . Last updated: .

picture-mode

Emacs's picture-mode lets you draw ASCII diagrams.

  _____________________________________________
 |                                             |
 |          Sequence                           |
 |  ______   ________________________________  |
 | |      | |                                | |
 | | List | |             Array              | |
 | |      | |    ________       ________     | |
 | |______| |   |        |     |        |    | |
 |          |   | Vector |     | String |    | |
 |          |   |________|     |________|    | |
 |          |  ____________   _____________  | |
 |          | |            | |             | | |
 |          | | Char-table | | Bool-vector | | |
 |          | |____________| |_____________| | |
 |          |________________________________| |
 |_____________________________________________|
ASCII diagram

To see how to use it:

  1. Open a new file.
  2. Alt+x picture-mode,
  3. Alt+x describe-modeCtrl+h m
Picture:right mode defined in `picture.el':
Switch to Picture mode, in which a quarter-plane screen model is used.

Printing characters replace instead of inserting themselves with motion
afterwards settable by these commands:

 Move left after insertion:            C-c <
 Move right after insertion:           C-c >
 Move up after insertion:              C-c ^
 Move down after insertion:            C-c .

 Move northwest (nw) after insertion:  C-c `
 Move northeast (ne) after insertion:  C-c '
 Move southwest (sw) after insertion:  C-c /
 Move southeast (se) after insertion:  C-c \

 Move westnorthwest (wnw) after insertion:  C-u C-c `
 Move eastnortheast (ene) after insertion:  C-u C-c '
 Move westsouthwest (wsw) after insertion:  C-u C-c /
 Move eastsoutheast (ese) after insertion:  C-u C-c \

The current direction is displayed in the mode line.  The initial
direction is right.  Whitespace is inserted and tabs are changed to
spaces when required by movement.  You can move around in the buffer
with these commands:

 Move vertically to SAME column in previous line: C-n
 Move vertically to SAME column in next line:     C-p
 Move to column following last
  non-whitespace character:                       C-e
 Move right, inserting spaces if required:        C-f
 Move left changing tabs to spaces if required:   C-b
 Move in direction of current picture motion:     C-c C-f
 Move opposite to current picture motion:         C-c C-b
 Move to beginning of next line:                  C-n

You can edit tabular text with these commands:

 Move to column beneath (or at) next interesting
  character (see variable `picture-tab-chars'):   C-M-i
 Move to next stop in tab stop list:              TAB
 Set tab stops according to context of this line: C-c TAB
   (With ARG, resets tab stops to default value.)
 Change the tab stop list:                        M-x edit-tab-stops

You can manipulate text with these commands:
 Clear ARG columns after point without moving:    C-d
 Delete char at point:                            C-c C-d
 Clear ARG columns backward:                      DEL
 Clear ARG lines, advancing over them:            C-k
  (the cleared text is saved in the kill ring)
 Open blank line(s) beneath current line:         C-o

You can manipulate rectangles with these commands:
  Clear a rectangle and save it:                  C-c C-k
  Clear a rectangle, saving in a named register:  C-c C-w
  Insert currently saved rectangle at point:      C-c C-y
  Insert rectangle from named register:           C-c C-x
  Draw a rectangular box around mark and point:   C-c C-r
  Copies a rectangle to a register:               C-x r r
  Undo effects of rectangle overlay commands:     C-x u

You can return to the previous mode with C-c C-c, which
also strips trailing whitespace from every line.  Stripping is suppressed
by supplying an argument.

Entry to this mode calls the value of `picture-mode-hook' if non-nil.

Note that Picture mode commands will work outside of Picture mode, but
they are not by default assigned to keys.

[see Emacs: Edit Column Text, Rectangle Commands]

artist-mode

artist-mode lets you draw ASCII pictures with mouse.

    +--------------+             -----------
    | +---+        |          --/   ------- \--
    | |+--+--------+---+    -/   --/       \-- \-
    | ||  |        |   |   /    /    -----    \  \
    | ||  |  +-----+-+ |   |    |   (     )   |  |
    +-++--+--+-----+ | |   \    \    -----    /  /
      ||  |  +-------+ |    -\   --\       /-- /-
      |+--+------------+      --\   ------- /--
      |   |                      -----------           ●●●●
      |   |                                     ●●●●●●●   ●●●
      +---+             ●●●●●         ●●●●●●●●●●●   ●●●●    ●●
                    ●●●●●    ●●●●●●●●●●    ●●●●●●   ●    ●   ●
                ●●●●●      ●●●●●●●●●●●●●●●●     ●●  ● ●  ●●  ●●
              ●●●       ●●●●              ●●●●   ●    ●   ●   ●
            ●●●      ●●●●           ●●●●●●      ●●  ●●●   ●  ●●
          ●●●      ●●●         ●●●       ●●●●     ●●●    ●●  ●
          ●      ●●●    ●●●●●●●  ●●●●●      ●●●●●●●     ●●   ●
         ●      ●●    ●●●            ●●●             ●●●●  ●●●
        ●●     ●●    ●●       ●●●●●    ●●●   ●●●●●●●●●    ●●
       ●●      ●    ●     ●●●●    ●●●    ●●   ●           ●
      ●●      ●    ●●   ●●●        ●●     ●   ●   ●●●●●   ●●
                   ●    ●     ●●●●●●      ●   ●   ●   ●●   ●●
                   ●●        ●●         ●●   ●●   ●    ●    ●
                    ●●●●     ●        ●●●   ●●   ●●   ●●    ●
                  ●●●●●●●●   ●●●●●●●●●●    ●●   ●●    ●    ●●
                  ●●●●●●●●    ●●●         ●●●  ●●    ●●    ●
                  ●●●●●●●●   ●● ●●●●●●●●●    ●●●     ●     ●
                   ●●●●●●●  ●           ●●●         ●●    ●●
                      ●●●  ●●     ●●●     ●●       ●●    ●●
                         ●●●    ●●● ●●     ●●●●●●●●     ●●
                 ●●●●●●●●●     ●●    ●●               ●●●
               ●●●            ●●      ●●●●●●●●●●●●●●●●●
               ●     ●●●●●●●●●●
               ●      ●●●●●●●●●●●●●●●●●●●●●●
               ●●●●                      ●●●
                  ●●●●●●●●●●●●●●●●●●●●●●●●
Some doodle with artist-mode.

Rectangle Edit Topic

  1. Emacs: Edit Column Text, Rectangle Commands
  2. Emacs: Insert Alphabets A to Z
  3. Emacs: Copy Rectangle Region to kill-ring
  4. Emacs: Align Text
  5. Emacs: picture-mode, ASCII Diagram
  6. Emacs: Make Whitespaces Visible
Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

Ask me question on patreon