Fork me on GitHub
 

Ymacs user documentation

If you are an Emacs user, then you should feel like home with Ymacs. Well, maybe not like home, but at least like at the home of a good friend. :-) By default Ymacs uses Emacs idioms and key bindings. It should be easy to customize it, however, to mimic other editors.

Like Emacs, in Ymacs there is the concept of “prefix keys”—combinations that are formed from multiple key strokes. A prefix key is notated by specifying the keys separated with a space. For example to press C-c / you need to type Control-C followed by a slash.

General key bindings

The following table summarizes the default key bindings (when no special programming mode is active).

C-a Move the cursor at the beginning of a line
HOME Toggle the cursor at the beginning of the indentation or beginning of line
END or C-e Move the cursor at the end of the line
ARROW keys Move the cursor around like in any other editor
C-f Move the cursor forward one character
C-b Move the cursor back one character
C-n Move the cursor to the next line
C-p Move the cursor to the previous line
M-g Goto line (accepts prefix command, see below, or gets the line number from the minibuffer)
C-HOME or M-< Move the cursor to the beginning of the text
C-END or M-> Move the cursor to the end of the text
C-ARROW_RIGHT or M-f Move forward one word
C-ARROW_LEFT or M-b Move backward one word
C-ARROW_DOWN Move forward one paragraph
C-ARROW_UP Move backward one paragraph
C-l Center on caret — scroll such that the caret goes in the middle of the widget
C-M-f Move forward skipping one balanced expression (SLOW at this time)
C-M-b Move backward skipping one balanced expression (10x SLOW at this time)
PAGE_DOWN or C-v Scroll down one page
PAGE_UP or M-v Scroll up one page
BACKSPACE Delete backward one character
DELETE or C-d Delete forward one character
ENTER or C-m Insert a new line
M-d Kill one word forward (read below for “killing text”)
C-BACKSPACE or
M-BACKSPACE or
M-DELETE
Kill one word backward
C-k Kill line (removes text to the end of the line, or the whole line if it's only whitespace)
M-C-k Kill balanced expression (SLOW at this time)
C-SPACE Set mark at current position
C-x C-x Swap the mark and cursor positions, moving the cursor to where the mark was
C-w Kill region between cursor and mark (like “cut”, in most editors)
M-w Copy region between cursor and mark into the kill ring (like “copy” in most editors)
C-y Yank (like “paste”) — insert the last killed chunk of text
M-y Yank-pop (rotate the kill ring, pasting the next chunk of killed text)
C-t Transpose characters around the cursor
M-t Transpose words around the cursor
C-x C-t Transpose lines
M-c Capitalize word
M-u Uppercase word
M-l Lowercase word
F11 Nuke (remove) trailing whitespace on all lines
TAB Indent line according to current mode; when no mode is in use, insert 4 spaces
M-q Fill paragraph — breaks long lines at 78 (“fill_column”) characters, recognizing certain paragraph prefixes
C-/ or C-z or
C-_ or C-x u
Undo
INSERT Toggle overwrite mode
M-s Center current line
M-/ Autocomplete current word based on text that is already present in the buffer (dabbrev-expand in Emacs)
C-s Interactive search forward
C-r Interactive search backward
C-u Universal prefix argument (see below for prefix arguments)
C-TAB or
C-x ARROW_RIGHT or
C-x C-ARROW_RIGHT
Switch to next buffer
C-S-TAB or
C-x ARROW_LEFT or
C-x C-ARROW_LEFT
Switch to previous buffer
C-x b Switch buffer (select a buffer by name, using TAB completion)
C-x 2 Split current frame vertically
C-x 3 Split current frame horizontally
C-x 1 Remove all splits, keeping only the active frame
C-x o Focus another frame
C-x l Toggle side line numbers
M-x Execute a command interactively; reads the command name with TAB completion

Using the operating system clipboard

Because Ymacs is a custom widget and doesn't use any kind of browser support for editing text, we cannot access system clipboard directly. Therefore if you want to select some text in an application from your operating system, or even in a Firefox page, and paste it into Ymacs, we have to resort to a trick: we'll open up a text area, where you can use the normal operating system shortcut (i.e. Control-V) to paste, and once pasted we will insert the text from it into Ymacs.

Similarly, when you want to copy some text for the operating system clipboard, so that you can paste it in some other application, we'll open the same textarea where you can press the normal OS shortcut for copy.

C-S-y Paste from operating system clipboard
C-S-w Cut for operating system clipboard
M-S-w Copy for operating system clipboard

Prefix arguments

Many commands accept a prefix argument. This argument can be entered using C-u followed by an optional dash (for negative arguments) and one or more digits. Some commands simply take an optional true value, which can be entered by C-u followed by the command directly (no digits).

Exactly what the argument means depends on the command. For example M-g moves to a line which can be entered as a prefix argument (if the argument is missing, it will request a line number from the user via the minibuffer). So, to move, say, to line 10, you can press the following keys: C-u 1 0 M-g, or you can simply press M-g then type 10 in the minibuffer followed by ENTER.

Many commands will simply repeat the action N times, given the argument N. For example, you can delete forward one word using M-d. If you want to delete 5 words forward, you would press C-u 5 M-d. Similarly, the self_insert_command will insert the pressed key N times, if an N argument was given.

Other commands

The following are non-standard combinations in Emacs, but Ymacs provides them because I found them useful and they're in my fingers already. :-)

M-C-d Delete (not kill!) the selected region, or current line when there's no region
M-S-y Yank-shift (the reverse of Yank-pop)
C-c / Close the last XML tag (so this works in any mode)
S-BACKSPACE Delete all whitespaces (newlines included) backwards
S-DELETE Delete all whitespaces forward
M-ENTER Start a new paragraph which is similar to the current one (i.e. follows the current prefix)
M-S-q Fill paragraph but remove any recognized prefix first

What's text killing?

The kill ring is the Emacs concept of clipboard. As you can expect, it's a lot more powerful than standard system clipboard. The kill ring can keep multiple chunks of text, though you will normally deal with the last.

When you “kill” text, it is pushed into the kill ring, so you could say it's effectively equivalent to “cutting”. Consecutive kill operations would not push new text chunks, but append to the last one. Thus, for example, if you use “backward kill word” to remove words “foo bar baz|” (where | is the cursor position), when you later hit C-y to paste, it will paste “foo bar baz”, not just “foo”.

A non-killing command will “seal” the last chunk of killed text, so that new kill commands will create new chunks instead.

When you paste (“yank”) using C-y, the last chunk of killed text is inserted and remembered. If you wanted to insert some text that was killed earlier, you can now use M-y or M-S-y to rotate the kill ring and consecutively replace the last yanked text with the “new last chunk” in the kill ring. This way you can access all things that were killed or copied, and not just the last one.