You may be familiar with the text editors "Personal Editor" and "Personal Editor II" (PE2) from IBM for the original IBM personal computers. These older editors ran on DOS up through Windows XP within a command prompt window. The editors were very configurable, had many commands and useful functions but were limited to using 8.3 file names, limited memory and limited line length. I (Viktors Berstis) have been using PE2 for most of my editing and would miss its unique functions, switching to some other editor. So I set out to write this new version "Personal Editor 3" (PE3) from scratch using the Snobol5 language (another one of my projects). Snobol5 is written in assembly langauge, runs on Intel 64 bit Windows and 64 bit Linux. Thus PE3 would not have the prior limitations, yet it is highly compatible with PE2 and can run my many special command scripts. So this project lets me finally sunset my Windows XP machine! This is open source and in the public domain.
This is a text editor written from scratch using the Snobol5 language and does use two small C programs to interface with NCURSES (for Linux) and PDCURSES (for Windows). The source code for PE3 (and SNOBOL5) is available on snobol5.org. There is no warranty, no merchantability and no fitness for any purpose. PE3 runs on 64bit Intel Windows and Linux machines. The executable file for 64-bit Windows 7 and up is available here:
The editor is invoked specifying any number of files to edit at once:
In the simplest case, you can edit a file and when finished use the [file] command or F3 to write out the changes. Use the [quit] command or F4 if you want to discard your edits. Unlike some other editors, the enter key just moves you down to the beginning of the next line. This was the default in PE1 and PE2. The F10 key is used by default to insert new lines. If you would prefer to have the enter key start a new line, redefine the enter key function using the command:
The %TEMP% directory in Windows and /tmp directory in Linux receive a timestamped backup copy of the file(s) opened in case of any problem. Those directories also contain a timestamped "script.pe3..." file. The script file logs all commands executed in the edit session (unless backup is set to zero) and the script can be replayed against the original backup file using the macro command to achieve the same result. In case of any remaining editor bug, please find these files and save them as they will enable reproducing any bug so that it can be fixed. If something goes wrong, you can delete the last command in the script file and run it against the backup to recover your edit up to that point.
The editor keeps all information in memory. If the files being edited are large, you can specify a larger allocation when invoking pe3:
The initial screen has several areas as follows. The top blue section shows the data lines of the file. The green line underneath is where you can enter PE3 commands. The cursor can moved around using the arrow keys, PgUP and PgDn. The cursor can also be positioned using a single click of the mouse. The Escape (Esc) keyboard key toggles the the cursor between the data area and the green command line. Underneath the green command line the file name being edited is shown. If this name is white, then no changes have been made to the file. If the name is red, then some change has been made. Under the file name, messages from various commands may appear. In the illustration the locate command was looking for the string "junk" but there is a message that it was not found. In the lower right, there are several numbers and a word. The first two tell the coding of the character that the cursor is on. In this case 20 in hexadecimal or 32 in decimal is the ASCII blank character. The next number tells what line number the cursor is on. The next number tells which column number the cursor is on (columns and lines start with 1). After these it says "Insert" or "Replace" indicating if characters being typed replace those there previously or if the new characters are inserted pushing the remaining ones to the right. Finaly the word "Nesting" in red may or may not appear in the lower right. It tells if all parenthesis, brackets and quotes match properly on the cursor line. If there is a mismatch, the the word "Nesting" appears while the cursor is on that line. You can see a diagram of the nesting using the "nest" command, by default assigned to the Alt-n key. This nesting diagram is in red because it is a set of "marked" lines. You can delete the marked lines afterward using [delete mark] or (Alt-d). You can restore any previous mark using [pop mark] or (Ctrl-o). You can split the window (using [split screen} or Ctrl-s) into two or four panes, each of which can either edit different parts of the same file or different files. You can resize the window as needed.
Each of the keyboard keys has a name. A keyboard key can also have one or more commands assigned to it. The key "s-a" has the command ['A'] assigned to it so that when you press that key while holding the shift key, an "A" will appear. You can assign different commands to any key. The default assignments can be seen in the "pe3keys.pro" file. If you have a more exotic keyboard, you might get a message that some keyboard scan code (for example 1234) is not understood. You can give that key a key name and assign that code to that key, and give it a function using the commands:
You can enter a special character (byte) using shift-alt-nnn where nnn is 000 to 255, the decimal representation of the byte. For example, holding down shift and alt while typing 123 gives the left curly bracket character {. In the future I will add a command for this, something like: [char nnn].
By default, a mouse click will move the cursor to the point in the file or the green command line. Holding down the left mouse button and dragging will character mark a region of text. You can use alt-z to copy it somewhere or alt-d to delete it. Holding down the right mouse button and dragging will block mark a region of text. If you want to revert back to the operating system's mouse behavior, use the command:
Most commands are surrounded by square brackets [command name]. However many commands do not require them. Brackets are optional unless otherwise noted. Several commands may be given in sequence. For example [right][down]. Most commands have an alternative abbreviated name as noted. The command names can be given in either upper or lower case letters.
["string"] or ['string'] or "string" or 'string' Types the string of characters at the cursor position. Either quotes or apostrophes can be used to delimit the string of characters. This allows the quote or apostrophe to be in the string: "don't" or '"quote"'.
[backtab word] or [bw] Tab to prior word before the cursor position. See also the [tab word] and [begin word] commands. The short version of the command must have brackets [ ].
[backtab] or [bt] Tab to prior tab point before the cursor position. See the set [set tabs] command for more information. See also the [tab], [? tabs] and [set tabs..] commands. The short version of the command must have brackets [ ].
[begin line] or [bl] Moves the cursor to the start of the line. The short version of the command must have brackets [ ].
[begin mark] or [bm] Moves the cursor to start of the marked area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[begin word] or [wb] Moves the cursor to start of the word. The short version of the command must have brackets [ ].
[bottom edge] or [be] Moves the cursor to bottom edge of data display. The short version of the command must have brackets [ ].
[bottom] or [bo] Moves the cursor to last line in the file. The short version of the command must have brackets [ ].
[center in margins] or [ci] Centers the line text per the current margins setting. See also [reflow], [? margins] and [set margins..] commands. This command must have brackets [ ].
[center line] or [cl] Scrolls the data pane to put cursor's line in center of pane. This command must have brackets [ ].
[change/string1/string2/*-m] or [c/string1/string2/*-m] search for string1 and replace it with string2. * do all lines, - to search backward, m to only search in marked area. You can use other characters than the slash '/' as a delimiter when your strings need to contain a slash. By default the search is case independent, but you can change that with the [set searchcase] command. If you are not doing all lines with "*", then a confirmation of the change is required. Use the F6 key or [confirm change] command to confirm the change. Use the [set confirm] command to turn on or off the confirm requirement. By default, confirm is on. The variable "foundsw" is 1 if the prior [change], [snoc], [locate] or [snol] command found something, otherwise foundsw is zero 0. See the [test] and [putvar] commands. See also the [repeat change] command.
[clear marks] or [ck] Gets rid of all marked areas. See also the [mark line], [mark char] and [mark block] commands. This command must have brackets [ ].
[clear message] or [ce] Erases the red message. This command must have brackets [ ].
[column n] or [col n] Moves the cursor to column n. Columns start with 1. This command must have brackets [ ].
[command toggle] or [cg] Toggles the cursor between data pane and green command line. Note that on Linux, the Esc key assigned to this takes about a half second because the operating system uses this key as an alternative to the Alt key. You might want to switch the command toggle function to a different key. Alternatively, you can use the mouse to position the cursor. This command must have brackets [ ].
[confirm change] or [co] Confirm a change command action when not using *. If confirm is turned off, then no confirmation is required. See also the [change...], [set confirm] and [? confrim] commands. This command must have brackets [ ].
[copy from command] or [cf] Copies the command line area to a new line under the cursor. This command must have brackets [ ].
[copy mark] or [cm] Copies the marked area to cursor position. See also the [mark line], [mark char] and [mark block] commands. This command must have brackets [ ].
[copy to command] or [ct] Copies the data line the cursor is on to the command line. This command must have brackets [ ].
[cursor command] or [cc] Moves the cursor to the command line. This command must have brackets [ ].
[cursor data] or [ca] Moves the cursor to the data pane. This command must have brackets [ ].
[date] Writes the date/time at cursor location.
[define keyname = cmds] or [def keyname = cmds] or [d keyname=cmds] Programs the keyname to execute commands cmds when struck or executed with the [key ..] command.
[delete char] or [dc] Deletes the character at the cursor. The short version of the command must have brackets [ ].
[delete line] or [dl] Deletes the cursor line. The short version of the command must have brackets [ ].
[delete mark] or [dm] Deletes the marked area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[dir -path-]Shows the directory contents of path "-path-". This output is placed in the virtual file named '.dir'.
[down n] or [dn n] Moves the cursor down one or n lines. If n is ommitted, the move is just for one line. The short version of the command must have brackets [ ].
[edit filename] or [e filename] or [pe3 filename] Edits the file named filename opening it and reading it into memory. If filename is .keydefs, then it shows the command assignments to the keys. If filename is .unnamed, it shows the contents of the backup area. See the [set backup] command. If filename is .help, it shows the help contents generated with [helptext] commands. If no filename is specified, then the next file previously opened is edited. If "notabs" is specified after the file name, tab characters are not expanded into blanks. If "tabs" is specified after the file name, tab characters are expanded into blanks. If the filename has blanks in it, it should be enclosed in single or double quote characters.
[end line] or [el] Moves the cursor to the end of the line. The short version of the command must have brackets [ ].
[end mark] or [em] Moves the cursor to the end of the marked area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[end word] or [we] Moves the cursor to the end of a word. The short version of the command must have brackets [ ].
[erase begin line] or [eb] Erases the characters from the cursor to the start of line. This command must have brackets [ ].
[erase end line] or [ee] Erases the characters from cursor to end of the line. This command must have brackets [ ].
[execute] or [ex] Executes whatever command(s) are in the green command line area. The short version of the command must have brackets [ ].
[file] or [fl] Saves the file to disk and ends editing this file. If a filename is specified, it saves it using that file name. If the file name contains blank characters, then it must be in single or double quotes. If the file name is followed by "notabs" then blanks are not compressed to tab characters. If the file name is followed by "tabs" then blanks are compressed to tab characters. The short version of the command must have brackets [ ].
[fill mark] or [fm] Fills the marked area with the following character typed. See also the [mark block] command. The short version of the command must have brackets [ ].
[find blank line] or [fb] Finds the next blank line. The short version of the command must have brackets [ ].
[first nonblank] or [fn] Moves the cursor to the first non-blank on the line. The short version of the command must have brackets [ ].
[help] Shows help text that may have been defined using the [helptext] commands, perhaps in you profile. This uses an internal file named .help.
[helptext text] or [ht text] Adds a line to the end of help text (useful in profiles). This uses an internal file named .help.
[here keyname] Places commands in keyname to take one to the current cursor position and file. The keyname can be any key name or user defined keyname. Keynames can cotain alphabetic letters, digits and hyphens. To execute the program for a keyname use the [key keyname] command.
[indent] or [in] Moves the cursor to the paragraph margin or the left margin per the margin settings. The short version of the command must have brackets [ ].
[insert line] or [il] Insert a new line below cursor line. The short version of the command must have brackets [ ].
[insert mode] or [im] Change to insert mode (not replace mode) when typing.
[insert toggle] or [it] Toggles between insert and replace mode. The short version of the command must have brackets [ ].
[join] or [jo] Joins the cursor line with the next line. The short version of the command must have brackets [ ].
[key keyname] Executes commands defined for keyname. See also the [keydef] command.
[keydef keyname code] Assigs keyboard scan code to the key named keyname. Keyname can be any string of letters, digits or hyphens. This should only be needed if your keyboard has some unusual key assignemnts or capabilities. When you press one of your keys and get an error message about the keyboard code not being defined, use the number given in the error message as the code. It is best to put this command in your profile. Be careful when redefining existing keys or you might create some problems. If a code of zero is specified, the keyname just becomes another user defined virtual key to which you can assign commands with the [define] command. These user defined keynames can be invoked using the [key..] command. You can see all of the keynames and what commands are assigned to them by using the [edit .keydefs] command.
[left edge] or [le] Moves the cursor to left edge of data pane. This command must have brackets [ ].
[left margin] or [lg] Moves the cursor to the left margin per the margin settings. This command must have brackets [ ].
[left n] or [lf n] Moves the cursor left one (if n omitted) or n characters.
[line n] or [ln n] Moves cursor to line number n. The short version of the command must have brackets [ ].
[/searchstring] or [/searchstring/-m] Simplified [locate] command when the slash character is not part of your search string. The optional - searches backwards. The optional m searches only in the marked area. Note that the trailing slash can be left off.
[locate/string/m-] or [l/string/m-] Searches for the string. The optional m is for searching only in the marked area. The optional - is for searching toward the beginning of the file. The default is to be case insensitive, but that can be changed with the [set searchcase] command. The slash delimiters can be replaced with any other character in case your search string needs to contain a slash. The variable "foundsw" is 1 if the prior [change], [snoc], [locate] or [snol] command found something, otherwise foundsw is zero 0. See the [test] and [putvar] commands. See also the [repeat locate] command.
[lowercase] or [lc] Convert charcters in the marked area to lower case. See also the [mark line], [mark char] and [mark block] commands.
[macro filename] or [m] Executes commands in file filename (e.g. to set a new profile). Lines starting with an asterisk (*) are ignored.
[mark block] or [mb] Creates a rectangular block mark starting at the cursor position. Moving the cursor to another position and issuing the [mark block] command there defines the opposite corner of the marked area. Swiping the mouse with the right button can also create a block mark. See also the [mark line], [mark char], [copy mark], [move mark], [overlay block], [fill mark], [sum], [sort], [delete mark], [unmark], [clear marks], [push mark] and [pop mark] commands. The short version of the command must have brackets [ ].
[mark char] or [mc] Creates a character mark starting at the cursor position. Moving the cursor to another position and issuing the [mark char] command defines the end of the character mark. Swiping the mouse with the left button can also create a character mark. See also the [mark line], [mark char], [copy mark], [move mark], [fill mark], [delete mark], [unmark], [clear marks], [push mark] and [pop mark] commands. The short version of the command must have brackets [ ].
[mark line] or [ml] Creates a line mark starting cursor's line. Moving the cursor to another line and issuing the [mark line] command there defines the end of the line mark. See also the [mark line], [mark char], [copy mark], [move mark], [fill mark], [delete mark], [unmark], [clear marks], [push mark] and [pop mark] commands. The short version of the command must have brackets [ ].
[move mark] or [mm] Moves the marked area to the cursor position. The mark is removed. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[msg messagetext] Displays the message text in the message area at the bottom of the window pane.
[nest] Creates marked lines above current line showing nesting of parethese, brackets and quotes. This can be deleted with the [delete mark] command.
[name filename] or [nm] Changes the name that should be used when saving the current file.
[next view] or [nv] Moves to the cursor to the next data pane editing the same file in a clockwise direction. This applies when the [split screen] command has been issued. The short version of the command must have brackets [ ].
[next window] or [nw] Moves to cursor to the next data pane. This applies when the [split screen] command has been issued. The short version of the command must have brackets [ ].
[overlay block] or [ob] Overlay the marked block at the cursor position. This only works with block marks. See also the [mark block] commands. The short version of the command must have brackets [ ].
[page down] or [pd] Scrolls down one page. The short version of the command must have brackets [ ].
[page up] or [pu] Scrolls up one page. The short version of the command must have brackets [ ].
[paragraph margin] or [pg] Moves the cursor to paragraph margin setting. The short version of the command must have brackets [ ].
[pe3 filename] or [edit filename] or [e filename] Edits the file filename. If no filename is given, edits the next file previously opened.
[pop mark] or [po] Restore the previously pushed mark area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[push mark] or [ps] Save the current marked area on a stack, to allow a new mark to be made. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[putvar name] or [pv name] Types the value of variable name at the cursor position. The variable "foundsw" is 1 if the prior [change] or [locate] command found something, otherwise foundsw is zero 0. See also the [var] and [test] commands.
[quit] or [q] Quits editing the current file without saving changes you made. It will ask if you really want to not save the file. If the only remaining files are .help, .keydefrs, .unnamed or .temp, then those are not saved and the editor exits. If you want to save any of those to the disk, you need to do so before quitting some other file.
[repeat change] or [rc] Repeats the prior [change] command.
[reflow] or [rf] Reflows words per the margins setting. The short version of the command must have brackets [ ].
[replace mode] or [rm] Changes to replace mode (not insert mode). The short version of the command must have brackets [ ].
[right edge] or [re] Moves the cursor to right edge of data pane. This command must have brackets [ ].
[repeat locate] or [rl] Repeats the prior [locate] command.
[right margin] or [rg] Moves the cursor to right margin setting if the right margin is less than column 1000. This command must have brackets [ ].
[right n] or [rt n] Moves the cursor right n characters. If n is omitted, it moves right one character.
[rubout] or [ro] Deletes the character before cursor position. It deletes the character at cursor position if the cursor is in column 1. The short version of the command must have brackets [ ].
[snoc pattern = replacement]Searches for a line with that snobol5 pattern within a line marked area and if found replaces it with the replacement. Use only single letter variable names to stay out of trouble. Also be careful because some patterns can create infinite loops or crash PE3! As an example, to look for a double letter and convert it to upper case use:
[snol pattern]Searches for a line with that snobol5 pattern. Use only single letter variable names to stay out of trouble. Also be careful because some patterns can create infinite loops or crash PE3! As an example, to look for a double letter use:
[sv filename] or [save filename]Saves the file to disk. If a filename is specified, it saves it using that file name. If the file name contains blank characters, then it must be in single or double quotes. If the file name is followed by "notabs" then blanks are not compressed to tab characters. If the file name is followed by "tabs" then blanks are compressed to tab characters. See also the [set carriagereturn] command. The short version of the command must have brackets [ ].
[sort] Sorts the lines of the block mark according to marked content. The block mark defines what is used to sort. The lines are rearranged accordingly. Numeric or character values can be in the block mark. Characters will come before numbers. See also the [mark block] command.
[set abbrev on/off] or [s abbrev on/off] or [sta on/off] Sets command abbreviations on or off when using [?key] or [edit .keydefs]. See also the [define] command.
[set backup n] or [s backup n] or [stk n] Turns backup saving off if n=0. If n>0, creates backup files of files you edit in the temp directory (%TEMP% on Windows, /tmp on Linux). if n>0 saves prior states of lines from the last n edits in the .unnamed internal file. You can edit the .unnamed file to copy back original lines if you need to. If n=0, no lines are added to .unnamed and no commands are added to the script file in the temp directory.
[set blankcompress on/off] or [s blankcompress on/off] or [stb on/off] Sets whether blanks should be compressed to tabs on [save] or [file] commands.
[set carriagereturn on/off] or [s carriagereturn on/off] or [stc on/off] Sets whether carriage return characters should be included at the ends of line. Windows defaults to on while Linux defaults to off. See also the [? cr] command.
[set confirm on/off] or [s confirm on/off] or [stc on/off] Sets whether confirmation is required on [change] commands. See also the [? confirm] command.
[set hscroll on/off] or [s hscroll on/off] or [sth on/off] If hscroll is on, left/right pane scrolling is by single characters instead of by half pane.
[set margins l r p] or [s margins l r p] or [stm l r p] Sets the left margin to column l, right margin to column r, and paragraph margin to column p.
[set searchcase any/exact] or [s searchcase any/exact] or [sts any/exact] Sets whether to observe alpha character case on [locate] and [change] command searches.
[set tabexpand on/off] or [s tabexpand on/off] or [ste on/off] To expand tabs into blank when the [edit] command reads in the file.
[set tabs every n starting m] or [s tabs every n starting m] or [stt every n starting m] Sets tab points at column m and every n characters thereafter.
[set tabs n n n n n ...] or [s tabs n n n ...] or [stt n n n ...] Sets tab points at columns in the list.
[sum] Inserts a line containing the sum of the numbers in the block mark area. See also the [mark block] command.
[save] or [sv] Saves the current file to disk.
[scrolldown n] or [scd n] Scrolls the data pane down n lines. If n is omitted, then it scrolls down one line.
[scrollleft n] or [scl n] Scrolls the data pane left n characters. If n is omitted, then it scrolls one character left.
[scrollright n] or [scr n] Scrolls the data pane right n characters. If n is omitted, then it scrolls one character right.
[scrollup n ] or [scu n] Scrolls the data pane up n lines. If n is omitted, then it scrolls one line up.
[shift left] or [sl] Shifts text in marked area left one character. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[shift right] or [sr] Shifts text in marked area right one character. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[split screen] or [ss] Splits screen into 2 or 4 data panes to view different parts of the file or different files at once. Each execution of this command rotates through showing 2 vertical panes, 4 panes, 2 horizontal panes and 1 pane. See also the [zoom window], [next view] and [next window] commands. The short version of the command must have brackets [ ].
[split] or [sp] Splits the line into two lines at the cursor position.
[system command] or [dos command] Executes the given operating system command. In Windows, use "exit" to return to the editor. In Linux it immediately returns to the editor.
[tab word] or [tw] Moves the cursor to next word. See also the [backtab word] command. The short version of the command must have brackets [ ].
[tab] or [tb] Moves the cursor to next tab position. See also the [backtab] command. The short version of the command must have brackets [ ].
[test expr1 comp expr2 keyname] Compares the values of expressions expr1 and expr2 using comparison operator comp. If the comparison is true, then the program assigned to keyname is executed. The comparison operators can be any of: =, <, >, <=, >=, != or ~=. The last two are "not equal". The variable "foundsw" is 1 if the prior [change] or [locate] command found something, otherwise foundsw is zero 0. See also the [var] and [putvar] commands. This command must be enclosed with brackets [ ].
[top edge] or [te] Moves the cursor to top edge of data pane. The short version of the command must have brackets [ ].
[top] or [to] Moves the cursor to first line of the file. The short version of the command must have brackets [ ].
[undo] or [ud] Undoes changes on a line if you have not moved the cursor off of that line. The short version of the command must have brackets [ ].
[unmark] or [um] Removes the mark of an area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[uppercase] or [uc] Changes alphabetic letters to upper case in the marked area. See also the [mark line], [mark char] and [mark block] commands. The short version of the command must have brackets [ ].
[up n] Moves the cursor up n lines. If n is omitted, it moves the cursor up one line.
[var name=expr] Evaluates expression expr and assigned the value to variable name. The expression can contain integers, variable names, operators: +, -, *, /, and parenthesis as needed. See also the [test] and [putvar] commands. This command must be enclosed with brackets [ ].
[version] Shows the build time of this version of PE3.
[zoom window] or [zw] Makes the current data pane full window size closing any other panes. The short version of the command must have brackets [ ].
[? abbrev] or [?a] Shows command abbreviation setting. See also the [define], [?key] and [edit .keydefs] commands.
[? backup] or [?k] Shows backup setting.
[? carriagereturn] or [?cr] Shows the current carriage return character setting when writing ends of lines. See also [set carriagereturn] command.
[? key keyname] Shows the command(s) (if any) assigned to keyname. See also the [define] and [key..] commands.
[? blankcompress] or [?b] Shows the state of blankcompress for [file] and [save] commands.
[? char] or [?c] Shows the decimal character code of a character at the cursor position.
[? confirm] or [?f] Shows the current setting of confirmation required for [change] commands. See also [confirm] and [set confirm] commands.
[? hscroll] or [?h] Shows the hscroll setting.
[? margins] or [?m] Show the margin settings.
[? memory] or [?y] Show remaining unused memory in bytes.
[? searchcase] or [?s] Shows the search case setting.
[? tabexpand] or [?e] Shows the tabexpand setting when reading a file.
[? tabs] or [?t] Shows the tab points.