oded - On-disk editor - edit text files by commands directly from shell |
oded - On-disk editor - edit text files by commands directly from shell
oded [<OPTIONS>] <INSTRUCTIONS>
Edit files by issuing editor commands like shell commands, but with the paradigm of well-known visual text processors: open file, move cursor, type in text, search and replace, select, copy, paste, ...
May open multiple files. Always one file is in the foreground. All opened files has a cursor position at which most commands are applied.
Files also have several marks which you can set or refer to in
select
or goto
commands.
A special pair of marks is SELECTION-START and SELECTION-END which
pins the currently selected text for you.
You have one clipboard.
Oded first executes INSTRUCTIONS given in parameters,
then all the instructions given at --script
option(s), if any.
Take instructions from FILE when done processing instructions given in parameters. May specify multiple times. Exit immediately on unknown command or parse error or if a command fails.
Take instructions from STDIN line-by-line.
Contrary to --script
scripts, it does not exit on errors,
just shows what was the exception,
and continues reading instructions.
Suitable for interactive mode.
Same as --script -
, except in error handling.
Set what INSTRUCTIONS to run after each successful command in
interactive mode (ie. --stdin
).
Open PATH file to edit.
open file PATH
only opens already existing files,
open or create ...
creates the file if it is not yet there.
open new file ...
opens a file only if it does not exist yet.
You can switch between multiple opened files by invoking open PATH
or open file PATH
again, or open NAME
if you opened the file
under a certain NAME by as NAME
.
Don't worry, it won't open the same PATH multiple time with conflicting editor states. However your system may allow accessing the same file (by soft and hard links) on different paths. Oded considers only the PATH string when discerning files, so x.txt and ./x.txt and .//x.txt are handled separatedly. You have to open a file before any operation.
Switch to an already opened file with the given NAME alias or
PATH path, if NAME alias is not found.
You can not open a file on path PATH once you set NAME as an alias for
a file on an other PATH.
But you can always refer to the same path by prepending ./
(or /
in case of absolute paths) to it.
Lines and byte offsets are indexed by 0.
Set cursor position in file.
Insert given STRING into the current cursor position. It does not overwrite current selection. Add newline to the end only if called as c<enter>.
Type given STRING into the current cursor position in overwrite mode. It does not overwrite current selection, but the text itself let it be currently selected or not.
Replace given PATTERN to STRING. If PATTERN is not given, then the last search pattern will be used. "Replace next" changes only the next COUNT number of occurrences starting from the cursor position. Default is 1 occurrence, if COUNT is not given. "Replace all" changes all the occurrences from the cursor position down to the end of file. If you want to replace all the occurrences in the whole file, "goto start" first.
Find next occurrence (or previous one if "backward" is specified) of
PATTERN and set the cursor to it.
PATTERN is either a bare word, a string enclosed in quotes, or a regexp
enclosed in slashes (/regexp/
).
PATTERN is not supported to overhang from one line to the next.
Remove newlines from the text if you must.
If the cursor is at a matching text, search PATTERN
will find the
very place where we are, while search next ...
skips 1 char and
continues from there.
Continue searching the next occurrence of the last search query.
You may close this instruction with an empty pattern (//
) to
separate it from the next instruction, since the empty search PATTERN
(both fixed text and regexp) is invalid, thus not searching an other
pattern but the last one.
In interactive mode search next
is enough.
Put a named mark to the current cursor position. NAME must not be a reserved mark name: START, END, SOL, EOL, HERE.
Select text from the previously named mark START-MARK to END-MARK.
Put marks with mark as
command.
You have some special predefined marks:
START
beginning of the fileEND
end of the fileHERE
current cursor positionSOL
start of lineEOL
end of line, excluding the line ending (Newline) charIf either from
or to
is missing, HERE
is implied.
Insert FILE's contents or the output (stdout) of COMMAND to the current cursor position.
Send selected text to COMMAND as stdin,
and in case of filter
, replace selection with its stdout.
Display a list of file paths which were opened.
The one in foreground prefixed with an *
asterisk.
If any of them opened by an alias name, it shown after the path in []
brackets.
Show the contents of the file in foreground.