Next: , Up: (dir)

GNU Moe Manual

This manual is for GNU Moe (version 1.5, 19 February 2013).


Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.

This manual is free documentation: you have unlimited permission to copy, distribute and modify it.


Next: , Previous: Top, Up: Top

1 Introduction

GNU Moe is a powerful, 8-bit clean, text editor for ISO-8859 and ASCII character encodings. It has a modeless, user-friendly interface, online help, multiple windows, unlimited undo/redo capability, unlimited line length, global search/replace (on all buffers at once), block operations, automatic indentation, word wrapping, file name completion, directory browser, duplicate removal from prompt histories, delimiter matching, etc.

To have Moe used as your default editor you need to set the environment variables `EDITOR=moe' and/or `VISUAL=moe' in your shell initialization file ($HOME/.profile if you are using bash).

Moe needs a screen size of at least 24 lines by 80 columns. Take this into account if runing it from a terminal emulator.


Next: , Previous: Introduction, Up: Top

2 Basic concepts

Buffer
The buffer is the basic editing unit; one buffer corresponds to one text being edited. You can have several buffers, but at any time you are editing only one, the "current buffer", though several buffers (or several parts of the same buffer) can be visible when you are using multiple windows.
Buffer handle
The buffer handle is the data structure underlying a (possibly hidden) window. It contains the window and cursor positions in the buffer. There is no limit on the number of buffer handles that can refer to the same buffer.
Current line
The line with the cursor.
File
Files are named units of text which are stored by the operating system for you to retrieve later by name. To keep any text permanently you must put it in a file.

When Moe loads a file, it creates a buffer, copies the contents of the file into the buffer, and then displays the buffer for you to edit. If you alter the text, you can save the new text in the file. This makes the changes permanent by copying the altered buffer contents back into the file. Until you save, the changes exist only inside Moe, and the loaded file remains unaltered.

To create a file, just load the file as if it already existed. This creates an empty buffer in which you can insert the text you want to put in the file. The file is actually created when you save this buffer.

Window
Moe divides the screen into one or more windows, each of which can display the contents of one buffer. The only limit to the number of windows is screen size.


Next: , Previous: Basic concepts, Up: Top

3 Invoking Moe

The format for running Moe is:

     moe [global_options] [ [+line[,column]] file_name [file_options] ]...

Where global_options are a mix of editor options and default file_options. Use `-' as a file name to read from standard input. Note that the short option names use the same letters that the options menu inside Moe. Most long option names have a negative form `--backup' `--no-backup'.

Each file name may be preceded by `+line[,column]' to start the cursor at the specified line and, optionally, column. line and column are applied to subsequent files until new values are specified for them.

Moe supports the following editor options:

-h
--help
Print an informative help message describing the options and exit.
-V
--version
Print the version number of Moe on the standard output and exit.
-1
--orphan
Put extra files in orphaned buffers instead of in new windows.
-b
--backup
Create backup files (default).
-B
--no-backup
Do not create backup files.
-e
--exit-ask
Ask always for confirmation when closing or saving-and-closing a buffer.
-H
--smart-home
Normally, when you press the home key, the cursor moves to the beginning of the line, and if you press it again, it remains there. With this option, if the cursor is at the beginning of the line and you press home, the cursor moves to the first non-blank character.
-i
--ignore-case
Search in Moe is case sensitive by default. With this option you can make it case insensitive by default.
-k n
--keep-lines=n
Number of lines to keep for PgUp/PgDn. -1 means half window.
-m n
--max-windows=n
Maximum number of windows to show at once on the screen. 0 means as many as they fit.
-n n
--indent-step=n
Number of spaces to add or remove when indenting or unindenting a block.
-s
--search-wrap
Make search wrap. If end of buffer is reached and no match is found, continue the search from the beginning of the buffer.
-u
--auto-unmark
Turn off highlighting after block copy or move.
-x
--rectangle
Turn on rectangular block mode. Provide basic rectangular block operations, like copy or move. This mode won't work properly if there are <Tab> characters in or at the left of the block.
     
     
Moe also supports the following file options:
-a
--auto-indent
When auto indent is enabled and you press enter, or the text wraps at the end of a line, the cursor moves under the first non-blank character of the previous line instead of at the beginning of the line.
-l col
--lmargin=col
Set left margin to col. The first column is column 1.
-r col
--rmargin=col
Set right margin to col.
-o
--read-only
Make the buffer read only.
-O
--overwrite
Disable insert mode. Make typed characters replace existing ones except at end of line.
-w
--word-wrap
Automatically passes the current word to the next line when you type past the right margin.


Next: , Previous: Invoking Moe, Up: Top

4 The moerc file

moerc is the runtime configuration file for Moe. In it you may define default editor options, default file options and file name dependent options. The moerc file is optional, so that you can run Moe from the source directory without installing it.

The options specified in the command line override those specified in the moerc file.

Inside the moerc file, file name dependent options override those specified as default file options.

You may copy the system moerc file ${sysconfdir}/moerc to $HOME/.moerc and customize these options as you like. The file syntax is fairly obvious and there are further instructions in it.


Next: , Previous: The moerc file, Up: Top

5 The status line

The status line is a line displayed in inverse video at the top of each window, and contains the following information:


Next: , Previous: The status line, Up: Top

6 Keyboard commands

Moe tries to rationalize the keyboard commands. The <Alt> key is used for harmless commands like cursor movements and scrolling. The <Control> key is used for more "dangerous" commands like copying text blocks, deleting lines, or exiting. The <Tab> key is used for file name completion and also shows/hides the directory browser when Moe asks for a file name to save or load. In any case, the unlimited undo/redo capability of Moe makes very difficult to accidentally cause an irreparable damage to your files.

Moe uses the function keys, so that the most frequent commands can be issued with only one finger. The function key <F1> shows the online help, and <F10> allows you to change the options. Believe it or not, this paragraph and some experience with text editors is all you need to use Moe just as well as an expert. Forget about `learning curves'; there is nothing to learn.

The <Control> key is displayed in the online help as `^', while the <Alt> key is displayed as `^['. In this manual Control-a will be written as C-a and Alt-a as A-a.

Some environments "swallow" the <Alt> key so that it never reaches the application. If this happens, press the <Esc> key, then release it and press the desired key.


Next: , Up: Keyboard commands

6.1 Function keys

<F1>
C-h
Show the online help. Press <Page_up> to see the previous help screen or <Page_down> to see the next help screen. Press <F1> or C-h again to return to the editor.
<F2>
Save the current buffer to a file, automatically creating any missing parent directories. It will ask you to confirm the file name. You may save the buffer with a different name, in which case the modified status of the buffer being edited does not change. Moe makes a backup for a file only the first time the file is saved from one buffer.
<F3>
Load (read) a file in a new buffer. Pressing <Tab> shows the contents of the current directory, or completes the name if there is only one possible name to show. If the file name starts with ~/, the ~ will be expanded to specify your home directory (tilde expansion).
<F4>
Toggle between showing only the current window or showing up to the selected maximum number of windows.
<F5>
Select the previous window.
<F6>
Select the next window.
<F7>
Undo the last change made to the current buffer. You may keep undoing changes until there are no more changes to undo. The buffer will be then exactly as when it was loaded.
<F8>
Redo the last change undone on the current buffer. The undo history is linear. That is, if you undo some changes and then make another change, this last change replaces the changes undone, so you can't redo them.
<F9>
Copy the selected block at the cursor position. This is a convenient alias for the command C-k c.
<F10>
Show the options menu. This menu allows you to change some editor-wide and current-buffer options, like auto indent, margins, word wrap, ask before exit, etc.
<F11>
Show the buffers menu, a list of all the buffers being edited. This menu allows you to select a buffer and make it the current buffer. Some buffers may appear more that once in the list if they have more than one buffer handle. The buffer names of modified buffers are preceded by an asterisk `*'.
<F12>
Select the last buffer handle where you pressed <F12> and make its buffer the current buffer. This allows you to switch between two buffers, or between two places of the same buffer, by repeatedly pressing <F12>.


Next: , Previous: Function keys, Up: Keyboard commands

6.2 Moving around

The simplest way to move the cursor to the place where you want to edit is with the arrow keys. Moe also provides commands to move to certain points in the buffer.

A-u
Move cursor to the beginning of the buffer.
A-v
Move cursor to the end of the buffer.
A-l
Prompt for a line number, and then move cursor to that line. Line 1 is the first line. If the line number is preceded by a plus or minus sign, it is considered relative to the current line.
A-c
Prompt for a column number, and then move cursor to that column. Column 1 is the first column. If the column number is preceded by a plus or minus sign, it is considered relative to the current column.
A-o
Prompt for an offset value, and then move cursor to the byte with that offset from the beginning of the buffer. The first byte in the buffer has offset 0. If the offset value is preceded by a plus or minus sign, it is considered relative to the current offset.
A-b
Move cursor to the begin of the selected block, if begin of block has been set and is in the current buffer.
A-k
Move cursor to the end of the selected block, if end of block has been set and is in the current buffer.
A-f
Move cursor to the matching `(', `[', `{', `<', `)', `]', `}', `>', `"', `'', `/*' or `*/'. Default movement is forward for undirected delimiters. If the cursor is not on a valid delimiter, Moe tries to guess what delimiter to match.
A-g
Like A-f, but default movement is backward for undirected delimiters.
A-d
Center cursor. Scroll window so that the line with the cursor is vertically centred.
A-w
Scroll window backward (scroll up) leaving `keep-lines' of context, or half screen if `keep-lines' is -1.
A-z
Scroll window forward (scroll down) leaving `keep-lines' of context, or half screen if `keep-lines' is -1.
A-a
Scroll window left 8 columns.
A-s
Scroll window right 8 columns.
C-k 0..9
(Control-k followed by a digit from 0 to 9). Set one of the 10 user bookmarks at the cursor position.
A-0..9
(Keep the <Alt> key pressed while typing a digit from 0 to 9). Move the cursor to one of the 10 user bookmarks.


Next: , Previous: Moving around, Up: Keyboard commands

6.3 Inserting text

To insert printing characters into the text you are editing, just type them. This inserts the characters you type into the buffer at the cursor.

The <Backspace> key deletes the character preceding the cursor, while the <Delete> key deletes the character at cursor. You can delete a whole line with the C-y command.

The <Return> key inserts a newline character in the buffer. If the cursor is in the middle of a line, <Return> splits the line.

Moe can split lines automatically when you type past the right margin if you turn on word wrap in the options menu (see Function keys), or from the command line when invoking Moe.

If you prefer to have text characters replace (overwrite) existing ones rather than being inserted among them, you can activate overwrite mode pressing the <Insert> key. Pressing again the <Insert> key activates the normal insert mode.

To insert a control or special character in the buffer, use the command C-p. It will prompt for a character code in a number of formats and insert it at the cursor.


Next: , Previous: Inserting text, Up: Keyboard commands

6.4 Searching and replacing text

The C-f command enters search mode. It will prompt for the text to be searched for (the search string). The <F9> key will copy the selected block in the string being entered. <F9> may be also used when entering the replacement text.

The C-g command repeats the previous search or replace.

The C-w command searchs for the word at the cursor.

After entering the text to be searched, Moe will prompt for search options. You may just hit <Return> to search forward with default options or type one or more of the following options:

i
Ignore the case of the text being searched.
n
Do not ignore the case of the text being searched. Use it when default is set to ignore case.
r
Replace text. It will prompt for replacement text.
b
Search backward instead of forward.
g
Search globally. Extends the search to all the files being edited.
k
Block search. Restricts the search to the selected block.

If you chose `r' (replace) among the options above, every time the search string is found, you will be prompted whether to replace it with the replacement text. The possible answers are: y (yes) to replace and continue searching, n (no) to not replace this text, but continue searching, or r (rest) to replace all the remaining occurrences of the search string without asking for confirmation.


Next: , Previous: Search, Up: Keyboard commands

6.5 Syntax of regular expressions

Regular expressions have a syntax in which a few characters are special constructs and the rest are "ordinary". An ordinary character is a simple regular expression which matches that same character and nothing else. In Moe's regular expressions, all characters are ordinary characters except `\', which is used to indicate a special character or construct. Here is a list of those special constructs, also known as "special search sequences".

\\
Matches a single `\'. See online help for more special characters.
\?
Matches any single character. For example, `a\?b' will match an `a' followed by any character and then a `b'.
\*
Matches zero or more characters. For example, `a\*b' will match an `a' followed by any number of characters and then a `b'.
\c
This works like `\*', but matches a C/C++ balanced expression. For example, `\<for\>\s(\c)' will match any `for' loop, even if it includes nested parentheses.
\+
Matches zero or more instances of the character inmediately following the `+'. For example, `\+b' will match any number of `b's (including no `b's). `\+' may precede `\[..]', `\w' or `\W', matching any number of characters from those in set (including the empty string). `\+' may precede itself any number of times, matching N-1 or more instances of the character inmediately following the last `+'. For example, `\+\+\+b' will match two or more `b's.
\[..]
Character set. This matches any single character between the brackets. Ranges of characters may be specified by writing the starting and ending characters with a `-' between them. Thus, `\[A-Z]' matches any ASCII uppercase letter. `-' may be specified by placing it first or last. `]' may be specified by placing it first. If the first character after the left bracket is `^' indicates a "complemented set", which matches any character except the ones between the brackets.
\s
Matches zero or more whitespace characters. For example, `a\sb' will match an `a' followed by any number of whitespace characters (or none) and then a `b'.
\S
Matches the longest possible non-empty sequence of whitespace characters. For example, `a\Sb' will match an `a' followed by any positive number of whitespace characters and then a `b'.
\w
Matches any word-constituent character (letters, digits and the underscore) of the ISO-8859-15 or ISO-8859-1 character encodings. Other ISO-8859 encodings are not supported by this command.
\W
Matches any character that is not a word-constituent.
\^
\$
These match the beginning and end of a line. For example, `\^foo\$' matches `foo' on a line by itself.
\<
\>
These match the beginning and end of a word. For example, `\<foo\*\>' will match any whole word beginning with `foo'.

And here are the special replace sequences.
\&
This is replaced with the text which matched the search string. For example, `(\&)' will place parentheses around the matched text.
\c
This is replaced with the text which matched the search string capitalized; the first letter of each word is uppercased and the rest are lowercased.
\l
This is replaced with the text which matched the search string converted to lowercase. For example, `(\l)' will convert to lowercase the matched text and place parentheses around it.
\u
Same as \l, but converts the matched text to uppercase.
\0 - \9
(Backslash followed by a digit from 0 to 9). These are replaced with the text which matched the Nth special search sequence, except beginning/end of line/word, in the search string.


Next: , Previous: Regexps, Up: Keyboard commands

6.6 Block commands

Moe allows you to mark a region of text, the block, and then perform some operations like deleting the block, moving it to another place (in the same or another buffer), changing its encoding, etc. There can be only one block at any given time. If you begin marking a block, any existing block will be unmarked.

Here is a list of the block operations:

C-<Space>
Mark the beginning of block, or the end of block if the beginning is already marked. If pressed in an existing block, unmarks it.
C-k b
Mark the beginning of block.
C-k k
Mark the end of block.
C-k c
Copy the block at the cursor. The text inside the original block remains unchanged.
C-k m
Move the block at the cursor. The text inside the original block is deleted.
C-k y
Delete the text in the block.
C-k r
Read a block of text from a file and insert it at the cursor. This operation ignores rectangular block mode.
C-k w
Write the block to a file. The text inside the original block remains unchanged.
C-k i
Indent block. Add spaces at the beginning of every line in the block.
C-k u
Unindent block. Remove spaces from the beginning of every line in the block.
C-o 1
Encode Base64. Replace text in the block with its Base64-encoded equivalent data.
C-o 2
Decode Base64. Replace Base64-encoded data in the block with its corresponding plain text.
C-o 3
Encode Rot-13. Replace text in the block with its corresponding Rot-13-encoded text.
C-o 4
Encode Rot-47. Replace text in the block with its corresponding Rot-47-encoded text.
C-o 6
Decode Quoted-Printable. Replace Quoted-Printable-encoded text in the block with its corresponding plain text.
C-o 8
Decode UTF-8. Replace UTF-8-encoded text in the block with its corresponding ISO-8859-15 or ISO-8859-1 plain text. Other ISO-8859 encodings are not supported by this command.
C-o d
Remove all duplicate lines in the block leaving the first of each set.
C-o e
Remove all duplicate lines in the block leaving the last of each set.
C-o l
Convert all the letters in the block to lowercase.
C-o u
Convert all the letters in the block to uppercase.


Next: , Previous: Block commands, Up: Keyboard commands

6.7 Terminating your editing session

C-c
Close the current window without saving any changes. If the current window is the only one for its buffer, and the buffer being edited has been modified, or `exit-ask' is enabled (see Invoking Moe), it will ask you before closing the window.
C-x
Save the buffer being edited (if it has been modified), and then close the current window. If the current window is the only one for its buffer, and `exit-ask' is enabled (see Invoking Moe), it will ask you before saving the buffer or closing the window.
C-q x
Save and exit. Save all the modified buffers, and then exit completely. It will always ask you before saving or closing anything.
C-q c
Exit completely without saving. It will always ask you before closing anything.


Next: , Previous: Exiting, Up: Keyboard commands

6.8 Commands showing help and other information

C-h
Show the online help. See Function keys.
A-i
(Show character info). Show the line, position in line, position in buffer (offset) and code of the character at the cursor. (The `position in line' may differ from the column shown in the status line because of <Tab> characters in the line).
C-s 2
C-s 4
C-s 8
(Show little-endian multibyte value). Show the little-endian value of a sequence of 2, 4 or 8 bytes in decimal and hexadecimal. This is useful for example to show things like the CRC or the file size coded in gzip and lzip files.
C-s <F2>
C-s <F4>
C-s <F8>
(Show big-endian multibyte value). Show the big-endian value of a sequence of 2, 4 or 8 bytes in decimal and hexadecimal.
C-s c
(Show character code). Show the code of the character at the cursor on the status line. Repeat the command to revert to normal.
C-s g
(Show global status). Show the number of modified, unnamed and total buffers being edited. Really it shows the number of buffer handles, so the numbers may be greater than expected.
C-s v
Show Moe's version.


Previous: Info commands, Up: Keyboard commands

6.9 Commands for some special functions

C-b
Reformat paragraph. Break it up into lines that fit between the margins. If the cursor is situated to the right of the left margin, this command uses the cursor column as the left margin.
C-p
Insert a control or special character in the buffer. It also accepts an arbitrarily large number in decimal ([1-9]...), hexadecimal (0x...) or octal (0...), and inserts it as a little-endian sequence of binary characters. If the number is followed by `+', a big-endian sequence is inserted instead.
C-y
Delete the current line.
C-o c
Centre the current line between the margins.
C-o n
Change the name of the current buffer preserving undo history, user bookmarks, etc.
C-o r
Redraw the screen.
C-o s
Split the current window into two. The resulting windows share the same buffer. To undo the split just close one of the two windows with C-c.
C-q <F2>
Save to files all the named buffers that have been modified. A named buffer is one with an associated file name. This function is very useful if you do a global replace on many buffers at once and want to save all the modified buffers without pressing <F2> a lot of times.
C-q u
Update copyright notices in all files. For this to work, the copyright notice format should be `Copyright <optional_text> <list_of_years> Copyright_holder_name'


Next: , Previous: Keyboard commands, Up: Top

7 Other features

Emergency save
When Moe is interrupted by an abnormal event (a SIGTERM signal for example), it will try to save all modified buffers in a file named DEADMOE in the current directory.
Binary files
As Moe is 8-bit clean, it is able to edit binary files, though in a somewhat inconvenient way. If the file does not have any newline character, all of it will be loaded as a single line.
DOS files
If Moe detects at load time that all the lines of a file are terminated by a CR/LF pair, assumes it is a DOS file and removes all the CRs. The CRs are restored later when saving the buffer to a file. If some, but not all, of the lines are CR/LF terminated, no action is taken and CRs are shown as control characters on the screen.


Next: , Previous: Other features, Up: Top

8 Reporting Bugs

There are probably bugs in Moe. There are certainly errors and omissions in this manual. If you report them, they will get fixed. If you don't, no one will ever know about them and they will remain unfixed for all eternity, if not longer.

If you find a bug in Moe, please send electronic mail to bug-moe@gnu.org. Include the version number, which you can find by running moe --version.


Previous: Problems, Up: Top

Concept Index