Emacs: Insert A to Z Vertically

By Xah Lee. Date: . Last updated: .

Here's a command that inserts letters a to z, vertically in a column. (similar to rectangle-number-lines) It can also insert any sequence of Unicode characters.

(defun xah-insert-column-az ()
  "Insert letters A to Z vertically, similar to `rectangle-number-lines'.
The commpand will prompt for a start char, and number of chars to insert.
The start char can be any char in Unicode.
URL `http://ergoemacs.org/emacs/emacs_insert-alphabets.html'
Version 2019-03-07"
  (interactive)
  (let (
        ($startChar (string-to-char (read-string "Start char: " "a")))
        ($howmany (string-to-number (read-string "How many: " "26")))
        ($colpos (- (point) (line-beginning-position))))
    (dotimes ($i $howmany )
      (progn
        (insert-char (+ $i $startChar))
        (forward-line)
        (beginning-of-line)
        (forward-char $colpos)))))

To insert column of numbers, Alt+x rectangle-number-lines. [see Emacs: Edit Column Text, Rectangle Commands]

Insert A to Z Using rectangle-number-lines

Here's how to insert A to Z using emacs builtin command.

You can also insert letters A to Z by using rectangle-number-lines.

try change this

1 cat
2 creatures
  dragon
  phoenix
  elf
  hydra
  medusa
3 dog
4 bird

to this

1 cat
2 creatures
  A. dragon
  B. phoenix
  C. elf
  D. hydra
  E. medusa
3 dog
4 bird
  1. Move cursor to before “dragon”.
  2. Alt+x set-mark-commandCtrl+Space】.
  3. Move cursor to before “medusa”.
  4. Alt+x universal-argumentCtrl+u】.
  5. Now, Alt+x rectangle-number-lines. It will prompt you to enter arguments.
  6. Type 65 (Letter A has Unicode codepoint 65. a is 97). [see ASCII Table]
  7. Remove the default %2d , type %c. (the “%c” is for character format)

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Working with Brackets

Org Mode

HTML

Emacs Efficiency

Misc