* * File: MACROS.TXT -- Miscellaneous useful macros for use with QEdit * * Last revised: 7-October-1993 * * To use these macros, select the ones you like, copy them to your keyboard * configuration file (QCONFIG.DAT), (editing the key assignment if need be) * and then run the configuration program (QCONFIG) to install the new key * assignments into your copy of QEdit. * * Most of these macros assume you are using QEdit 3.0 or greater. * (Or the equivalent QEdit TSR 3.0 or QEdit for OS/2 3.0 or greater). * * * Title: Fancy home macro. * * If already at the start of a line, go to the first non-white character * on the line; otherwise, if not already at the start of a line, go to the * start of the line. * Home MacroBegin BegLine JTrue done: FirstNonWhite done: * * Title: Block Cut with blank fill * * This does the same thing as Cut , but it fills the original block * with spaces. This is most useful with column blocks, when you don't want * the text "around" the block to "fill in" where the removed text was. The * macro assumes a block is already marked. The block will be [Cut] to the * clipboard or system scrap buffer. You can then insert the block where you * like by pressing the [Paste] key : * f10 MacroBegin GotoBlockBeg Cut Paste FillBlock ' ' Return UnmarkBlock * * Title: Find with Options prompt removed. * * The first one forces a forward case-insensitive search, the second backward. * f7 MacroBegin Find Pause Return 'i' Return #f7 MacroBegin Find Pause Return 'ib' Return * * Title: Find next occurence of the Word sitting at the cursor position * @= MacroBegin MarkWord Copy Find Paste Return Return * * Title: Find Word at cursor backwards * MacroBegin MarkWord Copy Find Paste Return 'bi' Return * * Title: "Safer" WriteBlock * * All the file prompts come up with a default of the last file loaded. * However, when using WriteBlock, accepting the default could overwrite * a file you have in the editor. Here's a macro to replace that * makes sure the prompt comes up blank, and that the Overwrite/Append always * comes up defaulted to Append no matter what. * @w MacroBegin CursorRight CursorLeft WriteBlock " " Backspace Pause Return EndLine PrevPosition * * Title: Delete to beginning of line * ^backspace MacroBegin begin: CursorLeft JFalse done: DelCh Jump begin: done: * * Title: Duplicate "n" Lines * * The built in DupLine function duplicates the current line, and moves the * cursor down onto the duplicate. This macro does the same thing for X lines * starting from the cursor line going "UP". It will stop and prompt for the * number of lines. Press ESCAPE twice at the prompt to abort. * @d MacroBegin UnmarkBlock MarkLine AddLine AddLine CursorUp RepeatCmd Pause Return MarkLine GotoBlockEnd CopyBlock GotoBlockEnd CursorDown DelLine DelLine CursorUp * * If "Insert line blocks ABOVE cursor line?" is set to YES, use this instead: * @d MacroBegin UnmarkBlock MarkLine AddLine AddLine CursorUp RepeatCmd Pause Return MarkLine GotoBlockEnd CursorDown CopyBlock GotoBlockEnd CursorDown DelLine DelLine CursorUp * * Title: Alternate Help File * * This allows you to have a help file much larger than one screen, by loading * it into QEdit into an editing buffer. * * Change the directory & filename here to the help or doc file that you use. * f1 MacroBegin EditFile 'c:\qedit\help.dat' Return * * Title: Load a file whose name is at the cursor * * This picks up a filename that is sitting at the cursor position in the * editor, and loads it into another buffer. * ^] MacroBegin AltWordSet MarkWord Copy EditFile Paste Return DefaultWordSet * * Title: Alternate WrapPara * * WrapPara assumes you have moved the cursor to the top of the paragraph * you wish to wrap. This macro removes this requirement by moving the * cursor there for you. This macro will re-wrap the current paragraph, no * matter where the cursor is currently sitting in it. * @b MacroBegin CursorDown PrevPara WrapPara NextPara * * Title: Wrap entire file * * WrapPara only affects the current paragraph. This macro repeats WrapPara * from the cursor position to the end of the file, reformatting the entire * file. NOTE: all paragraphs will be reformatted to the same margins, so * be sure this is what you want. * ^f10 MacroBegin EndFile AddLine BegFile BegLine again: WrapPara JTrue again: EndFile DelLine CursorUp * * Title: Absolutely Quit the Editor * * This key, when hit, will absolutely discard all files from the editor, * and exit to the DOS prompt, no questions asked. * * !WARNING!: Be careful with this one-- it will NOT prompt you to save your * work. You will lose all your work if you haven't saved it! * ^f12 MacroBegin again: Quit JTrue again: Escape * * Title: Delete redundant blank lines in entire file * * This macro deletes all blank lines that are adjacent to another blank line. * Useful for cleaning up files or screen captures that have too much excess * white space in them. * ^f11 MacroBegin findnext: EndPara CursorDown CursorDown JFalse end: blank: EndLine BegLine JTrue findnext: DelLine JTrue blank: end: * * Title: Worry-free Sort * * Sort only works if there is a single, non-zoomed window on the screen. * Well, rather than worry about that, how about have a macro take care of it: * #f3 MacroBegin GotoBlockBeg OneWindow Sort * * Title: Reload Current file * * QEdit normally never reloads a file from disk once in memory. But * sometimes the copy on disk might change while you are inside QEdit, and you * may want to see the new copy. (This could happen on a network, or if you * run a utility that can modify files, from inside QEdit using "Dos"). * * Hit this key, and no matter the state of the editing buffer, the * original copy of this file will be reloaded into the editor. This * will LOSE any and all changes you haven't saved, so BE CAREFUL! * ^f2 MacroBegin SplitLine EditFile CurrentFilename Return NewFile "N" Return * Here's a safer version: this one stops to let you answer the * "Save Changes?" prompt. You will have to hit RETURN to confirm the * reload of the file. * ^f3 MacroBegin EditFile CurrentFilename Return NewFile * * EZSpell by Sam Smith * (Tested with version 1.4) * * This macro invokes EZ-Spell to spell-check the current file. * * It is assumed that both EZS.EXE and the dictionary EZSPELL.DCT are in * a directory named in your PATH= statement. * * EZSpell creates a backup file with the last letter of the name changed * to a "$". We delete that file in this macro after EZSpell is done. * ^f9 MacroBegin SaveFile Dos "EZS " CurrentFilename Return Return Dos "DEL " CurrentFilename Backspace "$" Return Return EditFile CurrentFilename Return NewFile Return * * EZSpell: move to next marked word. This allows you to jump to words that * EZSpell marked for you in the current file. * * Since EZSpell marks words with square brackets, this will actually find any * pair of square brackets, and marks it as a block to highlight it. * ^f10 MacroBegin Find "[" Return "N" Return UnMarkBlock DropAnchor Match DropAnchor GotoBlockBeg MakeCtrOfScreen * * ShareSpell by Acropolis Software * (Tested with version 2.4. Version 2.0 or greater is recommended) * * This macro invokes ShareSpell to spell-check the current file. * * It is assumed that both SS.EXE and the dictionary ACROP.DIC are in * a directory named in your PATH= statement. * * There is no need to delete the backup file here, because SS stores it in * ".BAK" just like QEdit does. * ^f9 MacroBegin SaveFile Dos "SS " CurrentFilename Return Return EditFile CurrentFilename Return NewFile Return * * ShareSpell: move to next marked word. * * SS marks with an "@" ahead of each word. We search for that, mark the * word as a block to highlight it, and leave the cursor on the "@" so * the user can delete it. * ^f10 MacroBegin Find "@" Return "N" Return UnMarkBlock CursorRight MarkWord CursorLeft MakeCtrOfScreen * * Title: An Editing Log macro * * This macro allows you to keep a "log" of the files you have edited with * QEdit. This could be useful to keep track of large multi-file projects. * * It keeps the log in the file C:\Q.LOG. When you are "done" with a file, * hit this key and it will be saved to disk, and the time and date recorded * in the LOG file. This macro is very near the maximum line limit of * QCONFIG.DAT, so be careful when editing it. * ^f5 MacroBegin HorizontalWindow EditFile "C:\Q.LOG" Return EndFile AddLine BegLine InsertDate InsertTime " @" BegLine PrevWindow FindReplace "@" Return CurrentFilename Return Escape NextWindow FindReplace Return Return "N" Return SaveFile CloseWindow File * * Title: Run a Compiler Macro * * As written here, this macro will run the Turbo Pascal compiler (TPC) on the * current file, and bring the resulting error messages into a window below * the current one. Edit where it says "TPC /Q >ERRS.LST " to invoke whichever * language compiler you most often use. * #^f9 MacroBegin OneWindow UnmarkBlock DropAnchor EditFile 'ERRS.LST' Return KillFile Quit GotoBlockBeg UnmarkBlock Dos 'TPC /Q >ERRS.LST ' CurrentFilename Return Return HorizontalWindow EditFile Return PrevWindow ^f9 MacroBegin OneWindow UnmarkBlock DropAnchor EditFile 'ERRS.LST' Return KillFile Quit GotoBlockBeg UnmarkBlock Dos 'c /Q >ERRS.LST ' CurrentFilename Return Return HorizontalWindow EditFile Return PrevWindow * Title: Delete all blank lines in a marked block * * The cursor should be at the beginning of the block when the macro is * invoked. * #f9 MacroBegin SetScreenOff * turn off screen for speed begin: isCursorInBlock jFalse done: * exit if not in block isEmptyLine jFalse next: * skip if not empty line isLastLine jTrue last: * special handling for last line DelLine jump begin: * delete empty lines next: CursorDown jTrue begin: * try next line jump done: * last: DelLine * delete the last line done: * that's all, folks! * * Title: WordStar-like cursor left/right * * Left and Right cursor definitions that wrap to previous/next line * like WordStar does * cursorleft MacroBegin CursorLeft * try to go left MacroQuitTrue * succeed! then we are done CursorUp * else try to go to prev line MacroQuitFalse * if fail, then at top of file. done. EndLine * jump to end of previous line. cursorright MacroBegin isEndLine * are we at end of line? JTrue down: * if so goto down CursorRight * else right one MacroQuit * Quit macro down: CursorDown * try to go to next line MacroQuitFalse * if not goto end BegLine * else goto beginning of line * * Title: repeat GetPrev down * * A very useful QEdit command, GetPrev, copies a character from the line * immediately above the cursor line, onto the cursor line. Often it is * necessary to copy this character to several succeeding lines in the * same column. The GetPrev command, used in a macro, makes this * function easy. Assign this macro to the key (for example) in * QCONFIG.DAT as follows: * @4 MacroBegin GetPrev CursorLeft CursorDown * * Title: enhanced AddLine/DelLine * * QEdit's AddLine and DelLine commands do not change the cursor * position. Many would prefer that the cursor move to column one when * these commands are executed. A solution is to change the QCONFIG.DAT * file as follows: * * Default QCONFIG.DAT file: * * f2 AddLine * ^y DelLine * * Customized QCONFIG.DAT file: * f2 MacroBegin AddLine BegLine ^y MacroBegin DelLine BegLine * * Title: Enhanced Copy/Move block * * QEdit's CopyBlock and MoveBlock commands leave the copied or moved * Block marked. Many would prefer the Block to be unmarked. A solution * is to change the QCONFIG.DAT file as follows: * * Default QCONFIG.DAT file: * * @c CopyBlock * @m MoveBlock * * Customized QCONFIG.DAT file: * @c MacroBegin CopyBlock UnmarkBlock @m MacroBegin MoveBlock UnmarkBlock * Title: Alternate DropAnchor * * QEdit's DropAnchor command ends or extends a Block if executed after a * Block has been initially or entirely marked. Some editors have a * similar command, except that it acts as a toggle. That is, if you are * already marking a Block, and you press DropAnchor again, the Block is * unmarked and marking begins again at the current cursor position. To * implement this behavior, change the QCONFIG.DAT file as follows: * * Default QCONFIG.DAT file: * * @a DropAnchor * * Customized QCONFIG.DAT file: * @a MacroBegin UnmarkBlock DropAnchor * Title: Load sorted list of files in the current directory. * * This macro allows you to edit a sorted list of files of the current * directory. Assign this macro to the key (for example) in * QCONFIG.DAT as follows: * @5 MacroBegin Dos "dir *.* | sort>filedir.tmp" Return Return EditFile "filedir.tmp" Return DelLine DelLine DelLine DelLine * * Title: Transpose character * * macro to "twiddle" the character at the cursor, and the one to the right * of the cursor * f10 MacroBegin UnMarkBlock DropAnchor StoreScrBuff "%%%" return DelCh CursorRight GetScrBuff "%%%" return UnMarkBlock WordRight * * Title: PE2 like joinline * * Macro to make QEdit's joinline act line PE's joinline, e.g., force * QEdit's joinline to always concat the next line to the end of the * current line, regardless of the current cursor position. * Notes: Requires QEdit 2.1. * Must be on one line if processed by qconfig.exe. * Works better if "removing trailing spaces=yes" (our default) in qconfig.exe * @j MacroBegin CursorDown * force blank removal, and check for eof JFalse lastline * if at eof, we can get out now CursorUp * back to where we were CursorRight * force some movement that we can easily undo EndLine * JoinLine * concat the lines PrevPosition * back to where we were before the endline CursorLeft * and undo the cursorright lastline: * * Title: Copy line above to EOL * MacroBegin top: GetPrev JTrue top