RJOE(1)
๐ JOE โ Joe's Own Editor ๐
โจ NAME โจ
JOE โ Joe's Own Editor. that's it, that's the whole name, short and iconic ๐
๐ธ SYNTAX ๐ธ
okay so here's how you actually call this thing, all five personalities included:
joe [global-options] [ [local-options] filename ]...
jstar [global-options] [ [local-options] filename ]...
jmacs [global-options] [ [local-options] filename ]...
rjoe [global-options] [ [local-options] filename ]...
jpico [global-options] [ [local-options] filename ]...
๐ DESCRIPTION ๐
so JOE is a powerful console screen editor, no cap. it's got a "mode-less" user interface that feels like all those user-friendly PC editors you already know, and if you grew up on Micro-Pro's WordStar or Borland's "Turbo" languages you're gonna feel right at home bestie. but fr fr, JOE is a full featured UNIX screen-editor โ it has SO many features for editing programs and text. obsessed.
JOE also does cosplay, because why have one editor when you can have five? here's the lineup:
- JSTAR is a close imitation of WordStar, but with a ton of "JOE" extensions. slay.
- JPICO is a close imitation of the Pine mailing system's PICO editor, but with many extensions and improvements. glow up โจ
- JMACS is a GNU-EMACS imitation.
- RJOE is a restricted version of JOE โ it only lets you edit the files you named on the command line. boundaries, queen ๐ซถ
and the wild part? even though JOE is actually five different editors, it still only needs one executable โ just one with five different names. the name of the editor with an "rc" appended gives you the name of JOE's initialization file, and that file is what decides the personality of the editor. it's giving multiple personalities, but make it โจintentionalโจ.
JOE is free software; you can distribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. JOE is available over the Internet from http://www.sourceforge.net/projects/joe-editor. periodt.
๐ฆ USAGE ๐ฆ
to start the editor, type joe followed by zero or more names of files you want to edit. each file name may be preceded by a local option setting (peep the local options table which follows). other global options, which apply to the editor as a whole, may also be placed on the command line (see the global options table which follows). if you're editing a new file, you can either give the name of the new file when you invoke the editor, or in the editor when you save the new file. a modified syntax for file names is provided so you can edit program output, standard input/output, or sections of files or devices. see the section Filenames below for the details ๐
once you're in the editor, you can type in text and use special control-character sequences to do other editing tasks. to find out what those control-character sequences are, read the rest of this man page or type ^K H for help in the editor. iykyk.
now for some obscure computer-lore ๐ง (stay with me):
the ^ means that you hold down the Control key while pressing the following key (the same way the Shift key works for uppercase letters). a bunch of control-key sequences are duplicated on other keys, so you don't need to press the control key at all:
- Esc will work in place of
^[ - Del will work in place of
^? - Backspace will work in place of
^H - Tab will work in place of
^I - Return or Enter will work in place of
^M - Linefeed will work in place of
^J
some keyboards may give you trouble with some control keys. ^_, ^^ and ^@ can usually be entered without pressing shift (i.e., try ^-, ^6 and ^2). other keyboards may reassign these to other keys. try: ^., ^, and ^/. ^Space can usually be used in place of ^@. ^\ and ^] are interpreted by many communication programs, including telnet and kermit. usually you just hit the key twice to get it to pass through the communication program.
on some keyboards, holding the Alt key down while pressing another key is the same as typing Esc before typing the other key. cute little shortcut, we love her ๐
once you've typed ^K H, the first help window appears at the top of the screen. you can continue to enter and edit text while the help window is up, which is honestly main character energy. to page through other topics, hit Esc , and Esc . (that is, Esc , and Esc .). use ^K H to dismiss the help window.
you can customize the keyboard layout, the help screens and a number of behavior defaults by copying JOE's initialization file (usually /etc/joe/joerc) to .joerc in your home directory and then modifying it. see the section joerc below.
to have JOE used as your default editor for e-mail and News, you need to set the EDITOR and VISUAL environment variables in your shell initialization file (.cshrc or .profile) to refer to JOE (JOE usually resides as /usr/bin/joe).
there are a number of other obscure invocation parameters which may have to be set, particularly if your terminal screen is not updating as you think it should. see the section Environment variables below. ๐
๐ COMMAND LINE OPTIONS ๐
these options can also be specified in the joerc file. local options can be set depending on the file-name extension. Programs (.c, .h or .p extension) usually have autoindent enabled. Wordwrap is enabled on other files, but rc files have it disabled. ok so here's the vibe:
an option is enabled when it's given like this:
-wordwrap
an option is disabled when it's given like this:
--wordwrap
some options take arguments. arguments are given like this:
-lmargin 5
the following global options may be specified on the command line:
asisโ characters with codes above 127 will be sent to the terminal as-is, instead of as inverse of the corresponding character below 128. if this does not work, check your terminal server. this option has no effect if UTF-8 encoding is used.assume_256colorโ assume an ANSI-like terminal emulator supports 256 colors even if the termcap entry says it doesn't. delulu but make it useful โจassume_colorโ assume an ANSI-like terminal emulator supports color even if the termcap entry says it doesn't.text_colorcolor โ set color for text.status_colorcolor โ set color for status bar.help_colorcolor โ set color for help.menu_colorcolor โ set color for menus.prompt_colorcolor โ set color for prompts.msg_colorcolor โ set color for messages.autoswapโ automatically swap^K Bwith^K Kif necessary to mark a legal block during block copy/move commands.backpathpath โ sets path to a directory where all backup files are to be stored. if this is unset (the default) backup files are stored in the directory containing the file.backup_file_suffixstring โ sets suffix string to use for backup file names. if this is unset (the default), the suffix is~.baudnnn โ set the baud rate for the purposes of terminal screen optimization (overrides value reported bystty). JOE inserts delays for baud rates below19200, which bypasses tty buffering so that typeahead will interrupt the screen output. Scrolling commands will not be used for38400baud and above. this is useful for X-terms and other console ttys which really aren't going over a serial line.beepโ enable beeps when edit commands return errors, for example when the cursor goes past extremes.break_linksโ when enabled, JOE first deletes the file before writing it in order to break hard-links and symbolic-links. ๐break_hardlinksโ when enabled, and the file is not a symbolic links, JOE first deletes the file before writing it in order to break hard-links.brpasteโ when JOE starts, send command to the terminal emulator that enables "bracketed paste mode" (but only if the terminal seems to have the ANSI command set). in this mode, text pasted into the window is bracketed withESC [ 2 0 0 ~andESC [ 2 0 1 ~.columnsnnn โ set number of columns in terminal emulator (in case termcap entry is wrong). this is only useful on old system which don't have the "get window size" ioctl.csmodeโ enable continued search mode: successive^K Fs repeat the current search instead of prompting for a new one.dopaddingโ enable JOE to send padding NULs to the terminal (for very old terminals). vintage behavior, respect the elders ๐ซถexaskโ when set,^K Xprompts for a new name before saving the file.floatmouseโ when set, mouse clicks can position the cursor beyond the ends of lines.guess_crlfโ when set, JOE tries to guess the file format MS-DOS or UNIX.guess_indentโ when set, JOE tries to guess the indentation character and indentation step based on the contents of the file. the algorithm is to find the greatest common factor of the three most common indentations found in the file. math queen ๐ฅguess_non_utf8โ when set, enable guessing of non-UTF-8 files in UTF-8 locales.guess_utf8โ when set, enable guessing of UTF-8 files in non-UTF-8 locales.guess_utf16โ when set, enable guessing of UTF-16 files. if a UTF-16BE or UTF-16LE file is detected, it is converted to UTF-8 during load, and converted back to UTF-16 during save.helponโ when set, start off with the on-line help enabled.help_is_utf8โ when set, the help text in thejoercfile is assumed to be UTF-8.icaseโ search is case insensitive by default when set.joe_stateโ enable reading and writing of~/.joe_statefilejoextermโ set this ifxtermwas configured with--paste64option for better mouse support.keepupโ the column number on the status line is updated constantly when this is set, otherwise it is updated only once a second.languagelanguage โ sets language foraspell.lightoffโ automatically turn off^K B^K Khighlighting after a block operation.linesnnn โ set number of lines in terminal emulator (in case termcap entry is wrong). this is only useful on old system which don't have the "get window size" ioctl.markingโ enable marking mode: highlights between^K Band cursor.menu_aboveโ put menus above prompt instead of below them.menu_explorerโ stay in menu when a directory is selected (otherwise the directory is added to the path and the cursor jumps back to the prompt).menu_jumpโ jump into the file selection menu whenTab Tabis hit.midโ if this option is set and the cursor moves off the window, the window will be scrolled so that the cursor is in the center. this option is forced on slow terminals which don't have scrolling commands.leftnn โ this sets the number of columns the screen scrolls to the left when cursor moves past the left edge or when thecrawllcommand is issued. if nn is negative, then it's the fraction of the screen to scroll. for example,-2means scroll 1/2 the screen.rightnn โ sets how many columns the screen scrolls to the right when the cursor wanders past the right edge, or when thecrawlrcommand gets issued. If nn is negative, then it's the fraction of the screen to scroll instead. So like,-3means scroll 1/3 the screen. math queen ๐mouseโ enable xterm mouse support. ๐ญnobackupsโ disable backup files.nocurdirโ disable the current-directory prefix in prompts.noexmsgโ disable that exiting message ("File not changed so no update needed").nolinefeedsโ disable sending linefeeds to preserve screen history in the terminal emulator's scroll-back buffer (only relevant whennotitemode is enabled).nolocksโ disable EMACS compatible file locks.nomodcheckโ disable the periodic file modification check.nonoticeโ this option prevents the copyright notice from being displayed when the editor starts.nostaโ this option eliminates the top-most status line. It's nice for when you only want to see your text on the screen, or if you're using a vt52. main character energy, just you and the words ๐ฆnotagsmenuโ disable the selection menu for tags search with multiple results.notiteโ disable thetiandtetermcap sequences, which are usually set up to save and restore the terminal screen contents when JOE starts and exits.pastehackโ if keyboard input comes in as one block, assume it's a mouse paste and disable autoindent and wordwrap.noxonโ disable^Sand^Qflow control, possibly allowing^Sand^Qto be used as editor keys.orphanโ orphan extra files given on the command line instead of creating windows for them (the files are loaded, but you need to use switch-buffer commands to access them). ๐ซถpgnnn โ set number of lines to keep during Page Up and Page Down (use-1for 1/2 window size).regexโ use standard regular expression syntax by default, instead of the JOE syntax (where special characters have their meaning only when preceded with backslash).restoreโ set to have cursor positions restored to the last positions of previously edited files.rtbuttonโ swap left and right mouse buttons.search_promptingโ show the previous search string in the search command (like in PICO).skiptopnnn โ when set to N, the first N lines of the terminal screen are not used by JOE and are instead left with their original contents. This is useful for programs which call JOE to leave a message for the user.squareโ enable rectangular block mode. ๐ฒtransposeโ transpose rows with columns in all menus.titleโ display context (titles) in the status line. When enabled, this shows the first line of the function that the cursor is in on the status line. The syntax filecontext.jsfidentifies which lines are title lines.typeโ select file type, overriding the automatically determined type. The file types are defined in theftypercfile.undo_keepnnn โ sets number of undo records to keep (0means infinite). ๐ฅusetabsโ set to allow rectangular block operations to use tabs.wrapโ enable search to wrap to the beginning of file.
The following local options may be specified on the command line:
+nnn โ the cursor starts on the specified line.autoindentโ enable auto-indent mode. When you hit Enter on an indented line, the indentation is duplicated onto the new line. no cap, it just copies the vibe โจc_commentโ enable^Gskipping of C-style comments/.../cparacharacters โ sets list of characters which can indent paragraphs.cnotparacharacters โ sets list of characters which begin lines which are definitely not part of paragraphs.cpp_commentโ enable^Gskipping of C++-style comments// ...crlfโ JOE uses CR-LF as the end of line sequence instead of just LF. This is for editing MS-DOS or VMS files.encodingencoding โ set file encoding (likeutf-8or8859-1).flowedโ set to force an extra space after each line of a paragraph but the last.forceโ when set, a final newline is appended to the file if there isn't one when the file is saved.frenchโ when set, only one space is inserted after periods in paragraph reformats instead of two. ๐ฅhexโ enable hex-dump mode.highlightโ enable syntax highlighting. ๐highlighter_contextโ enable use of syntax file to identify comments and strings which should be skipped over during^Gmatching.indentcnnn โ sets the indentation character for shift left and shift right (^K ,and^K .). Use32for Space,9for Tab.indentfirstโ when set, the smart home key jumps to the indentation point first, otherwise it jumps to column 1 first.istepnnn โ sets indentation step.linumsโ enable line number display.lmarginโ set left margin.lmsgโ define left-side status bar message.overwriteโ enable overtype mode. Typing overwrites existing characters instead of inserting before them. ๐pictureโ enable "picture" mode โ allows cursor to go past ends of lines.pound_commentโ^Gignores# ...comments.purifyโ fix indentation if necessary before shifting or smart backspace. For example, if indentation uses a mix of tabs and spaces, andindentcis space, then indentation will be converted to all spaces before the shifting operation.rdonlyโ set read-only mode.rmarginnnn โ set right margin.rmsgstring โ define right-side status bar message.semi_commentโ^Gignores; ...comments.single_quotedโ^Gignores ยด...ยดsmartbacksโ enable smart backspace and tab. When this mode is set, backspace and tab indent or unindent based on the values of theistepandindentcoptions.smarthomeโ Home key first moves cursor to beginning of line, then if hit again, to the first non-blank character.smsgstring โ define status command format when cursor is on a character.spacesโ insert spaces when Tab key is hit.syntaxsyntax โ set syntax for syntax highlighting.tabnnn โ set tab stop width.text_delimitersword delimiter list โ give list of word delimiters which^Gwill step through.
For example, "begin=end:if=elif=else=endif" means that ^G will jump between the matching if, elif, else and endif. ๐ง
vhdl_commentโ^Gignores-- ...commentswordwrapโ JOE wraps the previous word when you type past the right margin.zmsgstring โ define status command format when cursor is at end of file.xmsgstring โ define startup message (usually the copyright notice).aborthintstring โ give the key sequence to show in prompts for abort (usually^C).helphintstring โ give the key sequence to show in prompts for help (usually^K H).
๐จ Colors and attributes ๐จ
Combine attributes and up to one foreground color and one background color to create arguments for color options like text_color. For example: bold+bg_green+blue โ that's the whole recipe bestie ๐ซถ
- Attributes:
bold,inverse,blink,dim,underline, anditalic - Foreground colors:
white,cyan,magenta,blue,yellow,green,red, orblack - Background colors:
bg_white,bg_cyan,bg_magenta,bg_blue,bg_yellow,bg_green,bg_redorbg_black
With a 16 color or 256 color terminal emulator (export TERM=xterm-16color), these brighter than normal colors become available:
- Foreground:
WHITE,CYAN,MAGENTA,BLUE,YELLOW,GREEN,REDorBLACK - Background:
bg_WHITE,bg_CYAN,bg_MAGENTA,bg_BLUE,bg_YELLOW,bg_GREEN,bg_REDorbg_BLACK
With a 256 color terminal emulator (export TERM=xterm-256color), these become available:
fg_RGBandbg_RGB, where R, G and B range from 0 - 5. So:fg_500is bright red. ๐ฅfg_NNandbg_NNgive shades of grey, where the intensity, NN, ranges from 0 - 23.
๐ Status line definition strings ๐
-lmsg defines the left-justified string and -rmsg defines the right-justified string. The first character of -rmsg is the background fill character.
-smsg defines the status command (^K Space). -zmsg defines it when the cursor is at the end of the file. The last character of smsg or zmsg is the fill character.
The following escape sequences can be used in these strings:
%t 12 hour time
%u 24 hour time
%T O for overtype mode, I for insert mode
%W W if wordwrap is enabled
%I A if autoindent is enabled
%X Rectangle mode indicator
%n File name
%m ยด(Modified)ยด if file has been changed
%* ยด*ยด if file has been changed
%R Read-only indicator
%r Row (line) number
%c Column number
%o Byte offset into file
%O Byte offset into file in hex
%a Ascii value of character under cursor
%A Ascii value of character under cursor in hex
%w Width of character under cursor
%p Percent of file cursor is at
%l No. lines in file
%k Entered prefix keys
%S ยด*SHELL*ยด if there is a shell running in window
%M Macro recording message
%y Syntax
%e Encoding
%x Context (first non-indented line going backwards)
%dd day
%dm month
%dY year
%Ename% value of environment variable
%Tname% value of option (ON or OFF for Boolean options)
These formatting escape sequences may also be given:
\i Inverse
\u Underline
\b Bold
\d Dim
\f Blink
\l Italic
๐ Basic Editing ๐
When you type characters into the editor, they are normally inserted into the file being edited (or appended to the file if the cursor is at the end of the file). This is the normal operating mode of the editor. โจ
If you want to replace some existing text, you have to delete the old text before or after you type in the replacement text. The Backspace key can be used for deleting text: move the cursor to right after the text you want to delete and hit Backspace a number of times. that's it, that's the whole trick ๐
Hit Enter or Return and boom, you get a line-break. โจ Like, if your cursor is chillin' in the middle of a line and you hit Enter, that line gets split into two and the cursor lands at the start of the second one. And if you hit Backspace at the beginning of a line? That line-break is gone, deleted, bye. ๐
Use the arrow keys to move around the file, bestie. If your keyboard is missing arrow keys (or they're just being dramatic and not working), use ^F to go forwards (right), ^B to go backwards (left), ^P to go to the previous line (up), and ^N to go to the next line (down). The right and left arrows just move one character at a time through the text โ so if you're at the beginning of a line and you press left-arrow, you'll end up at the end of the previous line. The up and down arrows move forwards and backwards by however many characters it takes so the cursor shows up in the same column it was in on the original line. ๐ฏ
Wanna indent your text? Use the Tab key, periodt. It inserts a special control character that makes everything after it start at the next tab stop. Tab stops normally hit every 8 columns, but you can change that with the ^T D command. PASCAL and C programmers often set tab stops every 4 columns. ๐ง
If your terminal screen gets messed up for some reason (like, say, you get a mail notice from biff ๐), you can make the editor refresh the screen by hitting ^R.
There are so many other keys for deleting text and moving around. For example, hit ^D to delete the character the cursor is on, instead of deleting backwards like Backspace. ^D will also delete a line-break if the cursor is at the end of a line. Type ^Y to delete the entire line the cursor is on, or ^J to delete just from the cursor to the end of the line. ๐ซถ
Hit ^A to move the cursor to the beginning of the line it's on. Hit ^E to move it to the end of the line. Hit ^U or ^V to scroll the cursor up or down 1/2 a screen's worth. "Scrolling" means the text on screen moves, but the cursor stays in the same place relative to the screen. Hit ^K U or ^K V to move the cursor to the beginning or the end of the file. And look at the help screens in the editor to find even more delete and movement commands โ there's always more. ๐
Made a mistake? No worries, it happens to the best of us. Hit ^_ to "undo" it. On most keyboards you hit just ^- to get ^_, but on some you might have to hold both Shift and Control down at the same time to get it. And if you "undo" too much? You can "redo" those changes back into existence by hitting ^^ (type this with just ^6 on most keyboards). Undo-redo, the iconic duo. ๐
๐ฐ๏ธ Cursor position history
Okay so imagine you were editing in one place in the file, then you had to temporarily go look at or edit some other place. You can get back to the original spot by hitting ^K -. This command actually returns you to the last place you made a change in the file. And you can step through a whole history of places with ^K - and ^K =, in the same way you step through the history of changes with the "undo" and "redo" commands. Time travel but make it text editing. ๐ฆ
๐พ Save and exit
When you're done editing the file, hit ^K X to exit the editor. You'll be prompted for a file name if you hadn't already named the file you were editing.
When you edit a file, you're actually editing only a copy of the file. So if you decide you don't want the changes you made during a particular edit session, you can hit ^C to exit the editor without saving them. Nothing happened, we don't talk about it. ๐
If you edit a file and save the changes, a backup copy of that file is created in the current directory with a ~ appended to the name, and it contains the original version of the file. Safety net, slay. โจ
๐ File operations
You can hit ^K D to save the current file (possibly under a different name from what the file was called originally). After the file is saved, you can hit ^K E to edit a different file.
If you want to save only a selected section of the file, check out the section on Blocks below. ๐
And if you want to include another file in the file you're editing, use ^K R to insert it.
๐ Filenames
Wherever JOE expects you to enter a file name โ whether on the command line or in prompts inside the editor โ you may also type:
!command
To read or write data to or from a shell command. For example, use joe '!ls' to get a copy of your directory listing to edit, or from within the editor use ^K D !mail jhallen@world.std.com to send the file being edited to me. ๐ฌ
>>filename
Use this to have JOE append the edited text to the end of the file "filename."
filename,START,SIZE
Use this to access a fixed section of a file or device. START and SIZE may be entered in decimal (ex.: 123), octal (ex.: 0777) or hexadecimal (ex.: 0xFF). For example, use joe /dev/fd0,508,2 to edit bytes 508 and 509 of the first floppy drive in Linux. ๐
-
Use this to get input from the standard input or to write output to the standard output. For example, you can put JOE in a pipe of commands: quota -v | joe | mail root, if you want to complain about your low quota. Iconic behavior, honestly. ๐
๐ Using JOE in a shell script
JOE used to use /dev/tty to access the terminal. This caused a problem with idle-session killers (they would kill JOE because the real tty device wasn't being accessed for a long time), so now JOE only uses /dev/tty if you need to pipe a file into JOE, as in:
echo "hi" | joe
If you want to use JOE in a shell script that has its stdin/stdout redirected, but you do not need to pipe to it, you should simply redirect JOE's stdin/stdout to /dev/tty:
joe filename </dev/tty >/dev/tty
๐ Word wrap and formatting
If you type past the right edge of the screen in a C or PASCAL language file, the screen scrolls to the right to follow the cursor. But if you type past the right edge in a normal file (one whose name doesn't end in .c, .h or .p), JOE automatically wraps the last word onto the next line so you don't have to hit Enter. This is called word-wrap mode. Word-wrap can be turned on or off with the ^T W command. JOE's initialization file is usually set up so this mode is automatically turned on for all non-program files. See the section below on the joerc file to change this and other defaults. ๐
Aside from word-wrap mode, JOE does not automatically keep paragraphs formatted like some word-processors do. Instead, if you need a paragraph reformatted, hit ^K J. This command "fills in" the paragraph the cursor is in, fitting as many words in a line as possible. A paragraph, in this case, is a block of text separated above and below by a blank line.
The margins JOE uses for paragraph formatting and word-wrap can be set with the ^T L and ^T R commands. If the left margin is set to a value other than 1, then when you start typing at the beginning of a line, the cursor immediately jumps to the left margin. Sneaky but helpful. ๐
There are a number of options that control the paragraph reformatter and word wrapper:
- The
cparaoption provides a list of characters which can indent a paragraph. For example, in e-mail, quoted matter is indicated by>at the beginnings of lines, so this character should be in thecparalist. - The
cnotparaoption provides a list of characters which, if they are the first non-whitespace character of a line, indicate that the line is not to be included as part of a paragraph for formatting. For example, lines beginning with.innroffcan not be paragraph lines. - Autoindent mode affects the formatter. If
autoindentis disabled, only the first line will be indented. Ifautoindentis enabled, the entire paragraph is indented. frenchdetermines how many spaces are inserted after periods.- When
flowedis enabled, a space is inserted after each but the last line of the paragraph. This indicates that the lines belong together as a single paragraph in some programs. - When
overtypeis enabled, the word wrapper will not insert lines.
๐ฏ Centering
If you want to center a line within the margins, use the ^K A command. Centered, as you deserve. ๐
๐ค Spell checker
Hit Esc N to check the spelling of the word the cursor is on, using the aspell program (or the ispell program if you modify the joerc file). Hit Esc L to check the highlighted block, or the entire file if no block is highlighted. ๐
JOE passes the language and character encoding to the spell checker. To change the language, hit ^T V. For example, use en_US for English.
โจ๏ธ Overtype mode
Sometimes it's so tiresome to have to delete old text before or after you insert new text. This happens, for example, when you're changing a table and you want to maintain the column position of the right side of the table.
When that happens, you can put the editor in overtype mode with ^T T. In this mode, the characters you type in replace existing characters, the way an idealized typewriter would. Also, Backspace simply moves left instead of deleting the character to the left, when it's not at the end or beginning of a line. Overtype mode is not the natural way of dealing with text electronically, so you should go back to insert-mode as soon as possible by typing ^T T again. ๐จ
If you need to insert while you're in overtype mode, hit ^@. This inserts a single Space into the text.
๐ป Control and Meta characters
Each character is represented by a number. For example, the number for A is 65 and the number for 1 is 49. All of the characters you normally see have numbers in the range of 32 - 126 (this particular arbitrary assignment between characters and numbers is called the ASCII character set). The numbers outside of this range, from 0 to 255, aren't usually displayed, but sometimes they have other special meanings. The number 10, for example, is used for the line-breaks. ๐ญ
You can enter these special, non-displayed control characters by first hitting ^Q and then hitting a character in the range @ A B C ... X Y Z [ ^ ] \ _ to get the number 0 - 31, and ? to get 127. For example, if you hit ^Q J, you'll insert a line-break character, or if you hit ^Q I, you'll insert a Tab character (which does the same thing the Tab key does). A useful control character to enter is 12 (^Q L), which causes most printers to advance to the top of the page. You'll notice JOE displays this character as an underlined L. ๐จ๏ธ
You can enter the characters above 127, the meta characters, by first hitting ^\. This adds 128 to the next (possibly control) character entered. JOE displays characters above 128 in inverse-video. Some foreign languages, which have more letters than English, use the meta characters for the rest of their alphabet. You have to put the editor in asis mode to have these passed untranslated to the terminal. ๐
Note: JOE now normally passes all 8-bits to the terminal unless the locale is set toCorPOSIX. If the locale isCorPOSIX, then theasisflag is the thing that decides whether meta characters get shown in inverse video or passed straight on through to the terminal. iykyk ๐
Note: in older versions of JOE you had to use Esc ยด to enter control characters. not us anymore, we're thriving โจ
๐ฆ Character sets and UTF-8 ๐ฆ
okay so JOE natively handles two classes of character sets, bestie: UTF-8 and byte coded (like ISO-8859-1). For both of these, the file gets loaded as-is into memory and is exactly preserved during save โ even if it's stuffed full of UTF-8 coding errors. no cap, it does not care.
It can not yet natively handle other major classes such as UTF-16 or GB2312. And there are more restrictions, so listen:
- character sets must use
LF(0x0A) orCR-LF(0x0D - 0x0A) as line terminators - space must be
0x20 - tab must be
0x09
Basically the files have to be UNIX or MS-DOS compatible text files. that's the vibe check ๐
Which means EBCDIC will not work properly (tho tbh you'd have to handle fixed record length lines anyway) and character sets which use CR terminated lines (MACs) will not yet work.
JOE now supports UTF-16 โ both big endian and little endian ๐. It does UTF-16 by converting to UTF-8 during load, and converting back to UTF-16 during save. iconic behavior honestly.
The terminal and the file can have different encodings, and JOE will translate between the two. Currently, one of the two must be UTF-8 for that translation to work. just how it is ๐ซถ
The character set for the terminal and the default character set assumed for files is determined by the LC_ALL environment variable (and if that's not set, LC_CTYPE and LANG are also checked).
For example, if LC_ALL is set to:
de_DE
Then the character set will be ISO-8859-1.
If LC_ALL is set to:
de_DE.UTF-8
The character set will be UTF-8. see how easy that was ๐ธ
Hit ^T E to change the coding for the file. Hit Tab Tab at this prompt to get a list of available codings. There are a number of built-in character sets, plus you can install character sets in the ~/.joe/charmaps and /usr/share/joe/charmaps directories. go off, custom charmaps โจ
Check /usr/share/i18n/charmaps for example character set files. Only byte oriented character sets will work. Also, the file should not be gzipped (all of the charmap files in /usr/share/i18n/charmaps on my computer were compressed ๐). And the parser is very bad, so basically the file has to look exactly like the example one in /usr/share/joe/charmaps. yes, exactly. we don't make the rules.
You can hit ^K Space to see the current character set.
You can hit ^Q x to enter a Unicode character if the file coding is UTF-8. ๐
๐ฌ Prompts ๐ฌ
Most prompts record a history of the responses you give them, and you can hit up and down arrow to step through those histories. little time machine moment โญ
Prompts are actually single line windows with no status line, so you can use any editing command that you'd normally use on text within them. The prompt history is actually just other lines of the same "prompt file". Which means you can search backwards through the prompt history with the normal ^K F command if you want. cute, right?
Since prompts are windows, you can also switch out of them with ^K P and ^K N.
๐ธ Completion and selection menus ๐ธ
You can hit Tab in just about any prompt to request that JOE complete the word you're typing. If JOE beeps, there are either no completions or many of them. As with the bash shell, hit Tab twice to bring up a list of all the possibilities. That list is actually a menu, but by default the cursor does not jump into it, since it's usually easier to just type in your selection. You can, however, jump into the menu window with ^K P (move to previous window) and use the arrow keys and <Enter> to make your selection. Also in a menu, you can hit the first letter of any of the items to make the cursor jump directly to it. The ^T option menu works like this.
If the menu is too large to fit in the window, you can hit Page Up and Page Down to scroll it โ even if you haven't jumped into it. ๐ฆ
Tab completion works in the search and replace prompts as well. In this case, JOE tries to complete the word based on the contents of the buffer. If you need to search for the Tab character itself, you can enter it with ^Q Tab. niche but necessary, bestie ๐
Also, you can hit Esc Enter in a text window to request that JOE complete the word you're typing. As with the search prompt, JOE tries to complete the word based on the contents of the buffer. It'll bring up a menu of possibilities if you hit Esc Enter twice. main character completion energy ๐
๐ Where am I? ๐
Hit ^K Space and JOE reports the line number, column number, and byte number on the last line of the screen. The number associated with the character the cursor is on (its ASCII code) is also shown. You can have the line number and/or column number always displayed on the status line by placing the appropriate escape sequences in the status line setup strings. Edit the joerc file for details. ๐
๐ญ What if I hit ^K by accident?
Hit the space bar. This runs an innocuous command (it shows the line number on the status bar). crisis averted, bestie, you didn't break anything ๐ซถ
๐ด Temporarily suspending the editor ๐ด
If you need to temporarily stop the editor and go back to the shell, hit ^K Z. You might want to do this to stop whatever you're editing and answer an e-mail message or read this man page, for example. You have to type fg or exit (you'll be told which when you hit ^K Z) to return to the editor. go touch grass, the buffer will wait for you ๐ธ
๐ Searching for text ๐
Okay bestie, this is the part where JOE becomes your personal bloodhound. Hit ^K F and the editor will go hunt down a text fragment (a string) for you โ forwards or backwards, your call. It's gonna prompt you for the text you're looking for. Then after you hit Enter, it hits you with another prompt, this time for options.
And honestly? You can just hit Enter again and it'll immediately go search forwards for your text. Iconic. Low effort, high reward. Orrr you can enter one or more of these bad boys:
bโ search backwards instead of forwards. Going back in time, retro vibes ๐iโ treat uppercase and lowercase letters as the same when searching. Normally, uppercase and lowercase letters are considered to be different, so this is the "don't be so picky" flag โจnnnโ (where nnn is a number) if you enter a number, JOE searches for the Nth occurrence of the text. Super useful for jumping to specific places in files that are structured in some regular manner. Number go brrr ๐ขrโ Replace text. If you enter theroption, then you will be further prompted for replacement text. Each time the editor finds the search text, you will be prompted as to whether you want to replace the found search text with the replacement text. You hit:yto replace the text and then find the next occurrence,nto not replace this text, but to then find the next occurrence,rto replace all of the remaining occurrences of the search text in the remainder of the file without asking for confirmation (subject to thennnoption above),- or
^Cto stop searching and replacing.
You can also hit B or Backspace to back up to the previously found text โ and if it had been replaced, the replacement is undone. Undo queen ๐
aโ the search covers all loaded buffers. So to replace all instances of"foo"with"bar"in all.cfiles in the current directory:
joe *.c
^K F
foo <Enter>
ra <Enter>
bar <Enter>
eโ the search covers all files in the grep or make error list. You can use a UNIX command to generate a list of files and search and replace through the list. So to replace all instances of"foo"with"bar"in all.cfiles which begin withf. You can also use"ls"and"find"instead of grep to create the file list.
Esc G
grep -n foo f*.c <Enter>
^K F
foo <Enter>
re <Enter>
bar <Enter>
xโ JOE will use the standard syntax for regular expressions if this option is given. In the standard syntax, these characters have their special meanings directly, and do not have to be escaped with backslash:.,*,+,?,{,},(,),|,^,$and[. โจyโ JOE will use the JOE syntax for regular expressions instead of the standard syntax. This overrides the"-regex"option. (Yes, it's beefing with a command line flag. Let them fight.)vโ JOE will send debug information about the regular expression to the startup log. The log can be viewed with theshowlogcommand. Nerd mode activated ๐ง
You can hit ^L to repeat the previous search. Laziness is a virtue fr fr.
You can hit ^K H at the search and replace options prompt to bring up a list of all search and replace options. Help is always one keypress away ๐ซถ
โจ Regular Expressions โจ
A number of special character sequences may be entered as search text:
\*โ this finds zero or more of the item to the left. For example, if you giveAB\*Cas the search text, JOE will try to find anAfollowed by any number ofBs, and then aC.\+โ this finds one or more of the item to the left. For example, if you giveAB\+Cas the search text, JOE will try to find anAfollowed by one or moreBs, and then aC.\?โ this indicates that the item to the left is optional. For example, if you giveAB\?Cas the search text, JOE will findACorABC.\{min,max}โ this indicates that JOE should try to find a string with a specific number of occurrences of the item to the left. For example,AX\{2,5}Bwill match these strings:AXXB,AXXXB,AXXXXB, andAXXXXXB. Min can be left out to indicate 0 occurrences. Max (and the comma) can be left out to indicate any number of occurrences.\.โ this finds exactly one character. For example, if you giveA\.Bas the search text, JOE will findAXB, but notABorAXXB.\!โ this works like., but matches a balanced C-language expression. For example, if you search formalloc(\!\*), then JOE will find all function calls tomalloc, even if there was a)within the parenthesis. This one is lowkey genius.\|โ this finds the item on the left or the item on the right. For example, if you giveA\|Bas the search text, JOE will try to find either anAor aB.\( \)โ use these to group characters together. For example, if you search for\(foo\)\+, then JOE will find strings like"foo", and"foofoofoo".^ \$โ these match the beginnings and endings of lines. For example, if you give^test\$, then JOE with findteston a line by itself.\\\โ these match the beginnings and endings of words. For example, if you give\is\\, then JOE will find the word"is"but will not find the"is"in"this". (Boundary bestie behavior ๐)\[...]โ this matches any single character which appears within the brackets. For example, if\[Tt]hisis entered as the search string, then JOE finds bothThisandthis. Ranges of characters can be entered within the brackets. For example,\[A-Z]finds any uppercase letter. If the first character given in the brackets is^, then JOE tries to find any character not given in the the brackets. To include-itself, include it as the last or first character (possibly after^).\\โ matches a single\.\nโ this finds the special end-of-line or line-break character.
A number of special character sequences may also be given in the replacement string:
\&โ this gets replaced by the text which matched the search string. For example, if the search string was\\*\\, which matches words, and you give"\&", then JOE will put quote marks around words.\1-\9โ these get replaced with the text which matched the Nth grouping; the text within the Nth set of\( \).\l,\uโ convert the next character of the replacement text to lowercase or uppercase.\L,\Uโ convert all following replacement text to lowercase or uppercase. Conversion stops when\Eis encountered.\\โ use this if you need to put a\in the replacement string.\nโ use this if you need to put a line-break in the replacement string.
Some examples:
Suppose you have a list of addresses, each on a separate line, which starts with "Address:" and has each element separated by commas. Like so:
Address: S. Holmes, 221b Baker St., London, England
If you wanted to rearrange the list, to get the country first, then the city, then the personยดs name, and then the address, you could do this:
Type ^K F to start the search, and type:
Address:\(\.\*\),\(\.\*\),\(\.\*\),\(\.\*\)\$
to match "Address:", the four comma-separated elements, and then the end of the line. When asked for options, you would type r to replace the string, and then type:
Address:\4,\3,\1,\2
To shuffle the information the way you want it. After hitting return, the search would begin, and the sample line would be changed to:
Address: England, London, S. Holmes, 221b Baker St.
Ate. No crumbs. ๐ฅ
๐ Escape sequences ๐
JOE understands the following escape sequences withing search and replacement strings:
\x{10ffff}โ this matches a specific Unicode code point given in hexadecimal.\xFFโ this matches a specific character specified in hexadecimal.\377โ this matches a specific character specified in octal.\p{Ll}โ this matches any character in the named Unicode category or block.
The block names, such as "Latin-1 Supplement" or "Arabic" can be found here:
Unicode Blocks ftp://ftp.unicode.org/Public/8.0.0/ucd/Blocks.txt
The category names such as "Ll" can be found here:
Unicode Categories
ftp://ftp.unicode.org/Public/5.1.0/ucd/UCD.html#General_Category_Values
Note that a single letter matches all of the category names which start with that letter. For example,\p{N}(any number) include\p{Nd}(decimal digit),\p{Nl}(letter number) and\p{No}(other number).
\dโ this matches any Unicode digit. This is the same as\p{Nd}.\Dโ this matches anything except for a Unicode digit. This is the same as\[^\p{Nd}].\wโ this matches any word character. This is the same as\[^\p{C}\p{P}\p{Z}].\Wโ this matches anything except for a word character. This is the same as\[\p{C}\p{P}\p{Z}].\sโ this matches any space character. This is the same as\[\t\r\f\n\p{Z}].\Sโ this matches anything except for a spacing character. This is the same as\[^\t\r\f\n\p{Z}].\iโ this matches an identifier start character. This is the same as\[\p{L}\p{Pc}\p{Nl}].\Iโ this matches anything except for an identifier start character. This is the same as\[^\p{L}\p{Pc}\p{Nl}].\cโ this matches an identifier continuation character. This is the same as\[\i\p{Mn}\p{Mc}\p{Nd}\x{200c}\x{200d}].\Cโ this matches anything except for an identifier continuation character. This is the same as\[^\i\p{Mn}\p{Mc}\p{Nd}\x{200c}\x{200d}].\tโ Tab\nโ Newline\rโ Carriage return\bโ Backspace\aโ Alert\fโ Formfeed\eโ Escape\\โ Backslash
๐ฆ Incremental search ๐ฆ
Use Esc S to start an increment search forwards, or Esc R to start an incremental search backwards. As you type the search string, the cursor will jump to the first text that matches the regular expression you have entered so far. It's giving live feedback, it's giving instant gratification ๐
Hit Esc S or Esc R again to find the next occurrence of the text or to switch the direction of the search.
^S, ^</pink> and ^L have the same effect as Esc S. ^R has the same effect as Esc R. These keys are to support JMACS.
Hit Backspace to undo the last incremental search action. The last action could be a repeat of a previous search or the entering of a new character. Bestie said "jk" ๐
Use ^Q to insert control characters into the search text. Previously, ` could also be used for this.
Hit any other key to exit the increment search. That's it, you're free, go live your life โจ
๐ซ Goto matching delimiter ๐ซ
Okay bestie, this one is SO satisfying. Hit ^G and you leap between matching delimiters. Like, cursor parkour. ๐ฆ
It works on both:
- character delimiters (think
(and)) - word delimiters, for languages like Pascal and Verilog that use
beginandendto delimit blocks
It also works for matching start and end tags in XML. โจ
And if a word is not known? ^G just starts a search with the word moved into the search prompt. Casual.
Now here's the catch, and it's giving "read the fine print" energy: for ^G to work on word delimiters, the cursor must be positioned on the first letter of the word. So in XML, if the cursor is on the < in <foo>, it will jump to the >. But if it is on the f, it will jump to the matching </foo>. Same deal in C: ^G will jump between #if, #else and #endif, but you need to position the cursor on the letter, not the #. ๐ค
^G is also smart enough to skip delimiters found in quoted or commented-out matter. But you have to tell JOE how your language indicates this: see the ftyperc file for examples of how this is done. ๐
There are a number of options which control the behavior of ^G. These options control which kinds of comments ^G can skip over:
c_commentcpp_commentpount_commentsemi_commentvhdl_comment
These options determine which kinds of strings ^G can skip over:
single_quoteddouble_quoted
This option allows an annotated syntax file to determine which text can be counted as comments or strings which can be skipped over by ^G:
highlighter_context
This option enables the use of syntax files to identify comments and strings which should be skipped over during ^G matching. The syntax file states should be annotated with the string and comment keywords for this to work. ๐ง
text_delimiters
This option provides a list of word delimiters to match. For example, "begin=end:if=elif=else=endif" means that ^G will jump between the matching if, elif, else and endif. It will also jump between begin and end. Chef's kiss. ๐
^G has a built-in table for matching character delimiters โ it knows that ( goes with ).
^G has a built-in parser to handle start/end tag matching for XML.
๐ Regions ๐
So you wanna move, copy, save or delete one specific lil section of text? Say less โ highlighted blocks are your girl. ๐
First, move the cursor to the start of the section of text you want to work on, and press ^K B. Then move the cursor to the character just after the end of the text you want to affect and press ^K K. The text between the ^K B and ^K K should become highlighted. โจ
Now you can move your cursor to someplace else in your document and press ^K M to move the highlighted text there.
You can press ^K C to make a copy of the highlighted text and insert it to where the cursor is positioned. ^K Y to deletes the highlighted text. ^K W, writes the highlighted text to a file.
A very useful command is ^K /, which filters a block of text through a UNIX command. For example, if you select a list of words with ^K B and ^K K, and then type ^K / sort, the list of words will be sorted. Another useful UNIX command for ^K /, is tr. If you type ^K / tr a-z A-Z, then all of the letters in the highlighted block will be converted to uppercase. Pipes? In MY editor? Iconic. ๐ฅ
๐ How do I deselect a highlighted region?
After you are finished with some region operations, you can just leave the highlighting on if you don't mind it (but don't accidentally hit ^K Y). If it really bothers you, however, just hit ^K B ^K K, to turn the highlighting off.
Beginning with JOE 4.2, you can hit ^C to cancel the region selection. ๐
๐ฆ New ways of selecting regions
The classic way is to hit ^K B at the beginning and ^K K at the end. These set pointers called markb and markk. Once these are set you can jump to markb with Esc B and jump to markk with Esc K.
New way: hit Ctrl-Right Arrow to start selecting rightward. Each time you hit Ctrl-Right Arrow, the block is extended one more to the right. This uses a simple macro: "begin_marking,rtarw,toggle_marking".
Unfortunately, there is no standard way to get the keysequence given by the terminal emulator when you hit Ctrl-Right Arrow. Instead you have to determine this sequence yourself and enter it directly in the joerc file. Some examples are given for Xterm and gnome-terminal. Hit ^Q Ctrl-Right Arrow within JOE to have the sequence shown on your screen. Note that Putty uses Esc Esc [ C which will not appear with ^Q Right Arrow (also Esc Esc is the set bookmark command, so you need to unbind it to do this in Putty). ๐ญ
Also you can hit Ctrl-Delete to cut and Ctrl-Insert to paste if the sequence for these keys are known.
The mouse can also be used to select text if mouse support is enabled in JOE. ๐ฑ๏ธ
๐ ๏ธ Indenting program blocks ๐ ๏ธ
Auto-indent mode is toggled with the ^T I command. The joerc file is normally set up so that files with names ending with .p, .c or .h have auto-indent mode enabled. When auto-indent mode is enabled and you hit Enter, the cursor will be placed in the same column that the first non-whitespace character was on in the original line. Lowkey magic.
You can use the ^K , and ^K . commands to shift a block of text to the left or right. If no highlighting is set when you give these commands, the program block (as indicated by indentation) that the cursor is located in will be selected, and will be moved by subsequent ^K , and ^K . commands.
The number of columns these commands shift by and the character used for shifting can be set through the istep and indentc options. These options are available in the ^T menu. Also, ^T = can be used to quickly select from a number of common values for indentation step and character.
JOE has a number of additional options related to indenting programs:
smartbacksโ Enable smart backspace and tab. When this mode is setBackspaceandTabindent or unindent based on the values of theistepandindentcoptions.smarthomeโ TheHomeand^Akeys first move the cursor to the beginning of the line, then if hit again, to the first non-blank character.indentfirstโ Smart home goes to first non-blank character first, instead of going to the beginning of the line first.purifyโ Fix indentation if necessary before shifting or smart backspace. For example, if indentation uses a mix of tabs and spaces, andindentcis space, then indentation will be converted to all spaces before the shifting operation.guess_indentโ When set, JOE tries to guess the indentation character and indentation step based on the contents of the file. The algorithm is to find the greatest common factor of the three most common indentations found in the file.
๐ฒ Rectangle mode ๐ฒ
Type ^T X to have ^K B and ^K K select rectangular blocks instead of stream-of-text blocks. This is also known as columnar mode. This mode is useful for moving, copying, deleting or saving columns of text. You can also filter columns of text with the ^K / command โ if you want to sort a column, for example. The insert file command, ^K R is also affected. ๐
When rectangle mode is selected, overtype mode is also useful (^T T). When overtype mode is selected, rectangles will replace existing text instead of getting inserted before it. Also the delete block command (^K Y) will clear the selected rectangle with Spaces and Tabs instead of deleting it. Overtype mode is especially useful for the filter block command (^K /), since it will maintain the original width of the selected column. So tidy. ๐ซถ
๐ผ๏ธ Picture mode ๐ผ๏ธ
Use ^T P to enter or exit picture mode. Picture mode helps with ASCII drawings. โ๏ธ
Picture mode controls how JOE handles the case where the cursor is past the ends of lines. This happens when you use the up or down arrow keys to move the cursor from the end of a long line to a short line.
If you attempt to type a character in this case:
If picture mode is off, the cursor will jump to the end of the line and insert it there.
If picture mode is on, the line is filled with spaces so that the character can be inserted at the cursor position.
Windows ๐ชโจ
okay bestie, you can edit more than one file at the same time or edit two or more different places of the same file. To do this, hit ^K O to split the screen into two windows. Use ^K P or ^K N to move the cursor into the top window or the lower window. Use ^K E to edit a new file in one of the windows. A window will go away when you save the file with ^K X or abort the file with ^C. If you abort a file which exists in two windows, one of the window goes away, not the file. not me double-checking that, but yes.
๐ก bestie note: "one of the window goes away" โ the window leaves, the file stays. iconic.
You can hit ^K O within a window to create even more windows. If you have too many windows on the screen, but you don't want to eliminate them, you can hit ^K I. This will show only the window the cursor is in, or if there was only one window on the screen to begin with, try to fit all hidden windows on the screen. If there are more windows than can fit on the screen, you can hit ^K N on the bottom-most window or ^K P on the top-most window to get to them. vibe check: scroll the ring, bestie.
If you gave more than one file name to JOE on the command line, each file will be placed in a different window. lowkey convenient.
You can change the height of the windows with the ^K G and ^K T commands.
Windowing system model ๐
JOE has an unusual model for its windowing system. Basically you have a ring of windows, but only a section of this ring may fit on the screen. The windows not on the screen still exist, they are just scrolled off. When you hit ^K N on the bottom window of the screen, it scrolls further windows from the ring onto the screen, possibly letting the top window scroll out of view. it's giving carousel but make it buffers.
Native JOE tries to keep each loaded buffer in a window, so users can find all of the buffers by scrolling through the windows. The explode command (^K I) either expands all windows to the size of the screen so that only one window can fit on the screen, or shrinks them all as much as possible to fit many on the screen. pick your fighter: one big window or a whole squad of tiny ones.
On the other hand, JOE supports "orphan" buffers- files loaded into the editor, but which are not in a window. ^C normally closes a window and discards the buffer that was in it. If you hit ^C on the last remaining window, it will normally exit the editor. However, if there are orphan buffers, ^C will instead load them into this final window to give you a chance to explicitly discard them. If the orphan option is given on the command line, as in joe -orphan *.c, then JOE only loads the first file into a window and leaves all the rest as orphans. fr fr, the orphans get their moment.
orphan also controls whether the edit command ^K E creates a new window for a newly loaded file, or reuses the current window (orphaning its previous occupant).
The bufed command prompts for a name of a buffer to switch into a window. Its completion list will show all buffers, including orphans and buffers which appear in other windows. Esc V and Esc U (nbuf and pbuf commands) allow you to cycle through all buffers within a single window. ngl, cycling buffers in one window is a slay.
Windows maintain a stack of occupants to support the pop-up shell window feature. When a pop-up window is dismissed, the previous buffer is returned to the window.
Scratch buffers ๐งปโจ
Scratch buffers are buffers which JOE does not worry about trying to preserve. JOE will not ask to save modified scratch buffers. Pop-up shell windows, the startup log and compile and grep message windows are scratch buffers. You can create your own scratch buffer with the scratch command. main character energy: temporary, unbothered, no save prompt.
The following commands load scratch buffers:
showlogโ Show startup logmwindโ Show message window (compile / grep messages fromEsc CandEsc Gcommands).
Keyboard macros ๐น๐
Macros allow you to record a series of keystrokes and replay them with the press of two keys. This is useful to automate repetitive tasks. To start a macro recording, hit ^K [ followed by a number from 0 to 9. The status line will display (Macro n recording...). Now, type in the series of keystrokes that you want to be able to repeat. The commands you type will have their usual effects. Hit ^K ] to stop recording the macro. Hit ^K followed by the number you recorded the macro in to execute one iteration of the key-strokes. obsessed with a good macro moment.
For example, if you want to put "**" in front of a number of lines, you can type:
^K [ 0 ^A **down arrow\ ^K ]
Which starts the macro recording, moves the cursor to the beginning of the line, inserts "**", moves the cursor down one line, and then ends the recording. Since we included the key-strokes needed to position the cursor on the next line, we can repeatedly use this macro without having to move the cursor ourselves, something you should always keep in mind when recording a macro. literally the "set yourself up for success" of key recording.
Keyboard macro subroutines ๐
If you find that the macro you are recording itself has a repeated set of key-strokes in it, you can record a macro within the macro, as long as you use a different macro number. Also you can execute previously recorded macros from within new macros. macro-ception, no cap.
Query suspend โธ๏ธ
If your macro includes a prompt for user input, and you want the user to fill in the prompt every time the macro is executed, hit ^K ? at the point in the macro recording where the user action is required. Keyboard input will not be recorded at this point. When the user completes the prompt, macro recording will continue.
When the macro is executed, the macro player will pause at the point where ^K ? was entered to allow user input. When the user completes the prompt, the player continues with the rest of the macro. pausing for user input? that's highkey thoughtful.
Repeat ๐
You can use the repeat command, ^K \, to repeat a macro, or any other edit command or even a normal character, a specified number of times. Hit ^K \, type in the number of times you want the command repeated and press Enter. The next edit command you now give will be repeated that many times. For example, to delete the next 20 lines of text, type:
^K \ 20return^Y
Macros and commands ๐๐
A macro is a comma separated list of commands. When the macro is executed, each command is executed until either the end of the list is reached, or one of the commands fails (non-zero return value from the command). Failed commands beep if you have beeps enabled (^T B). oof, the beep of failure.
Hit Esc D to insert the current set of keyboard macros as text into the current buffer. For example, the "**" insert macro above looks like this:
home,"**",dnarw ^K 0 Macro 0
You could insert this into your .joerc file and change the key sequence (the K 0) to something more permanent. glow-up your keybindings, bestie.
Define your own ๐ ๏ธ
You can bind macros to key sequences or define your own named macros in the joerc file. For example, this will define a macro called foo:
:def foo eof,bol
foo will position the cursor at the beginning of the last line of the file. eof jumps to the end of the file. bol jumps to the beginning of a line. Once a macro has been named this way it will show up in the completion list of the Esc X command prompt. custom macros are the ultimate accessory.
Command prompt ๐ฌ
You can execute a macro directly by typing it into the command prompt. Hit Esc X to bring up the command prompt. Hit Tab at this prompt for a completion list of all available commands.
Here is a complete list of commands.
Macro donยดt stop modifier ๐
Sometimes, you expect commands to sometimes fail, but want the rest of the commands in the list to be executed anyway. To mark a command which is allowed to fail, postfix it with !. For example, here a macro which hits down page in the window above:
prevw,pgdn!,nextw
If prevw fails, the macro is aborted as usual. Even if pgdn fails (already at end of buffer), nextw will be executed so that the cursor is returned to the original window. resilience queen behavior.
Macro repeat argument modifiers ๐ข
Repeat arguments can be specified with ^K \. When a command is executed with a repeat argument, it is repeatedly executed the specified number of times. If the repeat argument is negative, an opposite command (if one exists) is executed instead. For example, if you repeat rtarw -3 times, ltarw will be repeated 3 times. If a negative argument is given for a command which does not have an opposite, the repeat argument is ignored.
Normally, if a repeat argument is specified for a macro, the macro is simply repeated the given number of times. If a negative argument is given, the argument is ignored.
Sometimes you want to allow negative arguments for macros and have their behavior modified. To do this, postfix each command within the macro which should be switched to its opposite for negative arguments with -. For example, here is the page down other window macro:
prevw,pgdn-!,nextw
Now if you execute this with an argument of -2, it will be repeated twice, but pgup will be executed instead of pgdn. (note that several postfix modifiers can be placed after each command). negative numbers but make it opposite day.
Sometimes when a repeat argument is given to macro, you want only one of the commands in the list to be repeated, not the entire macro. This can be indicated as follows:
prevw,pgdn#!,nextw
If this is executed with an argument of 2, prevw is executed once, pgdn is executed twice, and nextw is executed once. not the whole macro, just that one command. periodt.
Finally, even more complex semantics can be expressed with the "if" command:
if~,"arg<0",then,
ltarw,
else,
rtarw,
endif
When the macro is executed, the "arg" math variable is set to the given repeat argument. The "argset" variable is set to true if the user set an argument, even if itยดs 1. If no argument was given, argset is false. math variables? in my editor? it's more likely than you think.
If any command in the list is postfixed with ~ (if above), the macro is not repeated, even if there is an argument. arg is still set to the given repeat count, however.
ยดpshยด/ยดqueryยด interaction ๐ค
The psh command saves the ^K B and ^K K positions on a stack. When the macro completes, (or when the pop command is called) the positions are restored.
The query command suspends macro execution until the current dialog is complete. It also suspends the automatic pop which happens at the end of a macro- so if the macro ends in a dialog you often want to call query to prevent the ^K B ^K K positions from being restored too early. save the positions, protect the vibe.
๐ท๏ธ Tags search
okay bestie, if you're deep in a giant C program spread across a million source files, this is the feature you're gonna be obsessed with ๐. There's a program called ctags and you use it to generate a tags file. What's in it? A whole list of program symbols plus the files and positions where those symbols are defined. It's giving โจmap of your entire codebaseโจ.
First things first: make the tags file with the ctags program. Like:
ctags *.c *.h
That creates a file called tags in the current directory. periodt.
JOE looks for the tags file in the current directory. If there isn't one, it'll try to open the file specified by the TAGS environment variable instead.
heads up ๐ซถ โ paths inside the tags file are always relative to the location of the tags file itself. no cap.
The tags file holds a list of identifier definition locations, and it can be in any one of these formats:
identifier filename /search-expression/[;comments]
identifier filename ?search-expression?[;comments]
identifier filename line-number[;comments]
Some versions of ctags sneak class-names into the identifiers, like:
class::member
When that happens, JOE will match on any of these strings:
member::memberclass::member
Some versions of ctags also put a filename in the identifier:
filename:identifier
In that case JOE will only find the identifier if the buffer name matches the filename. picky but fair ๐ .
The search-expression is a vi regular expression, but ngl JOE only supports these special characters:
^at the beginning means the expression starts at the beginning of the line$at the end means the expression ends at the end of the line\xquotes x (suppresses the meaning of/,?,^or$)
Type ^K ; to bring up a tags search prompt. If your cursor had been sitting on an identifier, the prompt comes pre-loaded with it (main character behaviour honestly ๐). Tab completion works in this prompt too โ it uses the tags file to find completions. so cute.
When you hit Enter, the tags search commences:
- If there is one and only one match, JOE jumps directly to the definition. slay.
- If there are multiple matches, then the behavior is controlled by the
notagsmenuoption:- If
notagsmenuis enabled, JOE jumps to the first definition. If you hit^K ;again before hitting any other keys, JOE jumps to the next definition, and so on. Thetagjumpcommand also performs this function. - If
notagsmenuis disabled, JOE brings up a menu of all the matches. You pick the one you want and JOE jumps to it. And if you hit^K ;again before hitting any other keys, the same menu re-appears with the cursor left in the original location. iconic.
- If
You can hit ^K - to move the cursor back to the original location from before the tags search (often ^C will work as well).
๐ซถ one thing bestie: since^K ;loads the definition file into the current window, you probably wanna split the window first with^K O, so you've got both the original file and the definition file loaded at once. trust.
๐งฎ Calculator
JOE has a built-in calculator, and you invoke it with Esc M. literally so fun.
Math functions
sin, cos, tan, exp, sqrt, cbrt, ln, log, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, int, floor, ceil, abs, erf, erfc, j0, j1, y0, y1
Variables
eโ set toepiโ set topitopโ set to the line number of the top window linelinesโ set to the number of lines in the filelineโ set to the current line numbercolโ set to the current column numberbyteโ set to the current byte numbersizeโ set to the buffer sizeheightโ set to the window heightwidthโ set to the window widthcharโ set to the ASCII value of the character under the cursormarkvโ true if there is a valid block set (^KB...^KK)rdonlyโ true if the file is read-onlyargโ current repeat argumentargsetโ true if a repeat argument was givenis_shellโ true if executed in an active shell windowno_windowsโ number of buffer windows on the screenansโ result of the previous expression
Commands
hexโ hex display modedecโ decimal display modeinsโ insertansinto the buffersumโ sum of numbers in the blockcntโ count numbers in the blockavgโ average value of numbers in the blockdevโ standard deviation of numbers in the blockevalโ evaluate math expressions in the block (or the whole file if no block is set)joe(...)โ execute a JOE macro (the argument is in the same format asjoercfile macros). The return value of the JOE macro is returned (for macro success, return true (non-zero)).
For example:
joe(sys,"[ 1 == 1 ]",rtn)
[ 1 == 1 ] is a shell command. [ is a synonym for the test UNIX command.
Returns true.
And remember bestie: the argument for the JOE macro command if is a math expression. So for example, the macro:
if,"joe(sys,\"[ 1 == 1 ]\",rtn)",then,"TRUE",endif
Types TRUE into the buffer. ๐
Operators:
!xโ logical not of x.xโ raise x to power of y. (yes, this is exactly how the page prints it, iykyk ๐)a*bโ multiply.a/bโ divide.a%bโ modulus.a+bโ add.a-bโ subtract.a<bโ true if a is less than b.a<=bโ true if a is less than or equal to b.a>bโ true if a is greater than b.a>=bโ true if a is greater than or equal to b.a==bโ true if a equals b.a!=bโ true if a does not equal b.a&&bโ true if both a and b are true.a||bโ true if either a or b are true.a?b:cโ if a is true return b, otherwise return c.a=bโ assign b to a.a:bโ execute a, then execute b.
&&, || and ? : work as in C and sh as far as side effects go: if the left side of && is false, the right side is not evaluated. ; is expression separator.
๐ Shell windows
Hit ^K ' to run a command shell in one of JOE's windows. yes, a whole shell, living inside your editor, no cap ๐ฆ.
When the cursor is at the end of a shell window (use ^K V if it's not), whatever you type gets passed to the shell instead of the buffer. Any output from the shell, or from commands you run in the shell, is appended to the shell window (and the cursor will follow that output if it's sitting at the end of the shell window). This command is chef's kiss for recording the results of shell commands โ for example the output of make, the result of grepping a set of files for a string, or directory listings from FTP sessions. besides typeable characters, the keys ^C, Backspace, Del, Return and ^D are passed to the shell. Type the shell exit command to stop recording shell output. And if you press ^C in a shell window when the cursor is not at the end of the window, the shell is killed. ๐
If you use Bash, you can hit: ^Q Up Arrow and ^Q Down Arrow to scroll through Bash's history buffer. Other keys work as well: try ^Q ^A to go to the beginning of the line, or ^Q ^E to go to the end of the line. Unfortunately JOE only emulates a dumb terminal, so you have to use a lot of imagination to do any editing beyond hitting backspace ๐ญ.
In general, any character quoted with ^Q is sent to the shell.
Also sent to the shell: Tab, Backspace, Enter, ^C and ^D.
โจ Pop-up shell windows โจ
Okay bestie, hit F1 - F4 to open shell windows and bop between them. ๐
These pop-up shell windows come with a full terminal emulator, so when you type man ls it actually formats correctly (like, properly enough that some interactive programs are usable in there). But plot twist: the shell window is still an edit buffer. It's giving chameleon. ๐ฆ
The old shell window (the one with no terminal emulation) is still around โ use ^K ยด to summon it like always. This one's handy when you wanna see the raw control sequences a program is spitting out. ๐
More keys get passed through to the running program in pop-up shell windows than in the older one. There's a :vtshell section of the joerc file that controls exactly which ones. Specifically: arrow keys and Ctrl-C go straight to the program. Which means you can scroll through bash history with the arrow keys like a normal person, or abort programs the normal way with Ctrl-C. Slay. โจ
But on the other hand, losing Ctrl-C means it's lowkey less obvious how to close the window. Options, bestie:
- Move the cursor off the shell data entry point (with
Ctrl-P), then hitCtrl-C. - Hit
^K Q. - Type
popat the command prompt.
If you need to pass a key to the shell that JOE normally uses, quote it. For example, if you invoke emacs -nw in the shell window, you can exit it with:
^Q ^X ^C
To quickly yeet the cursor back to the point where data is entered into the shell, hit ^K V. ๐
When you open a shell window, a JOE-specific startup-script gets sourced. It lives in /etc/joe/shell.sh (and also /etc/joe/shell.csh). It contains some aliases that let you control JOE with fake shell commands. Here's the full list so far:
clearโ erase shell window (delete buffer contents)joe fileโ edit a file in JOEmath 1+2โ evaluate equation using JOE's calculatorcd xyzโ change directory, keep JOE up to datemarkbโ same as^KBmarkkโ same as^KKmark commandโ execute shell command, mark it's outputparse commandโ execute shell command, parse it's output for file names and line numbers (for find or grep)parser commanโ execute shell command, parse it's output for errors (for gcc)releaseโ release parsed errorspopโ dismiss shell window (same as^K Q)
How do these even work? They emit an escape sequence that the terminal emulator recognizes: Esc { joe_macro }. When that arrives, the macro gets executed. And for security, only macros defined in the joerc file which begin with shell_ can be executed this way. No sneaky business. ๐ซถ
๐ Use cases ๐
Pop-up shell windows have a number of nice use cases:
- Use it to browse manual pages
Hit F1 and type man fopen. Use ยดbยด (ยดuยด) and space to control more (or less) while viewing the manual. You can leave the manual on the screen in one window while editing in another window.
- Use it to switch directories
Hit F1 and navigate to the directory while using cd. Once you are in the right place, hit ^K E to load a file (or type edit file from the shell).
- Use it in conjunction with the error parser to find files
Hit F1 and navigate to a directory. Use grep or find (or both) to generate a list of files):
parse grep -n FIXME *.c
Or:
markb; find . | xargs grep -n FIXME; markk; parse
(Note that you canยดt say this:
parse find . | xargs grep -n FIXME
...the issue is that only the words to the left of the pipe symbol are passed as arguments to the parse command).
Now use ^P to position the cursor on one of the lines of the list. Hit Esc Space to have JOE edit the file and jump to the specified line (also you can use Esc - and Esc = to step through the list).
- Use it in conjunction with search and replace to edit many files
Once JOE has a list of files (from above), use search and replace with the ยดeยด option to visit all of them:
^K F
Find: <text>
Options: re
Replace: <replacement text>
- Build your project
Easily capture errors from a build with:
parserr make
Hit Esc = and Esc - to step through the errors.
๐ง How it works.. ๐ง
- There is a new mode
"ansi". (Esc X mode ansi). When this mode is enabled, the screen updater hides escape sequences which are in the buffer. Otherwise you get a big mess from the sequences surrounding colored output from ยดlsยด. ๐ญ - There is a new built-in syntax:
"ansi". (^T Y ansi). This syntax parses the ANSI color control sequences so that text gets colored. ๐ - There is a terminal emulator to interpret control sequences from the shell program. It emulates a terminal by modifying the contents of an edit buffer.
- When the edit window is resized we tell the shell by issuing the
TIOCSSIZEorTIOCSWINSZioctl. This way, the program running in the shell knows the window size.
๐ฅ Compiler and grep/find parsers ๐ฅ
JOE has two parsers which can be used to generate the error list (list of file names / line numbers).
The "parserr" command parses the entire buffer, or if the block is set, just the highighted block for compiler error messages. The messages should be in this format:
<junk> file.name <junk> line-number <junk> : <junk>
The file name needs to be made of numbers, letters, ยด/ยด, ยด.ยด and ยด-ยด. It must have at leat one ยด.ยด in it. There needs to be a colon somewhere after the line number. Lines not in this format are ignored.
The "gparseยด command parses the entire buffer, or if the block is set, just the highlighted block for a list of filenames or filenames with line numbers from "grep -n", "find" and similar programs.
filename
filename:<junk>
filename:line-number:<junk>
Once JOE has the error list, there are a number of things you can do with it:
- Visit the files/locations in the list with
Esc -andEsc = - Search and replace across all files in the list by using the ยดeยด search and replace option.
- Clear the list by using the
"release"command.
Also, you can use Esc Space (ยดjumpยด command) to parse the line the cursor is on and jump to the parsed filename and line number. ยดjumpยด uses the grep/find parser unless ยดparserrยด had been previously issued in the buffer.
โญ Grep-find โญ
Hit Esc G to bring up the prompt. Enter a command which results in file names with line numbers, for example: ยดgrep -n fred *.cยด. This will list all instances of ยดfredยด in the *.c files. You need the ยด-nยด to get the line numbers.
Now you can hit Esc Space on one of the lines to jump to the selected file. Also, you can use Esc = and Esc - to step through each line. ๐
๐ Compile ๐
Hit Esc C to save all modified files and then bring up the compile prompt. Enter the command you want to use for the compiler (typically "make -w"). The compiler will run in a shell window. When itยดs complete, the results are parsed.
The ยด-wยด flag should be given to "make" so that it prints messages whenever it changes directories. The message are in this format:
make[1]: Entering directory `/home/jhallen/joe-editor-mercurial/joeยด
If there are any errors or warnings from the compiler you can hit Esc Space on one of the lines to jump to the selected file. Also, you can use Esc = and Esc - to step through each line.
๐ธ Syntax highlighting ๐ธ
To enable highlight use ^T H.
To select the syntax, use ^T Y. You can hit Tab Tab at the prompt for a completion list.
JOE tries to determine the syntax to use based on the name and contents of the file. The configuration file /etc/joe/ftyperc contains the definitions.
Each syntax is defined by a file located /usr/share/joe/syntax/.
๐ฆ How JOE syntax highlighting works ๐
so bestie, gather round, because this is the โจloreโจ behind your pretty colors. ๐
this whole thing comes from c.jsf โ http://joe-editor.hg.sourceforge.net/hgweb/joe-editor/joe-editor/file/tip/syntax/c.jsf.in, slightly modified. shoutout. ๐
here's the vibe: a deterministic state machine that does lexical analysis of your target language lives inside a syntax file. that's right, it's basically the "assembly language" of syntax highlighting. and fr fr, a whole separate program could in principle be used to convert a regular expression NFA syntax into this format. iykyk. ๐
every state kicks off with:
:<name> <color-name> <context>
let's break it down, no gatekeeping here:
nameโ that's the state's name, bestie.color-nameโ the color used for characters eaten by the state (really just a symbol for a user-definable color, so you can remix it later ๐จ).contextโ this tells JOE if the current character is part of a comment or a string. why do we care?? because it lets JOE skip over comments and strings when it's matching characters like parentheses. ๐ซถ to use this feature, thehighlighter_contextoption has to be applied to the files highlighted by the corresponding syntax. to apply it, just add it toftypercfor those file entries. periodt.
the valid contexts are:
- comment โ this character is part of a comment. example:
/* comment */ - string โ this character is part of a string. examples:
"string",'c','string'
the comment and string delimiters themselves should be marked with the appropriate context. and listen โ the context is considered to be part of the color, so the recolor=-N and recolormark options apply the context to previous characters too. ๐
also: the first state defined is the initial state. no cap.
within a state, you define transitions (aka jumps) to other states. each jump looks like this:
<character-list> <target-state-name> [<option>s]
there are three ways to specify those character-lists, and yes you need all of them:
*โ matches any character not otherwise specified ๐%or&โ matches the character in the delimiter match buffer (%matches the saved character exactly, while&matches the opposite character โ for example(will match)when&is used). iconic behavior honestly.- a literal list of characters within quotes (ranges and escape sequences allowed: see Escape Sequences ๐)
when the next character matches anything in the list, a jump to the target-state happens and the character gets eaten (we advance to the next character of the file to be colored). munch. ๐
โ ๏ธ the * transition should be the first transition specified in the state. don't be chaotic about it.
๐ the options ๐
there are several options, and every single one is here, so let's go:
noeatโ do not eat the character, instead feed it to the next state (this tends to make the states smaller, but be careful: you can make infinite loops ๐).noeatimpliesrecolor=-1.recolor=-Nโ recolor the pastNcharacters with the color of the target-state. for example, once/*is recognized as the start of a C comment, you want to color the/*with the C comment color usingrecolor=-2.markโ mark the beginning of a region with the current position.markendโ mark the end of a region.recolormarkโ recolor all of the characters in the marked region with the color of the target-state. ifmarkendis not given, all of the characters up to the current position are recolored. note that the marked region can not cross line boundaries and must be on the same line asrecolormark. ๐จbufferโ start copying characters to a string buffer, beginning with this one (it's OK to not terminate buffering with a matchingstrings,istringsorholdoption โ the buffer is limited to leading 23 characters). twenty-three, bestie. remember it. โจsave_cโ save character in delimiter match buffer.save_sโ copy string buffer to delimiter match buffer.stringsโ a list of strings follows. if the buffer matches any of the given strings, a jump to the target-state in the string list is taken instead of the normal jump.istringsโ same asstrings, but case is ignored. ๐ข note:stringsandistringsshould be the last option on the line. they cause any options which follow them to be ignored.holdโ stop buffering string. a futurestringsoristringswill look at the contents of the buffer at this point. useful for distinguishing commands and function calls in some languages:write 7is a command,write (is a function call โholdlets us stop at the space and delay the string lookup until the(or7. big brain move ๐ง
the format of the string list is:
"string" <target-state> [<options>s]
"string" <target-state> [<options>s]
"&" <target-state> [<options>s] # matches contents of delimiter match buffer
done
(all of the options above are allowed except strings, istrings and noeat. noeat is always implied after a matched string. ๐)
okay and now for the weirdness, because there's always a weirdness:
only states have colors, not transitions. ๐ญ so sometimes you have to make dummy states with:
* <next-state> noeat
...just to get a color specification. it's giving workaround but we respect it. ๐
and finally, the delimiter match buffer โ this one's for perl and shell ๐. a regex in perl can be s<..>(...) and in shell you can say: <<EOS ....... EOS. the idea is that you capture the first delimiter into the match buffer (the < or the first "EOS") and then match it to the second one with "&" in a string or character list. chef's kiss. ๐จโ๐ณ๐
๐ธ Subroutines ๐ธ
highlighter state machines can now make subroutine calls, bestie. this works by template instantiation: the called state machine is included in your current state machine, but it gets modified so that the return address points to the called. there is still no run-time stack (the state is represented as a single integer plus the saved delimiter string). wild, i know.
recursion is allowed, but is self limited to 5 levels.
๐ note: this recursion limit is obsolete. subroutines now do use a stack, so the call-depth is limitless. slay. ๐
to call a subroutine, use the call option:
"\"" fred call=string(dquote)
the subroutine called string gets called and the jump to fred is ignored. the dquote option is passed to the subroutine. ๐ซถ
if you use recolor along with call, the color used is that of the first state of the subroutine.
the subroutine itself returns to the caller like this:
"\"" whatever return
if we're in a subroutine, it returns to the target state of the call ("fred" in the above example). if we're not in a subroutine, it jumps to "whatever".
if you use recolor along with return, the color used is from the returned state ("fred" in the example above).
there are several ways of delimiting subroutines, which show up in how it's called. here are the options:
call=string()โ a file calledstring.jsfis the subroutine. the entire file is the subroutine. the starting point is the first state in the file.call=library.string()โ a file calledlibrary.jsfhas the subroutine. the subroutine within the file is calledstring.call=.string()โ there is a subroutine calledstringin the current file.
when a subroutine is within a file, but is not the whole file, it's delimited as follows:
.subr string
option flags can be passed to subroutines which control preprocessor-like directives. for example:
.ifdef dquote
"\"" idle return
"'" idle return
.else is also available. and .ifdefs can be nested. ๐ชโจ
๐ The joerc file ๐
Okay bestie, so literally everything you love about JOE's vibes lives in one little config file. The ^T options, the help screens, and the key-sequence-to-editor-command bindings? All defined in JOE's initialization file. If you make a copy of this file (which normally chills at /etc/joe/joerc) over to $HOME/.joerc, you can customize all these settings to your liking. The syntax of the initialization file should be pretty obvious and there are further instructions in it, so like, read the instructions bestie ๐ซถ
The joerc file has a directive to include another file: :include. This facility is used to include a file called ftyperc (usually located in /etc/joe/ftyperc). ftyperc has the file type table which determines which local options (including syntax for the highlighter) are applied to each file type.
๐ธ Initialization file loading sequence ๐ธ
If the path for an initialization file begins with / (you can specify this with the include directive), JOE only tries to load it from the absolute path. Otherwise, JOE tries to load initialization files (the joerc file and any files included in it, typically ftyperc) from three places:
"$HOME/.joerc"โ The user's personalized joerc file. ๐"/etc/joe/joerc"โ The system's joerc file. The exact path is fixed during the build, and is determined by the--sysconfdirconfigure script option."*joerc"โ Built-in file. This means JOE searches for the file in a table of files linked in with the JOE binary (they are in thebuiltins.cfile). A built-in joerc file is provided so that the editor will run in cases where system's joerc is inaccessible.
If the system's joerc file is newer than the user's joerc file, JOE will print a warning in the startup log. Previous versions of JOE would prompt the user for this case โ the idea was that JOE may be unusable with an out of date initialization file. ๐ญ
โจ joerc file sections โจ
The joerc file is broken up into a number of sections:
- Global options โ Options which are not file specific, like
noxon. - File name and content dependent options โ Options which depend on the file type, such as
autoindent. Theftypercfile is included in this section. ^Tmenu system definition โ Use:defmenuto define a named menu of macros. Themenucommand brings up a specific named menu.^Tis a macro which brings up the root menu:menu,"root",rtn.- Help screen contents โ Each help screen is named. The name is used to implement context dependent help.
- Key bindings โ Key binding tables are defined. You can define as many as you like (you can switch to a specific one with the
keymapcommand), but the following must be provided: mainโ Editing windowspromptโ Prompt windowsqueryโ Single-character query promptsqueryaโ Single-character query for quotequerysrโ Single-character query for search and replaceshellโ Shell windowsvtshellโ Terminal emulator shell windows
Key binding tables can inherit bindings from already defined tables. This allows you to group common key bindings into a single table which is inherited by the others. Iconic behavior fr fr. ๐
๐ Mode command ๐
Many options can be controlled with the ^T menu. This menu is defined in the joerc file. Each option in the ^T menu just executes a macro. Usually the macro is the mode command. You can execute the mode command directly with:
Esc X mode <enter>
Hit Tab Tab for a completion list of all options. It's giving convenience. โจ
๐ Menu command ๐
This command calls up a named menu of macros which was defined in the joerc file.
Esc X menu <enter>
As usual, hit Tab Tab at the prompt for a completion list of the menus which exist.
^T is bound to the simple macro menu,"root",rtn โ it brings up the root of the options menu system. Main character energy honestly. ๐
๐ฆ Xterm Mouse support ๐ฆ
There are two levels of mouse support. The -mouse option enables the first level, which will work with any stock Xterm. If -joexterm is also set, mouse support is enhanced, but you need a recent version of XTerm, and it needs to be ./configured with the --enable-paste64 option.
When -mouse is set, you can:
- Left-click in a text window to set the cursor position. Left-click in a different window to move the cursor to a different window.
- Select text with the mouse. Left-click and drag to select some text โ it will be as if you had used
^K Band^K Kto mark it. Left-click (but don't drag) to position the cursor somewhere else. Middle click to copy the selected text to the cursor โ it will be as if you had hit^K C. If you drag past the edge of the text window, the window will auto-scroll to select more text. Unfortunately, Xterm does not send any codes when the cursor is outside of the Xterm frame itself, so this only works if the mouse is still contained within the Xterm frame. I've sent a patch to the Xterm maintainer to improve this, but he has not taken it yet. ๐ญ - Resize windows with the mouse: click and hold on a status line dividing two windows to move it.
- Select menu entries (such as any completion menu or the
^Toptions menu): click on the menu item to position the cursor on it. Double-click on a menu item to select it (same as hitting return with cursor on it). - If your mouse has a wheel, turning the wheel will scroll the window with the cursor.
Unfortunately, when -mouse is selected, cut and paste between X windows does not work as it normally does in a shell window (left-click and drag to select, middle click to paste). Instead, you have to hold the shift key down to do this: shift-left-click and drag to select, and shift-middle click to paste. Note that pasting text into JOE this way has problems: any ` characters will get messed up because ` means quote the following control character. Also if auto-indent is enabled, pasted text will not be indented properly.
Note: these problems with pasting have been resolved in recent versions of JOE. ๐
- JOE enables "bracketed paste" mode in Xterm so that pasted text is bracketed with an escape sequence. This sequence causes JOE to disable the
autoindent,wordwrapandspacesmodes for the paste, and restores them when the paste is complete. - Even if the terminal emulator does not have this bracketed paste mode, JOE detects pasted text by timing: If text arrives all at once (all in the same buffer), the text is assumed to be pasted text and
autoindentandwordwrapare temporarily disabled.
When -joexterm is set (and you have ./configured Xterm with --enable-paste64):
- Cut & paste are properly integrated with X. Text selected with left-click-drag is available for pasting into other X windows (even if the selected text is larger than the text window). Text selected in other X windows can be pasted into JOE with middle-click. There are no problems pasting text containing
`or with auto-indent.
--enable-paste64 allows an application program to communicate Base-64 encoded selection data to and from the Xterm. The program has full control over what is in the selection data and when it is received or sent. Slay. ๐
๐ Color Xterm support ๐
JOE can make use of monochrome Xterm, 8-color Xterm, 16-color Xterm, 88-color Xterm and 256-color Xterm. The number of colors which Xterm supports is determined by which "configure" script options are set before the Xterm source code is compiled. The termcap or terminfo entry must support how your Xterm is configured. On my Slackware Linux distribution, you have to set the TERM environment variable to one of these:
xtermxterm-colorxterm-16colorxterm-88colorxterm-256color
If the termcap/terminfo entry is missing, you can add the "-assume_256color" option to the joerc file. Note that this was broken for terminfo in versions of JOE below 3.4. ๐
When it is working, the command: "joe -assume_256color -text_color bg_222" should have a gray background. Aesthetic. ๐ธ
๐ Hex edit mode ๐
When this mode is selected (either put -hex on the command line, or look for "Hex edit mode" after hitting ^T), the buffer is displayed as a hex dump, but all of the editing commands operate the same way. It is most useful to select overtype mode in conjunction with hex dump (hit ^T T). Then typing will not insert.
- To enter the hex byte
0xF8type^Q x F 8 - You can use
^K Cto copy a block as usual. If overtype mode is selected, the block will overwrite the destination data without changing the size of the file. Otherwise it inserts. - Hit
Esc X byte <Enter>, to jump to a particular byte offset. Hex values can be entered into this prompt like this:0x2000. - Search, incremental search, and search & replace all operate as usual.
Hex mode is lowkey underrated bestie, no cap. ๐ฅ
โจ Environment variables โจ
okay bestie, so for JOE to actually vibe correctly, a bunch of other environment stuff has to be right too. it's giving "the editor is fine, your terminal is the problem" ๐ญ
The throughput (baud rate) of the connection between the computer and your terminal has to be set correctly, because that's what lets JOE update the screen smoothly and lets typeahead defer the screen update. Use the stty nnn command to set it. You want it as close as possible to the actual throughput of the connection. Like, if you're connected via a 1200 baud modem, you want to use that value for stty. If you're connected via a 14.4k modem, but the terminal server you're connected to connects to the computer at 9600 baud, you want to set your speed as 9600 baud. The special baud rate of 38400 or extb means "very-high speed connection", like a memory mapped console or an X-window terminal emulator ๐
If you can't use stty to set the actual throughput (maybe because of a modem communicating with the computer at a different rate than it's communicating over the phone line), you can put a numeric value in the BAUD environment variable instead โ use setenv BAUD 9600 for csh or BAUD=9600; export BAUD for sh.
The TERM environment variable must be set to the type of terminal you're using. If the size (number of lines/columns) of your terminal is different from what's reported in the TERMCAP or TERMINFO entry, you can set this with the stty rows nn cols nn command, or by setting the LINES and COLUMNS environment variables. heads up though: the terminal size is variable on modern systems and is determined by an ioctl, so these parameters often have no effect ๐
JOE normally expects that flow control between the computer and your terminal uses ^S/^Q handshaking โ i.e., if the computer is sending characters too fast for your terminal, your terminal sends ^S to stop the output and ^Q to restart it. If the flow control uses out-of-band or hardware handshaking, or if your terminal is fast enough to always keep up with the computer output and you want to map ^S/^Q to edit commands, you can set the environment variable NOXON to have JOE attempt to turn off ^S/^Q handshaking. And if the connection between the computer and your terminal uses no handshaking and your terminal is not fast enough to keep up with the output of the computer, you can set the environment variable DOPADDING to have JOE slow down the output by interspersing PAD characters between the terminal screen update sequences ๐ข
Here's the complete list of the environment variables:
BAUDโ Tell JOE the baud rate of the terminal (overrides value reported bystty).COLUMNSโ Set number of columns in terminal emulator (in case termcap entry is wrong). This is only useful on old system which don't have the "get window size" ioctl.DOPADDINGโ Enable JOE to send padding NULs to the terminal when set (for very old terminals).HOMEโ Used to get path to home directory for~expansion and also to find~/.joercfile~/.joedirectory.HOSTNAMEโ Used to get hostname to put in EMACS compatible locks.JOETERMโ Gives terminal type: JOE will use this instead ofTERMif it's set.LANGโ Sets locale (likeen_US.utf-8). JOE uses the first of these which is set:LC_ALL,LC_CTYPE,LANG.LC_ALLโ Sets locale (likeen_US.utf-8). JOE uses the first of these which is set:LC_ALL,LC_CTYPE,LANG.LC_CTYPEโ Sets locale (likeen_US.utf-8). JOE uses the first of these which is set:LC_ALL,LC_CTYPE,LANG.LINESโ Set number of lines in terminal emulator (in case termcap entry is wrong). This is only useful on old system which don't have the "get window size" ioctl.NOXONโ Disable^Sand^Qflow control, possibly allowing^Sand^Qto be used as editor keys.SHELLโ Path to shell (like/bin/sh). This is used in several places: If you are on a system with no job control, this shell is invoked when you hit^K Z. Also this is the shell which is run in shell windows. IfSHELLis not set (Cygwin) or if it's set to/bin/sh, JOE invokes the first of these which exists:/bin/bash,/usr/bin/bash,/bin/sh.SIMPLE_BACKUP_SUFFIXโ If this is set, it is appended to the file name instead of~to create the backup file name.TAGSโ If set to a path to a file, JOE tries to use this as the "tags" file if there is no "tags" file in the current directory.TEMPโ If set, gives path to directory to open swapfile instead of/tmpTERMCAPโ Used by JOE's built-in termcap file parser (not used for terminfo). A termcap entry can be placed directly in this variable (which will be used if it matchesTERM), or if it begins with/, it gives a list of paths to termcap files to search.TERMPATHโ Gives list of paths to termcap files to search whenTERMCAPhas a termcap entry (otherwise it's ignored). The default list of paths to termcap files (whenTERMCAPandTERMPATHdo not have it) is:"~/.termcap /etc/joe/termcap /etc/termcap"TERMโ Gives terminal type, like"vt100"or"xterm".USERโ Used to get user name for EMACS compatible file locks.
๐ JOE commands grouped by function ๐
These commands can be entered at the Esc X prompt. yes bestie, that's your command palette era ๐
Background programs
bkndโ Run a shell in a windowvtbkndโ Run a shell in a terminal emulator windowkillprocโ Kill program in current windowrunโ Run a UNIX command in a windowsysโ Run a UNIX command and return to editor when done (I/O does not go through editor, but we get the command's return status).
Blocks
blkcpyโ Copy marked block to cursorblkdelโ Delete marked blockblkmoveโ Move marked block to cursorblksaveโ Save marked block into a filecopyโ Copy block to kill-ringdropโ Setmarkb. If it was already set, eliminate it.droponโ Setmarkb. If it was already set, eliminate it. Turn on marking mode.toggle_markingโ If we're in a block: clearmarkbandmarkk. If marking is off: setmarkband turn on marking. If marking is on: setmarkk(swap if necessary withmarkb) and turn marking off.begin_markingโ If we're on an edge of a block: setmarkbto other edge and turn on marking mode. Otherwise setmarkbto cursor and turn on marking mode.selectโ Setmarkb. If it was already set, do nothing.filtโ Filter block or file through a UNIX commandmarkbโ Set beginning of block markmarkkโ Set end of block markmarklโ Mark current linenmarkโ Eliminatemarkbandmarkkpicokillโ Delete line or blockpopโ Restoremarkbandmarkkvalues from stackpshโ Pushmarkbandmarkkvalues onto a stackswapโ Switch cursor withmarkbtomarkbโ Move cursor tomarkbtomarkbkโ Move cursor tomarkbormarkktomarkkโ Move cursor tomarkkyankโ Insert top of kill ringyankpopโ Scroll through kill ringyappโ Append next kill to top of kill ringupperโ Convert everything in block to uppercaselowerโ Convert everything in block to lowercase
Buffers
bufedโ Buffer menueditโ Load file into window: asks to reload if buffer existsswitchโ Load file into window: always uses buffer if it existsscratchโ Push a scratch buffer into current windowpopabortโ Abort and pop window from stack (do nothing if stack empty)nbufโ Load next buffer into current windowpbufโ Load previous buffer into current windowreloadโ Re-read file into buffer (revert)reloadallโ Re-read all unmodified buffers
Cursor Motion
bofโ Move cursor to beginning of filebolโ Move cursor to beginning of line (always)bopโ Move to beginning of a paragraphbosโ Move to beginning of screenbkwdcโ Search backwards for a characterbyteโ Move cursor to specific byte offset into the file.colโ Move cursor to specific column number.dnarwโ Move cursor down one lineeofโ Move cursor to end of fileeolโ Move cursor to end of lineeopโ Move cursor to end of paragraphfwrdcโ Search forward for matching charactergomarkโ Move cursor to a bookmarkhomeโ Move cursor to beginning of linelineโ Move cursor to specified lineltarwโ Move cursor leftnedgeโ Move cursor to next edgenextposโ Move cursor to next position in cursor position historynextwordโ Move cursor to end of next wordpedgeโ Move cursor to previous edgeprevposโ Move cursor to previous position in cursor position historyprevwordโ Move cursor to beginning of previous wordrtarwโ Move cursor rightsetmarkโ Set a bookmarktomatchโ Move cursor to matching delimitertosโ Move cursor to top of screenuparwโ Move cursor up
Deletion
backsโ Backspacebackwโ Backspace a worddelbolโ Delete to beginning of linedelchโ Delete character under cursordeleolโ Delete to end of linedellinโ Delete entire linedelwโ Delete word to right
Error parsing
nxterrโ Goto next parsed errorparserrโ Parse errors in current filegparseโ Parse grep list in current filejumpโ Parse current line and jump to itprverrโ Go to previous parsed errorshowerrโ Show current messagegrepโ Execute grep command, parse when donebuildโ Execute build command, parse when donereleaseโ Release error/grep records
Exit
cancelโ Likeabort, but doesn't return failure: useful in macros to escape out of a prompt.abortโ Bye-bye current buffer/window ๐ but if it's been changed, JOE's gonna stop and ask first. No sneaky discards here.abortbufโ Same energy asabort, except it just fails instead of prompting when it would have to ask โ which happens when it's the last window sitting on a modified buffer.askโ Prompts you to save the current file. You say yes โ it returns. You say no โ it runsabort. It's giving macro glue, so use it like"ask,query,exsave".exsaveโ Save the file and exit. That's it, that's the whole thing. โจloseโ The EMACS kill buffer. The buffer gets deleted โ and any windows hanging out with it get a replacement scratch buffer instead. ๐querysaveโ Prompts to save each modified buffer, one by one. Macro vibes:"querysave,query,killjoe".killjoeโ Exits JOE immediately, no checking for modified buffers, no questions, no mercy. ๐
โจ Files โจ
cdโ Set the directory prefix.saveโ Save file.savenowโ Save right this second โ unless the file name isn't known yet, in which case nope.insfโ Insert a file.
๐ธ Formatting ๐ธ
centerโ Center the line. Aesthetic. ๐fmtblkโ Format every paragraph in a block.formatโ Format the current paragraph.lindentโ Indent to the left.rindentโ Indent to the right.
๐ Help ๐
helpโ Turn help on or off.hnextโ Switch to the next help screen.hprevโ Switch to the previous help screen.
๐ฆ Inserting ๐ฆ
ctrlโ Type the next key.finishโ Complete the word in a text window.inscโ Insert a space.openโ Insert a newline.quoteโ Insert a control character.quote8โ Insert a meta character.rtnโ The Return / Enter key.typeโ Insert the typed character.secure_typeโ Insert the typed character, but only allowed in prompt windows โ it is not allowed in shell windows. ๐ซ
๐ Macros ๐
macrosโ Insert keyboard macros into the current file.playโ Execute a macro.queryโ Suspend macro recording so the user can be queried.recordโ Record a macro.stopโ Stop recording the macro.
๐ Menu ๐
backsmenuโ Undo in the file completion menu.bofmenuโ Move to the beginning of the menu.bolmenuโ Move to the beginning of the line in a menu.dnarwmenuโ Move down one line in a menu.eolmenuโ Move the cursor to the end of the line in a menu.eofmenuโ Move the cursor to the end of the menu.ltarwmenuโ Move the cursor left in a menu.rtarwmenuโ Move the cursor right in a menu.uparwmenuโ Move the cursor up in a menu.dnslidemenuโ Scroll the menu down one line.upslidemenuโ Scroll the menu up one line.pgupmenuโ Scroll the menu up.pgdnmenuโ Scroll the menu down.tabmenuโ Tab through the menu.
โญ Misc โญ
beepโ Beep. ๐execmdโ Execute a JOE command.debug_joeโ Insert debug information into the buffer.mathโ Calculator.mathsโ Secure Calculator โ there's no way to runjoe()macros from it. ๐modeโ Mode prompt.menuโ Menu prompt.msgโ Display a message.notmodโ Clear the modified flag.retypeโ Refresh the screen.shellโ Suspend the process or execute a sub-shell.statโ Display the cursor position.tagโ Tags file search.tagjumpโ Jump to the next tags file search match โ only ifnotagsmenuis set.timerโ Execute a macro periodically.txtโ Insert text. If the first character is a backtick (`), then the text is assumed to be a format string โ like, the same kind of string used to define the status line for thermsgandlmsgoptions โ and it gets formatted before the insertion.nameโ Insert the current file name.languageโ Insert the current language.charsetโ Insert the current character set.keymapโ Switch to another keymap.
๐ Prompts ๐
completeโ Complete a file-name in a prompt.ifโ Only run the following cmds if the expr is true (non-zero).thenโ Same asrtn, but it only works in prompt windows.elsifโ Try a new condition.elseโ Toggle the truth flag.endifโ Start running cmds again.
Here's an example if macro, bestie:
if,"char==65",then,"it's an A",else,"it's not an A",endif ^[ q
So when you hit Esc q (^[ q), if the character under the cursor is an 'A': "it's a A" gets inserted into the buffer โ otherwise "it's not an A" gets inserted. ๐
"if" creates a math prompt (like Esc M). "then" is like "rtn" โ it hits the return key for this prompt.
Within the math prompt, these variables are available:
charโ ASCII value of the character under the cursor.widthโ Width of screen.heightโ Height of screen.byteโ byte number.colโ column number.lineโ line number.linesโ no. lines in file.topโ line number of the top line of the window.
๐ซถ Repeat ๐ซถ
argโ Prompt for the repeat argument.uargโ Universal argument.
๐ Scrolling ๐
crawllโ Pan the screen left.crawlrโ Pan the screen right.dnslideโ Scroll the screen down 1 line.pgdnโ Scroll the screen down.pgupโ Scroll the screen up.upslideโ Scroll up one line.
๐ง Search and replace ๐ง
ffirstโ Find text.fnextโ Repeat the previous search.isrchโ Incremental search forward.qreplโ Search and replace.rfirstโ Search backwards for text.rsrchโ Reverse incremental search.
๐ Windows ๐
explodeโ Display one window, or display all windows.dupwโ Duplicate the current window.growwโ Increase the size of the window.nextwโ Move the cursor to the next window.prevwโ Go to the previous window.shrinkwโ Shrink the window.splitwโ Split the window into two.tw0โ Eliminate this window.tw1โ Show only one window.mwindโ Get the error messages window on the screen and put the cursor in it.showlogโ Get the startup log scratch buffer into a window.mfitโ Fit two windows on the screen: make the current window 6 lines, and give the rest of the space to the window above. That window above is either the existing previous window, or a newly created one if there wasn't one.
๐ Undo ๐
redoโ Re-execute the latest undone change.undoโ Undo the last change.
๐ญ Mouse ๐ญ
tomouseโ Move the cursor to wherever the mouse was clicked/dragged.defmdownโ Default single-click handler, usually bound toMDOWN. Positions the cursor to the mouse and begins a region.defmupโ Default single-click release handler, usually bound toMUP. Completes the selection of a region.defmdragโ Default single-click drag handler, usually bound toMDRAG. Selects a region of text a character at a time.defm2downโ Default double-click handler, usually bound toM2DOWN.defm2upโ Default double-click release handler, usually bound toM2UP.defm2dragโ Default double-click drag handler, usually bound toM2DRAG. Selects a region of text a word at a time.defm3downโ Default triple-click handler, usually bound toM3DOWN.defm3upโ Default triple-click release handler, usually bound toM3UP.defm3dragโ Default triple-click drag handler, usually bound toM3DRAG. Selects a region of text a line at a time.defmiddledownโ Default middle click handler, usually bound toMIDDLEDOWN. This one inserts text.defmiddleupโ Default middle click release handler, usually bound toMIDDLEUP.xtmouseโ Handle xterm mouse events, usually bound toEsc [ M. It parses the rest of the sequence and generates fake "keys" that can be bound to macros in thejoercfile. It uses a timer to detect double-click and triple-click. The keys are:MUP,MDOWN,MDRAG,M2UP,M2DOWN,M2DRAG,M3UP,M3DOWN,M3DRAG,MWUPandMWDOWN.extmouseโ Handle extended xterm mouse events, usually bound toEsc [ <.pasteโ Insert base64 encoded text (for the XTerm--enable-base64option).brpasteโ Disable autoindent, wordwrap and spaces. The idea is to bind this toEsc [ 2 0 0 ~so that when the terminal emulator sends a mouse paste, the text is inserted as-is. ๐ซถbrpaste_doneโ Restore autoindent, wordwrap and spaces modes to their original values from beforebrpaste. The idea is to bind this toEsc [ 2 0 1 ~so that these modes get restored after a mouse paste.
and that's the whole command list, bestie โ you made it to the end ๐
That's a wrap on JMACS(1) ๐ โ this page comes from the JOE() source, dated March 2016, and honestly? Iconic. Go forth and bind some macros, you absolute main character. ๐โจ
๐ฆ where this page comes from
- fedora 43: joe 4.8-1.fc43 ยท GPL-2.0-or-later
- fedora 44: joe 4.8-1.fc44 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms