\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename moe.info
@documentencoding ISO-8859-15
@settitle GNU moe Manual
@finalout
@c %**end of header

@set UPDATED 12 December 2025
@set VERSION 1.16-rc1

@dircategory Editors
@direntry
* Moe: (moe).                   A console text editor
@end direntry


@ifnothtml
@titlepage
@title GNU moe
@subtitle A console text editor
@subtitle for GNU moe version @value{VERSION}, @value{UPDATED}
@author by Antonio Diaz Diaz

@page
@vskip 0pt plus 1filll
@end titlepage

@contents
@end ifnothtml

@ifnottex
@node Top
@top

This manual is for GNU moe (version @value{VERSION}, @value{UPDATED}).

@menu
* Introduction::        Purpose and features of GNU moe
* Basic concepts::      Buffers, buffer handles, files, windows, etc
* Invoking moe::        Command-line interface
* Argument syntax::     By convention, options start with a hyphen
* Configuration::       The configuration file moe.conf
* The status line::     File name, position, etc
* Keyboard commands::   Description of moe's editing capabilities
* Romanization::        Transliterating Cyrillic, Greek, etc, to Latin
* Other features::      Emergency save, binary files, etc
* Problems::            Reporting bugs
* Concept index::       Index of concepts
@end menu

@sp 1
Copyright @copyright{} 2005-2025 Antonio Diaz Diaz.

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


@node Introduction
@chapter Introduction
@cindex introduction

@uref{http://www.gnu.org/software/moe/moe.html,,GNU moe}
is a console text editor for ISO-8859 and ASCII character encodings.
It has a modeless, user-friendly interface, online help, multiple windows,
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, text conversion
from/to UTF-8, romanization, etc. The file size, line length, number of
buffers, and undo/redo capability are only limited by the amount of memory
available and the size of the address space of your machine.

Moe respects your work. By default it won't automatically add, change, or
remove a single byte in your files. Moe is a WYTIWYG (what you type is what
you get) editor.

Moe can easily edit thousands of files at the same time.

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

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

If your text console doesn't show all the ISO-8859-15 characters, try the
command @command{setfont} from the package @samp{kbd}. You may also need to
add the line @samp{append="vt.default_utf8=0"} to /etc/lilo.conf or to the
configuration file of the bootloader in your machine. Check also with the
command @command{kbd_mode} that the keyboard is in the default (ASCII) mode.
Use the following commands to set the text console in the right mode for moe:
@example
kbd_mode -a
setfont -v lat9w-16.psfu
@end example

If your terminal emulator shows characters with @w{codes >= 128} incorrectly,
check that the encoding is set to ISO-8859-15. (Other ISO-8859 encodings may
also work).

The Linux/POSIX terminal interface is insufficient because the character set
used by the terminal can be neither queried nor changed portably by the
application. There seems to be no connection between the current locale and
the character set used by the terminal. A terminal is an interface between
human and computer. If the application sends a code to the terminal without
knowing what glyph the terminal will show to the user, this is a security
hole.


@node Basic concepts
@chapter Basic concepts
@cindex basic concepts

@table @asis
@item Blank character
Space (0x20) or tab (0x09).

@item Whitespace character
Space (0x20), (horizontal) tab (0x09), newline (0x0A), vertical tab (0x0B),
form feed (0x0C), carriage return (0x0D), or no-break space (0xA0).

@item Escape sequence
Sequence of characters beginning with a special character, usually backslash
@samp{\} or escape (0x1B). Beware of escape sequences equivalent to a single
backslash, like @samp{\d092}, @samp{\134}, @samp{\x5C}, or @samp{\u005C}.

@item Escape sequences for special characters
Alert @samp{\a}, backspace @samp{\b}, escape @samp{\e}, form feed @samp{\f},
newline @samp{\n}, carriage return @samp{\r}, (horizontal) tab @samp{\t},
vertical tab @samp{\v}, backslash @samp{\\}, decimal code @samp{\dddd}
(@samp{d} followed by three decimal digits), octal code @samp{\ooo} (one to
three octal digits), hexadecimal code @samp{\xhh} (two hexadecimal digits),
universal-character-name @samp{\uhhhh} or @samp{\Uhhhhhhhh} (four or eight
hexadecimal digits, equivalent to the corresponding ISO 10646 character
coded in UTF-8 in 1 to 6 bytes, limited to 0x7FFF_FFFF).

@item Beginning of text
Position of the first non-blank character in a line, or end-of-line if there
are no non-blank characters in the line.

@item Blank line
One that is empty or only contains whitespace characters.

@item 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.

@item 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.

@item Current line
The line with the cursor.

@item 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 content 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 content back into the file. Until
you save, the changes exist only inside moe, and the file loaded 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.

@item Window
Moe divides the screen into one or more windows, each of which can display
the content of one buffer. Two or more windows can display different parts
of the same buffer. The only limit to the number of windows is screen size.

@end table


@node Invoking moe
@chapter Invoking moe
@cindex invoking moe
@cindex options
@cindex usage
@cindex version

The format for running moe is:

@example
moe [@var{global_options}] [ [+[@var{line}[,@var{column}]]] @var{file} [@var{file_options}] ]...
@end example

@noindent
Where @var{global_options} are a mix of editor options and default
@var{file_options}. Note that the short option names use the same letters as
the options menu inside moe. Most long option names have a negative form:
@option{--backup} @option{--no-backup}.

Each file name may be preceded by @samp{+[@var{line}[,@var{column}]]} to
start the cursor at the line, and optionally column, specified. @var{line}
and @var{column} are applied to subsequent files until new values are
specified for them. @var{column} defaults to 1. A @samp{+} alone puts the
cursor at end-of-buffer.

Numbers given as arguments to command-line options or editor commands
(line, column, offset, etc) may be expressed as decimal, hexadecimal, or
octal values (using the same syntax as integer constants in C++), and may
contain underscore separators: 1_234_567, 0x1234_5678.

A hyphen @samp{-} used as a @var{file} argument means standard input. It can
be mixed with other @var{files} and is read just once, the first time it
appears in the command line. If standard input is a terminal, @samp{-} is
ignored. Remember to prepend @file{./} to any file name beginning with a
hyphen, or use @samp{--}.

If any @var{file} is a directory, moe loads recursively all files in
@var{file}, applying to each of them the @var{line}, @var{column}, and
@var{file_options} specified for @var{file}. This feature makes it easier to
edit a whole tree containing thousands of files. The search order is depth
first. All files in each directory are loaded before descending into
subdirectories. Backups @file{*~}, object files @file{*.o}, compressed files
(@file{*.gz}, @file{*.lz}, etc), graphic files (@file{*.pdf}, @file{*.png},
etc), and symbolic links are ignored.

Moe is able to read some types of non-regular files at startup. Opening
non-regular files during the editing session is not allowed because it could
cause moe to be killed, losing the changes of any other files being edited.
Files corresponding to terminal devices are ignored at startup.

Moe creates an unnamed empty buffer for each empty file name passed in the
command line.

@noindent
moe supports the following editor options: @xref{Argument syntax}.

@table @code
@item -h
@itemx --help
Print an informative help message describing the options and exit.

@item -V
@itemx --version
Print the version number of moe on the standard output and exit.
This version number should be included in all bug reports.

@item -b
@itemx --backup
Create backup files (default).

@item -B
@itemx --no-backup
Don't create backup files.

@item -e
@itemx --exit-ask
Ask always for confirmation when closing or saving-and-closing a buffer.

@item -H
@itemx --smart-home
Normally, when you press the @key{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
@key{Home}, the cursor moves to the first non-blank character.

@item -i
@itemx --ignore-case
Search in moe is case sensitive by default. With this option you can
make it case insensitive by default.

@item -k @var{n}
@itemx --keep-lines=@var{n}
Number of lines to keep for PgUp/PgDn. -1 means half window.

@item -m @var{n}
@itemx --max-windows=@var{n}
Maximum number of windows to show at once on the screen. 0 means as many as
fit.

@item -n @var{n}
@itemx --indent-step=@var{n}
Number of spaces to add or remove when indenting or unindenting a block.

@item -p
@itemx --preserve-links
Preserve (don't break) hard or symbolic links when saving files. This is
done by opening each file for writing without renaming or deleting it first.

@item -s
@itemx --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.

@item -u
@itemx --auto-unmark
Turn off highlighting after any block operation (copy, reformat, ...).

@item -x
@itemx --rectangle
Turn on rectangular block mode. Provide basic rectangular block operations,
like copy or move. This mode won't work properly if there are @key{Tab}
characters in or at the left of the block.

@end table

@noindent
moe also supports the following file options:

@table @code
@item -a
@itemx --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 to the beginning of the line.

@item -l @var{column}
@itemx --lmargin=@var{column}
Set left margin to @var{column}. Default value is 1. The first column is
column 1.

@item -r @var{column}
@itemx --rmargin=@var{column}
Set right margin to @var{column}. Default value is 76. A value of 0 sets the
right margin to the maximum possible @var{column}.

@item -o
@itemx --read-only
Make the buffer read-only.

@item -O
@itemx --overwrite
Disable insert mode. Make typed characters replace existing ones except
at end of line.

@item -w
@itemx --word-wrap
Enable word wrapping. Automatically pass the current word to the next line
when you type past the right margin.

@item -W
@itemx --no-word-wrap
Disable word wrapping.

@item -2
@itemx --two-spaces
Make @samp{reformat paragraph} put two spaces after period. @xref{reformat
paragraph}.

@end table

Exit status: 0 for a normal exit, 1 for environmental problems
(invalid command-line options, I/O errors, etc), 2 to indicate an invalid
or unreadable input file, 3 for an internal consistency error (e.g., bug)
which caused moe to panic.


@node Argument syntax
@chapter Syntax of command-line arguments
@cindex argument syntax

POSIX recommends these conventions for command-line arguments.

@itemize @bullet
@item A command-line argument is an option if it begins with a hyphen
(@samp{-}).

@item Option names are single alphanumeric characters.

@item Certain options require an argument.

@item An option and its argument may or may not appear as separate tokens.
(In other words, the whitespace separating them is optional).
Thus, @w{@option{-o foo}} and @option{-ofoo} are equivalent.

@item One or more options without arguments, followed by at most one option
that takes an argument, may follow a hyphen in a single token.
Thus, @option{-abc} is equivalent to @w{@option{-a -b -c}}.

@item Options typically precede other non-option arguments.

@item The argument @samp{--} terminates all options; any following arguments
are treated as non-option arguments, even if they begin with a hyphen.

@item A token consisting of a single hyphen character is interpreted as an
ordinary non-option argument. By convention, it is used to specify standard
input, standard output, or a file named @samp{-}.
@end itemize

@noindent
GNU adds @dfn{long options} to these conventions:

@itemize @bullet
@item A long option consists of two hyphens (@samp{--}) followed by a name
made of alphanumeric characters and hyphens. Option names are typically one
to three words long, with hyphens to separate words. Abbreviations can be
used for the long option names as long as the abbreviations are unique.

@item A long option and its argument may or may not appear as separate
tokens. In the latter case they must be separated by an equal sign @samp{=}.
Thus, @w{@option{--foo bar}} and @option{--foo=bar} are equivalent.
@end itemize


@node Configuration
@chapter The configuration file 'moe.conf'
@cindex moe.conf

@file{moe.conf} is the runtime configuration file for moe. In it you may
define default editor options, default file options, and file name dependent
options. @file{moe.conf} is optional; you don't need to install it in order
to run moe.

The options specified in the command line override those specified in
@file{moe.conf}.

Inside @file{moe.conf}, file name dependent options override those specified
as default file options.

You may copy the system @file{moe.conf} file @file{$@{sysconfdir@}/moe.conf}
to @file{$XDG_CONFIG_HOME/moe.conf} and customize these options as you like.
(@env{XDG_CONFIG_HOME} defaults to @file{$HOME/.config}). The file syntax is
fairly obvious and there are further instructions in it.


@node The status line
@chapter The status line
@cindex status line

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

@itemize @bullet
@item
The keyboard status. Shows the part already typed of a multi-key command, or
@samp{<} to indicate that there are text columns at the left of the window.
@item
The status characters. @samp{I} for insert mode, @samp{O} for overwrite
mode, @samp{W} for word wrap, @samp{A} for auto indent, @samp{R} for
read-only, and @samp{X} for rectangular block mode.
@item
The name of the file being edited, or @samp{(Unnamed)} if the buffer has not
yet been named. If the buffer has been modified since it was last saved or
opened, an asterisk @samp{*} is displayed before the name and
@samp{(Modified)} is displayed after the name.
@item
The cursor position in the buffer (Line Column).
@item
A 24-hour clock.
@item
The help key, or the code of the character under the cursor, or the line
position of the cursor in the buffer.
@end itemize


@node Keyboard commands
@chapter Keyboard commands
@cindex keyboard commands

Moe tries to rationalize the keyboard commands. The @key{Alt} key is used for
harmless commands like cursor movements and scrolling. The @key{Control} key is
used for more "dangerous" commands like copying text blocks, deleting lines,
or exiting. The @key{Tab} key is used for file name completion and also to
show/hide the directory browser when moe asks for a file name to save or
load. In any case, the unlimited undo capability of moe makes it difficult
to accidentally cause 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 @key{F1} shows the online help, and
@key{F10} allows you to change the options. The online help and some
experience with text editors is all you need to start using moe. Reading the
manual is only required for more advanced uses of moe.

The @key{Control} key is displayed in the online help as @samp{^}, while the
@key{Alt} key is displayed as @samp{^[}. In this manual @kbd{Control-a} is
written as @kbd{C-a}, and @kbd{Alt-a} as @kbd{A-a}.

Some environments "swallow" the @key{Alt} key so that it never reaches the
application. If this happens, press the @key{Esc} key, then release it and
press the desired key. Alternative key sequences are also provided for
environments that intercept the function keys.

@menu
* Function keys::       The most important functions are here
* Moving around::       Moving the cursor to the desired place
* Inserting text::      Inserting text by simply typing it
* Search::              Finding or replacing occurrences of a string
* Regexps::             Syntax of regular expressions
* Block commands::      Delimiting and operating on a region of text
* Exiting::             Terminating your editing session
* Info commands::       Commands showing help and other information
* Other commands::      Commands for some special functions
@end menu


@node Function keys
@section Function keys
@cindex function keys

@table @kbd
@item @key{F1}
@itemx C-h
Show the online help. Press @key{Page_up} to see the previous help
screen or @key{Page_down} to see the next help screen. Press @key{F1},
@kbd{C-c}, or @kbd{C-h} to return to the editor.

@item @key{F2}
Save the current buffer to a file, automatically creating any missing parent
directories. It asks you to confirm the file name. You may save the buffer
with a different name (save as), in which case the buffer may be read-only,
the modified status of the buffer does not change, and the file permissions
are copied from the existing file to the new file. Moe makes a backup of a
file only the first time the file is saved from a given buffer. If moe does
not have permission to make a backup, it reports an error. In this case you
may disable backups to overwrite the original file without making a backup.

@item @key{F3}
Load (read) a file in a new buffer. Pressing @key{Tab} shows the content of
the current directory or a list of files matching the current name, and
completes the name if there is only one possible name to show. The list of
matching files is displayed even if there is only one, showing that a
matching file exists. If the file name starts with @file{~/}, the @file{~}
is expanded to specify your home directory (tilde expansion).

@item @key{F4}
Toggle between showing only the current window or showing up to the
selected maximum number of windows.

@item @key{F5}
Select the previous window.

@item @key{F6}
Select the next window.

@item @key{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.

@item @key{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.

@item @key{F9}
Copy the selected block at the cursor position. This is a convenient
alias for the command @kbd{C-k c}.

@item @key{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.

@item @key{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 than once in the list if they have more than one buffer
handle. The names of modified buffers are preceded by an asterisk @samp{*}.
The names of DOS buffers are preceded by a minus sign @samp{-}. The names of
modified DOS buffers are preceded by a plus sign @samp{+}.

@item @key{F12}
Select the last buffer handle where you pressed @key{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 @key{F12}.

@item C-a 0..9ab
(@kbd{Control-a} followed by a digit from 0 to 9, or a or b).
Provide an alternative access to function keys on those operating systems
and terminal emulators that intercept the function keys. @kbd{C-a 1} to
@kbd{C-a 9} work as @key{F1} to @key{F9}. @kbd{C-a 0}, @kbd{C-a a}, and
@kbd{C-a b} work as @key{F10}, @key{F11}, and @key{F12} respectively.

@end table


@node Moving around
@section Moving around
@cindex 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.

@table @kbd
@item A-u
Move cursor to the beginning of the buffer.

@item A-v
Move cursor to the end of the buffer.

@item 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.

@item 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.

@item 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.

@item A-b
Move cursor to the beginning of the selected block, if the beginning of the
block has been set and is in the current buffer.

@item A-k
Move cursor to the end of the selected block, if the end of the block has
been set and is in the current buffer.

@item A-f
Go to matching delimiter. Move cursor to the matching @samp{(}, @samp{[},
@samp{@{}, @samp{<}, @samp{)}, @samp{]}, @samp{@}}, @samp{>}, @samp{"},
@samp{'}, @samp{`}, @samp{/*}, or @samp{*/}. Default movement is forwards
for undirected delimiters. If the cursor is not on a valid delimiter, moe
tries to guess what delimiter to match.

@item A-g
Like @kbd{A-f}, but default movement is backwards for undirected delimiters.

@item A-d
Center cursor. Scroll window so that the line with the cursor is vertically
centred.

@item A-w
Scroll window backwards (scroll up) leaving @samp{keep-lines} of context, or
half screen if @samp{keep-lines} is -1.

@item A-z
Scroll window forwards (scroll down) leaving @samp{keep-lines} of context, or
half screen if @samp{keep-lines} is -1.

@item A-a
Scroll window left 8 columns.

@item A-s
Scroll window right 8 columns.

@item C-k 0..9
(@kbd{Control-k} followed by a digit from 0 to 9).
Set one of the 10 user bookmarks at the cursor position.

@item A-0..9
(Keep the @key{Alt} key pressed while typing a digit from 0 to 9).
Move the cursor to one of the 10 user bookmarks.

@item C-k e
Extend bookmarks. Set the user bookmarks 1 to 9 that were not previously set
or that are repeated (point to the same character as a previous bookmark).
On buffers with 1000 lines or less, the bookmarks are set at lines 100 to
900. On larger buffers the bookmarks are set at 10% to 90% of the buffer
size in lines.

@end table


@node Inserting text
@section Inserting text
@cindex 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 @key{Backspace} key deletes the character preceding the cursor, while
the @key{Delete} key deletes the character at the cursor. You can delete a
whole line with the command @kbd{C-y}.

The @key{Return} key inserts a newline character in the buffer. If the
cursor is in the middle of a line, @key{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 (@pxref{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 by
pressing the @key{Insert} key. Pressing @key{Insert} again returns to normal
insert mode.

To insert a control or special character in the buffer, use the command
@kbd{C-p}. It prompts for a character code in a number of formats and
inserts it at the cursor.


@node Search
@section Searching and replacing text
@cindex search

@noindent
The command @kbd{C-f} enters search mode. It prompts for the text to be
searched (the search string). The function key @key{F9} copies the selected
block in the string being entered. @key{F9} may also be used when entering
the replacement text.

@noindent
The command @kbd{C-g} repeats the previous search or replace.

@noindent
The command @kbd{C-w} searches for the word at the cursor.

After entering the text to be searched, moe prompts for search options. You
may just hit @key{Return} to search forwards with default options or type one
or more of the following options:

@table @kbd
@item i
Ignore the case of the text being searched, including characters inside sets
and equivalence classes.

@item n
Don't ignore the case of the text being searched. Use it when default is set
to ignore case.

@item r
Replace the text found. Moe then prompts for replacement text.

@item d
Delete the text found. (Replace with nothing).

@item b
Search backwards instead of forwards.

@item g
Search globally. Extends the search to all the buffers being edited.

@item k
Block search. Restricts the search to the selected block.

@end table

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

@samp{d} (delete) works just as 'replace with nothing'.


@node Regexps
@section Syntax of regular expressions
@cindex 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 the
backslash @samp{\}, which is used to indicate a special character or
construct. Here is a list of those special constructs, also known as
'special search sequences'. (Unknown escape sequences or escape sequences
equivalent to a backslash or to a right square bracket are rejected as
syntax errors).

@table @kbd
@item \\
Matches a single @samp{\}. @xref{Basic concepts}, for more special characters.

@item \?
Matches any single character. For example, @samp{a\?b} matches an @samp{a}
followed by any character and then a @samp{b}.

@item \*
Matches zero or more characters. For example, @samp{a\*b} matches an
@samp{a} followed by any number of characters and then a @samp{b}.

@item \c
This works like @samp{\*}, but matches a C/C++ balanced expression. For
example, @samp{\<for\s(\c)} matches any @samp{for} loop, even if it includes
nested parentheses.

@item \+
Matches zero or more instances of the character immediately following the
@samp{+}. For example, @samp{\+b} matches any number of @samp{b}s (including
no @samp{b}s). @samp{\+} may precede @samp{\[..]}, @samp{\w}, @samp{\W}, or
@samp{\=<ch>}, matching any number of characters from those in the set
(including the empty string). @samp{\+} may precede itself any number of
times, matching N-1 or more instances of the character immediately following
the last @samp{+}. For example, @samp{\+\+\+b} matches two or more
@samp{b}s. @samp{\+} may be followed by a escape sequence for a special
character except @samp{\u} and @samp{\U}.

@item \[..]
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 @samp{-} between them. Thus, @samp{\[A-Z]} matches any
ASCII uppercase letter. @samp{-} may be specified by placing it first or
last. @samp{]} may be specified by placing it first. If the first character
after the left bracket is @samp{^}, it indicates a 'complemented set', which
matches any character except the ones between the brackets. Character sets
may contain escape sequences for special characters except @samp{\u} and
@samp{\U}. Equivalence classes may not be used to specify ranges.

@item \=
Equivalence class. This matches any single character belonging to the same
equivalence class as the character immediately following the @samp{=}. For
example, @samp{\=e} matches any of @samp{eèéêë}. The character following the
@samp{=} must be a single-byte character; it may not be a escape sequence.
Equivalence classes may be used inside a character set. Thus,
@samp{\[\=a\=e\=i\=o\=u]} matches any ISO-8859-15 lowercase vowel.

@item \s
Matches zero or more whitespace characters. For example, @samp{a\sb} matches
an @samp{a} followed by any number of whitespace characters (or none) and
then a @samp{b}.

@item \S
Matches the longest possible non-empty sequence of whitespace characters.
For example, @samp{a\Sb} matches an @samp{a} followed by any positive number
of whitespace characters and then a @samp{b}.

@item \T
Matches trailing whitespace. (A sequence of spaces, tabs, and no-break
spaces at the end of a line of text). It is equivalent to
@w{@samp{\+\+\[ \t\xA0]\$}}, but faster. It comes in handy to remove
unwanted trailing whitespace. (Search and delete @samp{\T}). Moe can remove
all the trailing whitespace from a whole source tree in a single step.

@item \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 sequence.

@item \W
Matches any character that is not a word-constituent.

@item \^
@itemx \$
These match the beginning and end of a line. For example, @samp{\^foo\$}
matches @samp{foo} on a line by itself.

@item \<
@itemx \>
These match the beginning and end of a word. For example, @samp{\<foo\+\w\>}
matches any whole word beginning with @samp{foo}.

@end table

And here are the special replace sequences.

@table @kbd
@item \&
This is replaced with the text which matched the search string. For example,
@samp{(\&)} places parentheses around the matched text.

@item \c
This is replaced with the text which matched the search string capitalized;
the first letter of each whitespace-separated word is uppercased and the
rest are lowercased.

@item \l
This is replaced with the text which matched the search string converted to
lowercase. For example, @samp{(\l)} converts to lowercase the matched text
and places parentheses around it.

@item \u
Same as @kbd{\l}, but converts the matched text to uppercase.
@samp{\u0} may be specified as @samp{\u\x30} to avoid an ambiguity with the
universal-character-name escape sequence @samp{\uhhhh} (@pxref{Basic concepts}).

@item \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. Note that octal escape sequences for
special characters can't be used in the replacement string because they
conflict with the special replace sequences @w{@samp{\0 - \3}}.

@end table


@node Block commands
@section Block commands
@cindex 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, moe unmarks any previously
existing block.

Here is a list of the block operations:

@table @kbd
@item C-@key{Space}
Mark the beginning of the block, or the end of the block if the beginning is
already marked. If pressed in an existing block, unmarks it.

@item C-k b
Mark the beginning of the block.

@item C-k k
Mark the end of the block.

@item C-k c
Copy the block at the cursor. The text inside the original block remains
unchanged.

@item C-k m
Move the block at the cursor. The text inside the original block is deleted.

@item C-k y
Delete the text in the block.

@item C-k r
Read a block of text from a file and insert it at the cursor. This operation
ignores rectangular block mode.

@item C-k w
Write the block to a file. The text inside the original block remains
unchanged.

@item C-k i
Indent block. Add spaces at the beginning of every line in the block.

@item C-k u
Unindent block. Remove spaces from the beginning of every line in the block.

@item C-o 1
Encode to Base64. Replace text in the block with its Base64-encoded
equivalent data.

@item C-o 2
Decode Base64. Replace Base64-encoded data in the block with its
corresponding plain text. In case of error, the cursor is moved to the
first byte of the invalid 4-byte group.

@item C-o 3
Encode/decode Rot-13. Replace text in the block with its corresponding
Rot-13-encoded text. Rot-13 encoding is reversible; running the command
a second time restores the original text.

@item C-o 4
Encode/decode Rot-47. Replace text in the block with its corresponding
Rot-47-encoded text. Rot-47 encoding is reversible; running the command
a second time restores the original text.

@item C-o 5
Encode to ASCII. Replace the ISO-8859-15 plain text in the block with an
approximate transliteration to ASCII-encoded text. Other ISO-8859 encodings
are not supported by this command. Any ASCII text already present in the
block is left unmodified. This command does not simply reset the most
significant bit of each byte. For example, the control codes
@samp{0x80}-@samp{0x9F} are converted to the corresponding binary escape
sequences @samp{0x1B 0x40}-@samp{0x1B 0x5F}, the @samp{latin small letter
sharp s (german)} is transliterated to @samp{ss}, and the @samp{euro sign}
is replaced with the string @samp{euro}.

@item C-o 6
Decode Quoted-Printable. Replace Quoted-Printable-encoded text in the
block with its corresponding plain text. In case of error, the cursor is
moved to the invalid character.

@anchor{encode to UTF-8}
@item C-o 7
Encode to UTF-8. Replace the ISO-8859-15 plain text in the block with
its corresponding UTF-8-encoded text. Other ISO-8859 encodings are not
supported by this command. If the text in the block is already valid
UTF-8, encoding is not performed to avoid double UTF-8 encoding. If
@samp{encode to UTF-8} is issued a second time and any byte value
larger than 127 is found, the encoding is performed unconditionally.

@anchor{decode UTF-8}
@item 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. In case of error, decoding
is not performed and the cursor is moved to the first byte of the
invalid or out of range UTF-8 character. If @samp{decode UTF-8} is
issued a second time, the decoding is performed unconditionally, copying
any out of range UTF-8 characters unmodified and producing a document
with mixed encoding (@pxref{remove UTF-8 out of range}).

This command also transliterates some non-Latin scripts into Latin
script (@pxref{Romanization}).

@anchor{reformat paragraphs}
@item C-o b
Reformat all the paragraphs in the block. Whitespace in blank lines between
paragraphs is removed. @xref{reformat paragraph}.

@item C-o d
Remove all duplicate lines in the block searching forwards and leaving only
the first of each set.

@item C-o e
Remove all duplicate lines in the block searching backwards and leaving only
the last of each set.

@anchor{remove UTF-8 out of range}
@item C-o o
Remove UTF-8 out of range. Remove from the UTF-8-encoded text in the
block any valid UTF-8 character out of the range of characters managed
by moe. In case of error, the cursor is moved to the first byte of the
invalid UTF-8 character found. This command can be used before
@samp{decode UTF-8} to avoid mixed encoding in the decoded text.

@item C-o k
Capitalize all the words in the block. (Uppercase the first letter of each
whitespace-separated word and lowercase the rest).

@item C-o l
Convert all the letters in the block to lowercase.

@item C-o u
Convert all the letters in the block to uppercase.

@end table


@node Exiting
@section Terminating your editing session
@cindex exiting

@table @kbd
@item 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 @samp{exit-ask} is enabled (@pxref{Invoking moe}), moe asks you
before closing the window.

@item 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
@samp{exit-ask} is enabled (@pxref{Invoking moe}), moe asks you before
saving the buffer or closing the window.

@item C-q c
Exit completely without saving. Moe asks you before closing anything.

@item C-q x
Save and exit. Save all the modified buffers, and then exit completely. Moe
asks you before saving or closing anything.

@end table


@node Info commands
@section Commands showing help and other information
@cindex info commands

@table @kbd
@item @key{F1}
@itemx C-a 1
@itemx C-h
Show the online help. @xref{Function keys}.

@item A-i
(Show character info). Show the line, position in line, position in buffer
(offset and percent of buffer size), and code of the character at the
cursor. (The @samp{position in line} may differ from the column shown in the
status line because of @key{Tab} characters in the line).

@item A-t
(Show UTF-8 code). Show the UTF-8 code of the (possibly multibyte) character
at the cursor. If the code is valid, the cursor is moved to the first byte
of the character.

@item C-s 2
@itemx C-s 4
@itemx 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.

@item C-s @key{F2}
@itemx C-s @key{F4}
@itemx C-s @key{F8}
(Show big-endian multibyte value). Show the big-endian value of a sequence
of 2, 4, or 8 bytes in decimal and hexadecimal.

@item C-s c
(Show character code). Show on the status line the code of the character
at the cursor. Repeat the command to revert to normal. This command
overrides the command @kbd{C-s p} below.

@item C-s g
(Show global status). Show the number of modified, unnamed, and total
buffers being edited.

@item C-s p
(Show line position in buffer). Show on the status line the percent
position of the current line in the buffer. Repeat the command to revert
to normal. This command overrides the command @kbd{C-s c} above.

@item C-s v
Show moe's version.

@end table


@node Other commands
@section Commands for some special functions
@cindex other commands

@table @kbd
@anchor{reformat paragraph}
@item C-b
Reformat paragraph. Break it up into lines that fit between the margins.
Whitespace between words is collapsed to a single space or no-break space.
If the cursor is situated to the right of the left margin, this command uses
the cursor column as the left margin. @xref{reformat paragraphs}.

@item 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 bytes. If the
number is followed by @samp{+}, a big-endian sequence is inserted instead.
Numbers may contain underscore separators: 1_234_567, 0x1234_5678.
The escape sequences @samp{\uhhhh} and @samp{\Uhhhhhhhh}
(universal-character-name) insert in the buffer the corresponding ISO 10646
character coded in UTF-8 (1 to 6 bytes, limited to 0x7FFF_FFFF).

@item C-y
Delete the current line.

@item C-o c
Centre the current line between the margins.

@item C-o n
Change the name of the current buffer preserving undo history, user
bookmarks, etc.

@item C-o r
Redraw the screen.

@item 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 @kbd{C-c}.

@item C-q @key{F2}
@itemx C-q 2
Save to files all the named buffers that have been modified. A named buffer
is one with an associated file name. This function is useful if you do a
global replace on many buffers at once and want to save all the modified
buffers without pressing @key{F2} a lot of times.

@item C-q u
Update copyright notices in all buffers, inserting the current year in
the list of years and joining the groups of 3 or more consecutive years
in ranges. For this to work, the copyright notice format should be
@w{@samp{Copyright <optional_text> <list_of_years> <copyright_holder_name>}},
and the year numbers must have four digits.
Year numbers separated by a comma @samp{,} are counted individually.
Year numbers separated by a hyphen @samp{-} are counted as a range.

@end table


@node Romanization
@chapter Romanization
@cindex romanization

Romanization is the process of transliterating a language from its
(non-Latin) script into the Latin script. It can be useful when the
capability of rendering the non-Latin script is not available.

The command @samp{decode UTF-8} (@pxref{decode UTF-8}) performs a context
independent transliteration of Cyrillic, Greek, Armenian, and Georgian
scripts, in UTF-8 format, into Latin script in ISO-8859-15 format. If the
transliteration is needed in UTF-8 format, it can be then encoded with the
command @samp{encode to UTF-8} (@pxref{encode to UTF-8}).


@node Other features
@chapter Other features
@cindex emergency save
@cindex binary files
@cindex DOS files

@table @asis
@item Emergency save
When moe is interrupted by an abnormal event (a SIGTERM signal for example),
it tries to save all modified non-empty buffers in a file named
@file{DEADMOE} in the current directory. Each buffer is saved only once even
if it has multiple handles. (To prevent two terminating moes from writing to
the same @file{DEADMOE}, don't run more than one moe from the same directory).

@item Basic @command{less} emulation
In read-only buffers the space bar scrolls forwards leaving 1 line of
context, @samp{b} scrolls backwards leaving 1 line of context, @samp{/} acts
as @samp{Find}, @samp{n} as @w{@samp{Find next}}, @samp{N} as
@w{@samp{Find next}} in reverse direction, and the scroll keys work without
the need of pressing the @key{Alt} key.

@item 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 contain any newline character, all of
it is loaded as a single line.

@item DOS files
If moe detects at load time that all the complete lines of a file are
terminated by a CR/LF (carriage return/line feed) pair, moe assumes it is a
DOS file and removes all the CRs. The CRs are restored later when saving the
buffer to a file. If at least one CR is missing, no action is taken and CRs
are shown as control characters on the screen. If the last line is
unterminated, it is left as-is.

@end table


@node Problems
@chapter Reporting bugs
@cindex bugs
@cindex getting help

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 GNU moe, please send electronic mail to
@email{bug-moe@@gnu.org}. Include the version number, which you can
find by running @w{@samp{moe --version}}.


@node Concept index
@unnumbered Concept index

@printindex cp

@bye
