Text objects are textual patterns like a line, a top level definition, a word, a sentence or any other unit of text. When
objed-local-mode is enabled, certain editing commands (configurable) will activate
objed and enable its modal editing features. When active, keys which would usually insert a character are mapped to objed commands. Other keys and commands will continue to work as they normally would and exit this editing state again.
By default important editing keys like Space, DEL or Return are not bound to modal commands and will execute the regular command and exit
objed. Character movement exits
objed, as well. This makes it convenient to move around and continue by adding/deleting text.
objed shows the current object type in the
mode-line. The textual content of the object is highlighted visually in the buffer and the cursor color is changed, too. The user can now navigate by units of this object, change the object state or switch to other object types.
The object state is either
whole and is indicated in the modeline by
(w) after the object type. With inner state, anything that would be considered delimiters or padding around an object is excluded.
The user can apply operations to objects. By marking objects before applying an operation, s?he can even operate on multiple objects at once. This works similar to the way you interact with files in
dired. When marking an object, the point moves on to the next object of this type.
The object type used for initialization is determined by the entry command (see
objed-cmd-alist). For example, using
beginning-of-defun will activate
objed using the
defun object as an initial object type. With the command
objed would initialize with the
line object. To activate
objed without movement you can use
objed-activate, bound to M-SPC by default. Objed uses the last command and its mapping in
objed-command-alist to choose the initial object.
Objed’s modal state provides basic movement commands which move by line, sexp word or character. Those commands automatically activate the corresponding object type. Other commands only activate the part between the initial position and the new position moved to. By repeating commands you can often expand/proceed to other objects. This way you can compose movement and editing operations very efficiently.
The expansion commands distinguish between block objects (objects built out of lines of text like paragraphs or text blocks with the same level of indentation and also comment blocks) and context objects (programming constructs like strings, brackets, comments or functions). This way you can quickly expand to the desired objects.
For example to move to the end of the paragraph, the user would first move to the end of the line with Ctrl - e. This would activate
objed using the line object with the text moved over. The user can now continue to the end of the paragraph by pressing e again. Now s?he is able to proceed even further by pressing e again OR to continue by adding new text to the end of the paragraph OR to continue by acting on the text moved over, for example killing it by pressing k.
As often with text editing, the explanation sounds more complicated than using it. To get a better impression of the editing workflow with
objed I have added some animated demos below.
To learn more about available features and commands have a look at the descriptions below, the commentary section or the docstrings and bindings defined in
objed-map. To define your own operations and text objects see
objed is still evolving, some bindings might change in this process. Because of that the following screencasts might not always show up to date key bindings.