V I H E L P ################################################################################ SPF commands on left, VI commands on right. For SPF commands, equivalent TSO Edit keystroke commands denoted by <keyname>, TSO Edit command line options denoted by (=>commandname), TSO Edit line commands denoted by (commandname). -------------------------------------------------------------------------------- ******************************************************************************** SPF FILE COMMAND | VI FILE COMMANDS EQUIVALENT ******************************************************************************** edit a file | vi file edit file at last line | vi + file edit file at line number n | vi +n file edit file at first pattern | vi +/pattern file edit a second file | :e file2 or :edit file2 <F2 SPLIT> | :e +/pattern file2 | (edit second file at first line of "pattern") <F9 SWAP> | :e# or Ctrl-^ | (toggle between both files after writing; # is | the symbol for the alternate second file; % is | the symbol for the current file; when editing | more than one file, all currently saved option | and map settings, saved buffers, search | patterns, and last edit command (. or Ctrl-@) | are kept and transferred to the other files) edit multiple files | vi file1 file2 file3 | (use :n to go to the next file in the list or | use :e filename to go directly to the named | file; if using ':e', the ':args' will still | reflect the previous file edited; to return to | the previous file, use :e#) | vi prog* | (edit all filenames beginning with "prog") | vi `find . -type f -print` | (edit all files in the current directory and in | all its subdirectories) | vi `grep -l "pattern" *` | (edit all files in the current directory that | have "pattern" in its contents) | :n or :next | (move to next file; if autowrite is set, each | file is saved before moving to next file; if | autowrite is not set, need to :w first, or use | :n! to move to next file without saving the | changes to the current file) | :n file4 file5 | (edit a new set of files; the current file or | set of files is discarded from edit buffer) | :rew or :rewind | (reset file pointer to first file in list; use | :rew! to not save edits made to current file) | :ar or :args | (display the current set of files being edited) edit file after a system | vi -r crash (=>RECOVER ON) | (list the files the system saved after abort) | vi -r file | (edit buffer file recovered from edit abort) browse a file | view file or vi -R file | (read-only mode; or use more or pg commands; | you can also browse multiple files this way) save file and exit <F3 END> | ZZ or :x or :wq save current file (=>SAVE) | :w or :write save part of current file | :130,$w file2 | (save line 130 to end of file as "file2") | :'a,'bw file2 | (save from line marked with label "a" to line | marked with label "b" as "file2") | :/pattern1/,/pattern2/w! file2 | (save from line with "pattern1" to line with | "pattern2" to "file2"; w! overwrites "file2" | if it previously existed) append file to another file | :w >> file2 | (write current buffer contents to "file2") save current file under a | :w file2 a different filename | (save current "file" buffer as "file2"; the | original "file" is not saved until you :w it) | :w %.new | (save current "file" as "file.new") | :w new%.ver3 | (save current "file" as "newfile.ver3") rename filename without | :f newfilename or :file newfilename modifying original file | (ZZ saves "newfilename"; no change is made to | the original file prior to executing :f if you | did not :w save it) use vi to rename or delete | mvi *.dat files in a directory | (edit the names of all files ending in ".dat"; | upon exit from the /tmp file created, files | which were changed are renamed; any filenames | preceded with "D " are deleted) (=>CANCEL) the edit session | :q! do not save changes made | undo any changes made to | :e! file as of last save | ******************************************************************************** SPF CURSOR MOVEMENT COMMAND | VI MOVEMENT EQUIVALENTS ******************************************************************************** MOVE CURSOR BY CHARACTER | -------------------------------------------------------------------------------- left arrow key | h or left arrow key or Ctrl-H right arrow key | l or right arrow key or <space bar> up arrow key | k or up arrow key or Ctrl-P down arrow key | j or down arrow key or Ctrl-J or Ctrl-N <BackSpace> in input mode | <BackSpace> or Ctrl-H -------------------------------------------------------------------------------- MOVE CURSOR BY TEXT OBJECT | -------------------------------------------------------------------------------- <Return> (move to new line) | <Return> or j or down arrow key or Ctrl-M move forward one word | w or W (move to the start of the next word) <Alt><RightArrow> | e or E (move to the end of the next word) move backward one word | b or B (move to the start of previous word) <Alt><LeftArrow> | move backward one word | Ctrl-W (move backward over newly entered text during text input | on the current line to type over it) move backward to the start | Ctrl-U (move backward to the start of newly of the new entered text | entered text on the current line to during text input | type over it; if you press <escape> at | this point, all the text is deleted) move to beginning of next | ) (move to the start of the next sentence) or previous sentence | ( (move to the start of the previous sentence) | (a sentence is delimited by one or more empty | lines or .?! followed by at least 2 spaces) move to beginning of next | } (move to the start of the next paragraph) or previous paragraph | { (move to the start of the previous paragraph) | (a paragraph is delimited by an empty line or | by an nroff-troff paragraph macro) move to beginning of next | ]] (move to the start of the next section) or previous section | [[ (move to the start of the previous section) | (a section is delimited by nroff-troff section | macros or each "{" character in a C program) -------------------------------------------------------------------------------- MOVE CURSOR BY LINE | -------------------------------------------------------------------------------- move to start of line | 0 (move to the extreme left margin of the line) move to end of line | $ move to first of line | ^ (move to the first character on the line) | + (move to the first character of next line) | - (move to the first character of previous line) | n_ (move to first character (n-1) lines lower) <Tab> during text input | <Tab> (tabstops default to 8 spaces; use | :set tabstop=n to set tabs n spaces) | Ctrl-I or Ctrl-T (also tabs in input mode) back up one shiftwidth of | Ctrl-D (useful if shiftwidth is set to tabstop; tabs during text input | works only if autoindent is turned on) disable autoindent during | ^ Ctrl-D (start edit on column 1 in input mode, text input | but resume autoindent on next line) | 0 Ctrl-D (start edit on column 1 in input mode, | do not resume autoindent until a line is | manually indented again) go to last line (=>m <F8>) | G or :$ go to first line (=>m <F7>) | 1G go to line n (=>LOCATE n) | nG or :n (move to line number "n") go down n number of lines | nj or n<DownArrow> go up n number of lines | nk or n<UpArrow> move to the top of current | H screen <F12 CURSOR> | nH (move cursor to "n" lines below top line) move to the middle line of | M current screen | move to the last line of | L current screen | nL (move cursor to "n" lines above bottom line) mark cursor position with | mx (mark cursor position with an invisible mark, an invisible mark to use | where "x" is an alphabetic character a-z) as a line address for ex | `x (move cursor to the character marked by "x") commands (can be used to | 'x (move cursor to start of the line marked "x") move around quickly like | `` (return cursor to previous mark or context) using the SPF Edit xx | '' (return cursor to start of line of previous exclude command) | mark or context) -------------------------------------------------------------------------------- MOVE CURSOR BY COLUMN | -------------------------------------------------------------------------------- go to column n | n| (move to column "n" of current line) move n spaces to the right | nl or n<RightArrow> or n<space bar> move n spaces to the left | nh or n<LeftArrow> -------------------------------------------------------------------------------- MOVE CURSOR BY SCREEN | -------------------------------------------------------------------------------- scroll backward one full | Ctrl-B screen <F7 UP> | nCtrl-B (scroll backward "n" full screenfuls) scroll up one half-screen | Ctrl-U <F7 UP> HALF | nCtrl-U <F7 UP> n | (set scroll length to "n" lines and scroll up; | other Ctrl-U's will also scroll "n" lines) scroll forward one full | Ctrl-F screen <F8 DOWN> | nCtrl-F (scroll forward "n" full screenfuls) scroll down one half-screen | Ctrl-D <F8 DOWN> HALF | nCtrl-D <F8 DOWN> n | (set scroll length to "n" lines; scroll down) | other Ctrl-D's will also scroll "n" lines) scroll up 1 line | Ctrl-Y (leaves cursor where it is, if possible) scroll down 1 line | Ctrl-E (leaves cursor where it is, if possible) scroll screen <F7 F8> CSR | z <Return> (scroll current line to top screen) | z. (scroll current line to center of screen) | z- (scroll current line to bottom of screen) | /pattern/z or /pattern/. or /pattern/- | (search forward for "pattern" and place the | next occurrence of "pattern" on the top, | center, or bottom of the screen) -------------------------------------------------------------------------------- MOVE CURSOR BY FINDING TEXT | -------------------------------------------------------------------------------- find a pattern (=>FIND) | /pattern (search forward for "pattern") | ?pattern (search backward for "pattern") find a word | /\<word\> | (search forward for "word", omitting any "word" | that is an embedded pattern of another word) | ?\<[Kk][^ <tab>]*[aeiouAEIOU]\> | (search backward for any word that begins with | "K" or "k" and ends in a vowel) repeat find (rFIND <F5>) | n (repeat find in the same direction) | N (repeat find in the opposite direction) find a pattern only if it | /pattern1/;/pattern2/;/pattern3/ occurs after some other | (find "pattern3" only if it follows after patterns | "pattern1" and "pattern2"; the search fails if | either "pattern2" occurs before "pattern1" or | "pattern3" is before "pattern1" or "pattern2") find a character on the | fc (search forward for character "c") current line | nfc (search forward for "n"th occurrence of "c") | Fc (search backward for character "c") | nFc (search backard for "n"th occurrence of "c") | tc (search forward for the character before "c") | Tc (search backward for the character after "c") repeat character find | ; (repeat find in same direction as last find) | , (repeat find in the opposite direction) find the matching bracket | % (if cursor is placed on an open bracket (, [, in program code | {, <, press % to move cursor to the matching | closing bracket ), ], }, >; likewise, if | cursor is placed on closing bracket, % will | move backward to its matching open bracket) display lines containing a | :g/pattern/p pattern | (display all lines having a given "pattern"; | similar to using grep) | :g!/pattern/nu or :v/pattern/nu | (display all lines not having given "pattern" | along with their line numbers) | :v/^[A-Za-z0-9]/p | (display all lines that do not begin with an | alphanumeric character) ******************************************************************************** SPF EDIT LINE COMMANDS | VI EDIT EQUIVALENTS ******************************************************************************** INSERT TEXT | -------------------------------------------------------------------------------- insert text <insert> | i (insert text before cursor) | ni (duplicate "n" copies of what is inserted) | a (append text after cursor) | na (duplicate "n" copies of what is appended) insert at start of line | I (insert text at beginning of line) insert at end of line | A (append text at ending of line) insert new line (I) | o (open a new line below the current line) | O (open a new line above the current line) text split (TS) | i <Return> <escape> insert non-printing control | Ctrl-V characters into the file | (quote the next non-printing character into the | file; quoting a newline <Return> prints out a | ^M, quoting <escape> prints ^[, etc; to quote | Ctrl-V itself, press Ctrl-V twice to get ^V) return to vi command mode | Esc <F11> or Ctrl-[ -------------------------------------------------------------------------------- CHANGE TEXT | -------------------------------------------------------------------------------- replace text <overlay> | R (type over existing text starting at cursor) | nR (insert "n" copies of text that is input) replace a character | r (replace the character the cursor is on; this | command leaves you in command mode) | nr (overlay n copies of replacement character) change a word | cw (change a word starting at cursor) | ncw (change "n" words starting at cursor) change to end of line | C (change text from cursor to end of line) change to start of line | c0 (change text from cursor to start of line) change to end of sentence | c) (c( changes to start of sentence) change a range of columns | cn| (change from cursor to column "n") change to character on line | cf? (change from cursor to next "?" on line) change to pattern of text | c/pattern (change all text from cursor to next | occurrence of text "pattern") | c?pattern (change text from cursor to previous | occurrence of text "pattern") change a line | cc (replace current line with a blank line) | S (same as cc; blanks out the current line) change n lines | ncc (change "n" consecutive lines) change to end of file | cG (change from current line to end of file) change to start of file | c1G (change from current line to first line) substitute a character | s (replace a character with new text) substitute n characters | ns (replace "n" characters with new text) change txt1 txt2 | :s/txt1/txt2 (=>CHANGE txt1 txt2) | (change the first "txt1" on the line to "txt2") | :s/txt1/txt2/g | (change all "txt1" on the line to "txt2") | :6,15s/txt1/txt2 | (change the first "txt1" on lines 6 to 15) | :%s/pattern1.*pattern2/txt/g | (change a pattern of text that begins with | "pattern1" and ends with "pattern2" to "txt") repeat change | n & (n moves cursor to next occurrence of text; (rCHANGE <F6>) | & changes next occurrence of text) change all txt1 txt2 | :%s/txt1/txt2/g (=>CHANGE ALL txt1 txt2) | (change all "txt1" in the file to "txt2") | :%s/txt1/txt2/gc | (confirm each change by entering "y" at the | ^^^ prompt; enter "n" or just press <Return> | to negate; Ctrl-C cancels further changes) | :g/txt/s/old/new/g | (globally change all "old" to "new" only on all | lines where a pattern "txt" occurs) | :g!/txt/s/old/new/g or :v/txt/s/old/new/g | (globally change all "old" to "new" only on all | lines where pattern "txt" does not occur) metacharacters for patterns | . (match any single character except newline) when used in searches | * (match zero or more of preceding character) (wildcard characters) | .* (match any number of any characters) | ^txt (match "txt" only at the start of line) | txt$ (match "txt" only at the end of line) | \ (escape the meaning of the special command | character that follows it such as | . * ^ $ / \ ~) | [ ] (match any one of the characters enclosed by | the brackets; e.g., [A9] matches A or 9, | [A-Z] matches A to Z, [;:0-9&] matches ; : & | and the numbers 0-9, ^[aeiou] matches any | lowercase vowel at the start of a line, | [^aeiou] matches any character that is not a | lowercase vowel; to match \ - or ] within | brackets, escape their meaning by specifying | \\ \- or \] ) | \( (save patterns enclosed by \( \) in up to 9 | \) buffers; the buffers may be recalled as part | of the replacement text by specifying \1 to | \9; :%s/\([0-9.]*\) *\([0-9.]*\)/\2 \1/ | transposes two fields in a numeric database | composed of only numbers and decimals (.)) | \< (match characters at the start of a word; | e.g., \<un matches words starting with un) | \> (match characters at the end of a word; e.g., | \>es matches words ending with es) | ~ (match whatever was last used as a search | pattern; if last search was on "XGrabKey", | /~board will search for "XGrabKeyboard"; | does not work as a pattern in substitute | command and may not work on some machines) metacharacters for patterns | \ (escape the meaning of the special command when used in replacement | character that follows such as . or *) (wildcard characters) | \n (where n is 0 to 9, replace \n with the | corresponding \( \) delimited search | pattern; set above \( \) example) | & (replace & with whatever was used as the | search pattern; e.g., :%s/In/& fact/g will | replace all "In" with "In fact") | \u (change next character in replacement to be | uppercase; \U changes every character that | follows it in the replacement string to be | uppercase unless separated by \e or \E) | \l (change next character in replacement to be | lowercase; \L changes every character that | follows it in the replacement string to be | lowercase unless separated by \e or \E) | ~ (replace the search pattern with whatever | was last used as a replacement pattern; if | :s/XGrabKeyboard/XGrabButton/ was executed | on a line, the next substitution command of | :s/XGrabPointer/~/ changes "XGrabPointer" | also to "XGrabButton") change the case of a letter | ~ (toggles between upper and lower case) invert the case of a word | ywmno<Esc>P:s/[^ ]/\~/g<Return>0"nDdd`n@n | (ywmno yanks a word, marking its place "n"; | P:s/[^ ]/\~/g puts word on next line, converts | to lowercase; 0"nDdd deletes the tilde'd | characters to buffer "n" and deletes line; | line; `n@n moves back to original word and | executes "n" buffer; above command changes | "AbC" to "aBc"; to include punctuation, use | yWmno, "Ab.CDE" changes to "aB.cde"; or keep | the "~" key held down over the word) invert the case of a line | !!tr '[a-z][A-Z]' '[A-Z][a-z]' | :s/\([a-z]*\)\([A-Z]*\)/\U\1\L\2/g | (either the tr or substitution will work) change words to uppercase | :%s/.*/\U&/ (change entire file to uppercase) (=>UPCASE ALL) | :/do:/,/end:go/s/.*/\U&/ | (change all text between the first occurrence | of a line having "do:" through the next line | having text pattern "end:go" to uppercase) | :?^$?,'bs/otherwise/\u&/g | (change every occurrence of "otherwise" from | the previous empty line through the line | marked "b" to "Otherwise") change words to lowercase | :%s/.*/\L&/ (change entire file to lowercase) (=>LOWCASE ALL) | :3,8s/IN EXAMPLE/\L&\e NUMBER/g | (change all "IN EXAMPLE" patterns in lines 3 | through 8 to "in example NUMBER") | :,'bs/Ex/\l&/g | (change every occurrence of "Ex" from the | current line to the line marked "b" to "ex") -------------------------------------------------------------------------------- DELETE / MOVE TEXT | -------------------------------------------------------------------------------- delete a character | x (delete character at cursor) <delete> | X (delete character before cursor) delete n characters | nx (delete "n" characters after cursor) | nX (delete "n" characters before cursor) delete a word <Alt><delete> | dw (delete a word starting at cursor) | ndw (delete "n" words starting at cursor) delete to end of line | D (delete from cursor to end of line) delete to start of line | d0 (delete from cursor to start of line) delete to end of sentence | d) (d( deletes to start of sentence) delete a range of columns | dn| (delete from cursor to column "n") delete a line (D) | dd (delete current line) block delete n lines (DD) | ndd (delete "n" consecutive lines; e.g., 4dd is | the same as D4 in SPF Edit) | d'a (delete from current line to line marked | with label "a") | :/-/d (delete the next line with a "-" in it) delete to end of file | dG (delete from current line to end of file) delete to start of file | d1G (delete from current line to first line) delete to character on line | df? (delete from cursor to next "?" on line) delete to a pattern of text | d/pattern | (delete text from cursor to next occurrence of | "pattern") | d?pattern | (delete text from cursor to previous occurrence | of "pattern") | :%s/pattern1.*pattern2//g | (delete a pattern of text that begins with | "pattern1" and ends with "pattern2") | if "/txt/" is "//", this becomes a delete) move a line (M) | dd (p or P) | (dd deletes a line; p pastes the deleted line | below cursor, P pastes the text above the | cursor; unless you delete to a named buffer, | (see below), you must use p/P to immediately | put the text back to another spot before doing | another dd or yy/Y move or copy) | :m$ | (move current line to end of file) block move n lines (MM) | ndd (p or P) | (ndd deletes "n" consecutive lines; p pastes | deleted lines below cursor, P pastes the text | above the cursor; e.g., 4dd p is the same as | M4 in SPF Edit) | :'a,'bm. | (move from line marked "a" to line marked "b" | after the current line) delete to buffer | "andd (cut to a named buffer) | ("a" is one of 26 buffers named a-z; "n" is the | number of lines to delete, default of 1 line) | "Andd | (delete "n" lines; append it to the contents of | buffer "a") paste deleted text from a | "ap or "aP named buffer | (put the contents of buffer "a" after or before | the current line) paste from a delete buffer | "np or "nP (restored deleted text) | ("n" is buffer number 1-9 storing the past 9 | deletions; last delete is saved in buffer 1; | only works for deleted lines, not deleted | words or parts of lines) | "1pu.u.u.u.u.u.u.u.u | (step through the contents of all 9 delete | buffers; useful if you accidentally deleted | something recently that you want to get back; | the "u" undoes each delete buffer restoration; | the "." puts the contents of another one of | the delete buffers below the current line) transpose two characters | xp (swap character with following character) transpose two words | dwwP (swap word beginning at cursor with word | that follows) transpose two lines | ddp (swap position of current line with line | that follows) delete lines having pattern | :g/pattern/d | (delete all lines in file with "pattern") | :g!/pattern/d or :v/pattern/d | (delete all lines in file without "pattern") | :/pattern1/,/pattern2/d | (delete from first line having "pattern1" to | first line having "pattern2") move lines having a pattern | :g/pattern/mo$ | (move all lines with "pattern" to end of file) delete columns of text | :%!colrm f l (=>C ALL P'=' '' f l) | (delete all text in columns "f" through "l") | :'a,.!colrm f l | (delete all text in columns "f" to "l" from the | line marked "a" to the current line) | :2,10!colrm 1 4 | (delete all text in columns 1 to 4 for lines 2 | to 10; note this can be use to shift text to | the left instead of the << command) blank out columns of text | :.,$!column f l (=>C ALL P'=' ' ' f l) | (from the current line to the end of file, | blank out columns "f" to "l" with spaces) | :'a,'b!column 20 | (from line marked "a" to line "b", fill columns | 20 to end of line with blank spaces) | :%!column 34 55 - | (for every line in the file, fill columns 34 to | 55 with the character "-") overlay text onto other | :.!yo lines of text (C OO) | (yank the current line of text to buffer for | subsequent overlay onto other text using po) | :16,26!po | (overlay a line of yo-yanked text onto lines 16 | through 26) | :'a,.!po or !'a po | (overlay a line of yo-yanked text onto lines | starting from the line marked with label "a" | through the current line) -------------------------------------------------------------------------------- COPY TEXT | -------------------------------------------------------------------------------- copy a file (=>COPY file) | :r file or :read file | (copy contents of "file" after current line) | :r !sed -n 50,75p file | (copy lines 50 through 75 of "file" after the | current line; an equivalent command using awk | is :r !awk 'NR >= 50 && NR <= 75' file ) | :r !sed -n "/pattern1/,/pattern2/p" file | (copy after the current line all text in "file" | that is between an occurrence of "pattern1" | and an occurrence of "pattern2") copy a file contents after | :g/pattern/r file every pattern occurrence | (:g searches every line of file for "pattern") copy a Unix command output | :g/pattern/r !Unixcommand after every pattern | (:g searches every line of file for "pattern") copy Unix command output | :r !Unixcommand into the current file | (copy Unix command output after current line) copy n numbers of words | nyw (p or P) | (copy "n" number of words starting at cursor | and put after or before the cursor) copy to end of line | y$ (p or P) | (copy text from cursor to end of line and put | below or above the cursor) copy to start of line | y0 (p or P) | (copy text from cursor to start of line and put | below or above the cursor) copy to end of sentence | c) (p or P) | (y( copies to start of sentence) copy a range of columns | yn| (p or P) | (copy from cursor to column "n" and put after | or before the cursor) copy a line (C) | yy or Y (p or P) | (yy or Y yanks a line; p or P puts the yanked | line below or above the cursor; unless you | yank to a named buffer (see below), you must | use p/P to immediately put the text back to | another spot before doing another dd or yy/Y | move or copy) block copy n lines (CC) | nyy or nY (p or P) | (yank "n" consecutive lines; p or P pastes | yanked lines; e.g., 4yy is same as C4 in SPF | Edit) | y'a (p or P) | (yank from current line to line marked with | label "a"; p or P pastes the yanked text) | :'a,'by (p or P) | (yank from line marked "a" to line "b") | :'a,'bco. | (copy from line marked "a" to line marked "b" | after the current line) repeat a line (R) | yy (p or P) | (yank line and paste back below or above | current line) repeat a line n times (Rn) | :1,ng/^/'aco'a | (to repeat a line "n" number of times, you can | either yy yank and then use p "n" number of | times; or you can mark the line as "a", and | the :1,ng/^/'aco'a will duplicate "n" copies | of that line; e.g., :1,34g/^/'aco'a will add | 34 more copies of the line marked "a"; "n" | must be no greater than the number of lines in | the file) repeat a text block (RR) | :'a,'bco'b | (repeat the block of text marked by "a" on the | first line and "b" on the last line; the | repeated block will be placed beneath the | original text block; or use yy/p yank/put) (RRn) | :1,ng/^/'a,'bco'b | (repeath the block of text marked by "a" on the | first line and "b" on the last line "n" number | of times; "n" copies of the repeated text | block will be appended below the original text | block; "n" must be no greater than the number | of lines in the file) yank to buffer (=>COPY1) | "anyy or "anY (copy to a named buffer) | ("a" is one of 26 buffers named a-z; "n" is | number of lines to yank, default of 1 line) | "Anyy or "AnY | (yank "n" lines; append it to the contents of | buffer "a") paste yanked text from a | "ap or "aP named buffer (=>COPY1) | (put the contents of buffer "a" after or before | the current line) yank lines having pattern | :g/pattern/y a | (yank all lines having "pattern" and store in | buffer "a") | :g/pattern/y A | (yank all lines having "pattern" and append to | buffer "a") store an ex command that is | "add @a or "ayy @a often used into a buffer | ("add deletes a line containing a vi or ex and execute the buffer | command sequence and stores it in buffer "a" whenever the command is | (or a-to-z); @a executes the stored command needed | whenever it is entered in command mode; can | restore the delete buffer with "ap if it needs | to be modified; when using "ayy, enter command | on the last line and use 1,$-1 as the line | address in order to avoid running the command | on itself; an @-command may not be more than | 512 characters long) | :*a (equivalent ex execution of buffer "a") repeat the last @ command | @@ -------------------------------------------------------------------------------- REFORMAT TEXT | -------------------------------------------------------------------------------- concatenate lines of text | J (join next line to end of current line) | nJ (join "n" consecutive lines into one line) | :j n or :join n | (join "n" consecutive lines into one line) | :j! n or :join! n | (like :j, but whitespace is not eliminated) text flow (TFnn) | !a}fmt -nn | (where "a" is number of paragraphs to block; | "nn" is maximum allowed line length; block | only a few paragraphs at a time for safety) justify and block text | :%!format -b -w72 | (format all lines so that they are both left | and right justified and 72-columns wide) | :'a,'b!format -i4 -w68 -l | (format the text between the lines marked "a" | and "b" so that they are 68-columns wide, | indented 4 spaces (for a right margin of 72 | columns), and left justified) | :1,7!format -c -w80 | (format lines 1 to 7 so they are centered | within 80-column wide lines) | :%!perl -pe 'print " " x int((81-length())/2)' | (center every line down the middle between | columns 1 and 80) | :,8!perl -pe 'print " " x int((73-length())/2)' | (center from the current line to line 8 down the | middle between between columns 1 and 72) shift lines left/right | << >> (defaults to 8 spaces per shift; use ( or ) | :set shiftwidth=n to shift line n spaces) | . (repeat previous << or >> shift) block shift n lines | n<< n>> (shift n consecutive lines by either the (( or )) | default 8 spaces or shiftwidth value) | . (repeat previous << or >> shift) | >'a (shift current line through line marked | with label "a" to the right) | :8,12s/^/ /g | (shift lines 8 to 12 to left 3 spaces) insert a empty line between | :%s/$/Ctrl-V<Return>/ every line of text | (combination of Ctrl-V and <Return> generates | the characters "^M" on the substitution line) split text up so that a new | :%s/Example -/Example -Ctrl-V<Return>/g line is created every | (combination of Ctrl-V and <Return> generates time a specific word | the characters "^M" on the substitution line; occurs | the text will be split after every occurrence | of "Example -") split text up so that each | :%s/[<space><Tab>][<space><Tab>]*/Ctrl-V<Return>/g line has only one word | (for all lines, substitute any tabs or blanks left-justified at the | for newline breaks; if you know that no tabs extreme left margin | exist in the file, a simpler command that will | work is... | Q :%s/ */Ctrl-V<Return>/g delete all leading spaces | :%s/^ *\(.*\)/\1/ on every line in the | (^ * searches for one or more spaces at the file (=>CRUNCH) | start of line; \(.*\)/\1 restores the rest of | line with leading spaces; can use to prepare | text for embedding of nroff-troff commands) delete spaces and tabs at | :%s/[<space><Tab>]*$// ends of lines and on | (remove blanks or tabs at the end of all lines; blank lines (helps save | blank lines having invisible blanks or tabs some disk space) | are also trimmed) delete all blank lines | :g/^$/d or :v/./d | (delete all blank lines which are empty) | :g/^[ <Tab>]*$/d | (delete all blank or white-space-only lines) change multiple blank lines | :%s/[<space><Tab>]*$// to single blank lines | :%!cat -s | (the substitution first compresses blank lines | having spaces to empty lines, cat command then | squeezes out all multiple blank lines) convert a single column of | !}pr -4t text into 4-column table | (if needed, use !}expand -8 to align columns) switch columns of data in a | :'a,'b!awk '{print $2" "$1" "$3" "$5" "$4}' column-oriented database | (move 2nd field of data as the 1st column of | data so that the 1st field is now the 2nd one, | swap the 4th and 5th fields; assumes 5 fields, | each separated by blanks) reverse the order of lines | :g/^/mo0 in a file (=>FLIP) | sort the lines in a file | :%!sort (sort the file in ascending order) | :%!sort -r (sort the file in descending order) | :'a,'b!sort +2 | (sort the 3rd field only between the lines | marked a and b) add line numbers to the end | 1G of each line | !Gawk '{printf "\%s\%8d\n", $0, NR}' | (1G first moves to the start of file; the awk | command then adds line numbers to the end of | each line; if spacing of the numbers is not | okay, "u" undo, and execute the command again | using some spacing other than "%8") transpose matrix of values | :%!transpose | (transpose the entire file contents (assumed to | be a matrix of values); a 8x5 matrix becomes a | 5x8 matrix) translate characters to | :%!tr A-Za-z N-ZA-Mn-za-m other characters | (encrypts all lines to ROT13 format) | :%!tr N-ZA-Mn-za-m A-Za-z | (translates all lines with ROT13 encryption) regularize the spacing and | :%s/\([.?!]\) *\([a-zA-Z0-9]\)/\1 \U\2/g case of sentences | (change any . ? ! punctuation followed by at | least one space followed by an alphanumeric | character to a uniform two spaces between | sentences, capitalizing any lowercase letter | that begins a sentence; this, however, will | not capitalize letters at the start of a line | that should be capitalized) | :%s/\([^.?!]\) *\([^.?!]\)/\1 \2/g | (change the spacing between any character that | is not a . ? ! punctuation and any non[.?!] | character to a uniform one space separation) run spelling checker on | :w (save file first) the file | :$r !spell % (append mispelled words at bottom) ******************************************************************************** COMMANDS FOR PROCESSING | VI EDIT EQUIVALENTS ******************************************************************************** comment DSS processing step | :'a,'bs/^/CC/ | (insert the DSS comment symbol "CC" at the | front of lines marked "a" through "b"; similar | to the SPF COMMENT macro) | :'a,'bs/^CC// | (uncomment the commented DSS lines marked "a" | through "b") comment CHESS text | :'a,s/^/! / | (insert "! " in front of lines marked "a" to | the current line for commenting CHESS code) | :9,18s/^! // | (uncomment CHESS lines 9 through 18) comment lines of IBM JCL | :,$s/^/\/\/\* / | (insert a "//* " in front of the current line | through the last line to comment IBM JCL) | :/&END/+1,/EXEC DUMP/s/^\/\/\* // | (uncomment previously commented lines of IBM | JCL starting from the line after the next | occurrence of "&END" through next occurrence | of "EXEC DUMP") comment lines of CRAY JCL | :.,.+5s/^/# / | (insert a "# " in front of the current line to | 5 lines after the current line to comment out | CRAY JCL) | :1,'bs/^# // | (uncomment previously commented lines of CRAY | JCL from lines 1 to the line marked as "b") ******************************************************************************** SPF EDIT KEYS AND COMMANDS | VI OR EX COMMAND EQUIVALENTS ******************************************************************************** repeat the last edit/insert | . command (RETRIEVE) | (repeat the last modification command issued; | command may be o/O, d, c, i, a, etc) | 4. (repeat the last modification command 4 times) | Ctrl-@ | (when executed in input mode, will repeat the | text that was last inserted if input as the | first character of the new insertion; returns | back to command mode; only 128 characters are | saved from previous insert; will not work if | more than 128 characters were last input) <reset> | escape key (usually <F11>) | (in input mode, returns from input mode back | to command mode; in command mode, cancels a | partially formed command, such as "z" or "d", | when no followup character has been given) <delete> | x display current line number | :.= display the total number of | := lines in the file | :/pattern/= | (show line number of first line with "pattern") display filename, current | Ctrl-G or :f line number, total lines | undo previous change | u (undo last change made) (=>UNDO) | U (undo all changes made to a line; cursor must | not have moved off of that line) | :e! (undo all changes to file since last save) cancel a current partially | Ctrl-U <Backspace> typed ex/search command | screen refresh <Dup PA1> | Ctrl-L or Ctrl-R | (refresh the current screen; useful if mail | message changes screen during edit session) quit vi, invoke ex | Q quit ex, return back to vi | :vi run command (=>TSO COMMAND) | :!Unixcommand | (when running commands using :!, some special | characters may need to be preceded with \ to | escape its normal csh meaning, including... | ! & | % + - * ? / ^ > < ( ) && || << >> # ; $) | :!! (execute most recent shell escape command) filter text through a Unix | :.!Unixcommand command as standard | (filter current line through a Unix command; input, replacing the | current line is replaced by command output) text with the command's | !!Unixcommand standard output | (filter the current line through Unix command | and replace with it with the command output; | may want to open up a new line first to insert | the output of the Unix command) | n!!Unixcommand | (filter "n" consecutive lines starting with | the current line through a Unix command; the | "n" lines are replaced with command output) | !}Unixcommand | (filter a paragraph of text through a Unix | command; general form is !(times)(textblock) | where "times" is number of "textblocks" to | process and "textblock" may be {} () [[ ]] + | - or G) | :'a,'b!Unixcommand1 | Unixcommand2 | Unixcommand3 | (filter a block of text from the line marked | "a" through the line marked "b" through three | different Unix commands; the text block will | be replaced with the output from command3) send file contents to the | :w ! Unixcommand standard input of a Unix | (can input the contents of a file to a shell, command | awk, sed, C program) define a string as an | :ab string replacement text abbreviation to be | (abbreviate "replacement text" as "string"; translated to other text | "replacement text" cannot end with "string") | :una string | (cancel "string" as an abbreviated text string) change working directory | :cd directorypath | (change the current working directory that vi | will write to using :w or read from with :e) copy lines using ex | :co or :copy or :t | (address)co(destination) | :.,.+4co28 (copy current line through 4th line | after current line after line 28) | :'a+2,$-4t. (copy 2nd line after line marked as | "a" through 4th line before the last | line in the file after current line) | :%co$ (copy entire buffer file after last | line of file; equivalent to Unix | command "cat file >> file") delete lines using ex | :d or :delete | (address)d(bufferletter) | :d b 4 (delete 4 consecutive lines and store in | buffer b) | :'a,'bd (delete all lines between the line | marked "a" to the line marked as "b") | :%d (delete all the lines in a file) map a key to commands to be | :map <k> replacementcommand executed in command mode | (map key <k> to commands in command mode; | "replacementcommand" cannot use "k" in its | definition and be more than 100 characters) | :unmap <k> or :unm <k> | (cancel key <k> that was previously mapped) map a key to commands to be | :map! <k> replacementcommand executed in input mode | (map key <k> to commands in input mode; | "replacementcommand" cannot use "k" in its | definition and be more than 100 characters) | :unmap! <k> or :unm! <k> | (cancel key <k> that was previously mapped) mark the current line with | :ma x or :mark x or :k x an letter label | (assign marker "x" (single lowercase letter) to | a specific line to use as command address; go | to this line using `x or 'x) move lines using ex | :m or :move | (address)m(destination) | (same as copy with delete or delete with put) | :m 'a (move current line to line marked a) | :2 m 15 (move line 2 to below line 15) | :.,.+4m0 (move current line through 4th line | after current line to top of file) preserve current buffer in | :pre or :preserve case of write error | (use "vi -r filename" to recover later on) display lines using ex | :p or :P or :print | (address)p(count) restore previously deleted | :pu or :put or yanked text | (address)pu(buffername) | (if (buffername) is deleted, the last deleted | or yanked text is restored) recover file from system | :rec or :recover save area after a system | (use after system crash or after using :pre; crash or edit abort | equivalent to starting vi with "vi -r file") create a new shell from vi | :!sh or :!csh or :!ksh | exit or Ctrl-D (to terminate shell and resume | editing the current file) exit from vi to the current | Ctrl-Z or :stop (fg) shell | (temporarily suspend vi and return to the Unix | prompt of current shell; enter "fg" at Unix | prompt to resume the vi session; if autowrite | is set and file has been changed, a file save | is done unless :stop! is specified) execute ex command sequence | Q :so filename or Q :source filename stored in a file | (enter :vi to return to vi mode) create a ctags file for use | ctags prog* later by vi | (create a file "tag" in the current directory | that contains pointers to segments of code in | all programs whose names start with "prog") | ctags *.c *.h ~/lib/*.h | (create file "tag" with pointers to all program | segments in all C and header files in the | current directory along with all header files | in the "/lib/" directory) edit tagged program segment | :ta Segmentnametag or :tag Segmentnametag (a very quick way to hop | (ctags must have been run to make tags file) around in up to three | :vi -tSegmentname different segments of | (start vi in file with the tagged code segment) code that may be in | Ctrl-] other files or even | (if cursor is placed on first character of a other directories) | tagged program function name, pressing Ctrl-] | will open up the file containing that tagged | code segment; :rew will return to the original | place you were editing prior to Ctrl-]; if you | use Ctrl-] on a function name from the file | that the first Ctrl-] placed you in, you may | be placed into yet a third file; Ctrl-^ will | toggle back and forth between this file and | the one opened by the first Ctrl-]; :rew will | return you back to the original edit spot) undo all changes made by | :u or :undo the last editing command | (equivalent to vi "u" undo command) print vi program version | :ver or :version yank lines using ex | :ya or :yank or :y | (address)ya(bufferletter) | :y a 4 (yank 4 consecutive lines and store in | buffer a) | :12,19 y (yank lines 12-19 to general buffer) shift lines left/right | :(address)<(count) or :(address)>(count) in ex | :> (shift current line one shiftwidth to right) | :<8 (shift 8 consecutive lines one shiftwidth to | the left) line address of ex commands | none (execute ex command on current line only) | $ (last line in file) | . (current line in file) | - (line above current line of cursor) | + (line below current line of cursor) | n (nth line in file) | % (every line in the file; same as 1,$) | g (global or all lines in file; same as %) | .-n (nth line before the current line) | .+n (nth line after the current line) | 'a (line previously marked as "a") | '' (line of previous context where cursor was) | /pattern/ (first line in the forward search | direction having a given pattern) | ?pattern? (first line in the backward search | direction having a given pattern) | a,b (all lines from line "a" to line "b") | 'a,'b (all lines from line marked "a" to line | marked "b"; marker "b" must not precede | marker "a" in file) | a+n,a-n ("n" lines after or before "a" where "a" | is any address described above; second | address must not precede first address) ******************************************************************************** VI OPTION SETTINGS | DESCRIPTION ******************************************************************************** All toggle flag options can be disabled by adding prefix 'no' to option name Options may also be specified using the abbreviations shown in brackets. -------------------------------------------------------------------------------- :set all | Display all current option settings. :set autoindent (ai) | Good for programming; indent next line the same | distance as the previous line; Ctrl-T or Ctrl-D | (input mode) add or remove indent levels based | on tabstop setting. Def: noai. :set autoprint (ap) | Display changes after each editor command. Def: | ap. :set autowrite (aw) | Automatically write the file if changed before | opening another file with :n or before giving a | Unix command with :!. Useful when editing two | or more files simultaneously. Def: noaw. :set beautify (bf) | Ignore control characters during input (except | tabs, newlines, and formfeeds). Def: nobf. :set directory=???? (dir) | Store buffer files in the specified directory. | Def:/tmp. :set edcompatible | Use ed-like features on substitute commands. Def: | noedcompatible. :set errorbells (eb) | Sound bell when error occurs. Def: errorbells. :se hardtabs=? (ht) | Define boundaries for terminal hardware tabs. Def: | ht=8. :set ignorecase (ic) | Disregard case of characters during searches. Def: | noic. :set lisp | Insert indents in appropriate lisp format. Def: | nolisp. :set list | Display tabs as ^I and ends of lines as $. Def: | nolist. :set magic | Wildcard characters . * [] ~ have special meaning | when used in patterns. Def: magic. :set mesg | Permit system messages to display on terminal | while editing, which may disrupt display; can | use Ctrl-L to restore screen display) :set modeline | After vi reads EXINIT variable and .exrc file, the | first and last 5 lines of the file are read for | extra ex commands; embedded commands must begin | with "ex:" or "vi:" and must be valid ex editor | commands; separate multiple commands with "|"; | each line must be terminated with :. :set number (nu) | Display line numbers left of screen. Def: nonu. :set open | Allow entry to open or visual mode from ex. Def: | open. :set optimize (opt) | Abolish carriage returns at end of lines when | printing many lines; speeds output on dumb | terminals when displaying lines with leading | white spaces (blanks or tabs). Def: noopt. :set paragraphs=??? (para) | Define paragraph delimiters for movement by {}. | Pair of characters used in value are names of | nroff/troff macros that begin paragraphs. :set prompt | Display ex prompt (:) when vi Q command given. | Def: prompt. :set readonly (ro) | Any writes of a file will fail unless ! is used | after the write (using w, ZZ, or autowrite). | Def: noro. :set redraw (re) | Redraw screen whenever edits are made. Noredraw | is useful on slow dumb terminals; deleted lines | show up as @ and inserted text appears to | overwrite existing text until <Esc> pressed. | Def: depends on line speed and terminal. :set remap | Allow nested map sequences. Def: remap. :set report=? | Display message on prompt line whenever an edit is | made that affects at least a certain number of | lines. Def: report=5. :set scroll=?? | Amount of lines to scroll. Def: half of window. :set sections=?? ?? | Define section delimiters for movement by [[ ]]. | Pair of characters used in value are names of | nroff/troff macros that begin sections. :set shell=???? (sh) | Define pathname of shell used for shell escape | ':!' and shell command ':sh'. Def: path derived | from the existing shell environment. :set shiftwidth=? (sw) | Define number of spaces for backward tabs when | autoindenting or shifting lines using << or >> | command. Def: sw=8. :set showmatch (sm) | Good for programming; when ) or } is entered, | cursor moves briefly to matching ( or {; if no | match made, error bell rings. Def: nosm. :set slowopen (slow) | Hold off display during insert. Def: depends on | line speed and terminal type. :set tabstop=? (ts) | Define number spaces <Tab> spaces. Def: ts=8. :set taglength=? (tl) | Define number of characters significant for tags. | Def: tl=0, all characters significant. :set tags=?? ??? | Define pathname of files containing tags. Def: | system searches /usr/lib/tags and file "tag" in | the current directory. :set term=vt??? | Define the terminal type. :set terse | Display shorter error messages. Def: noterse. :set timeout (to) | Time out a keyboard map after 1 second; useful | only for vi versions that allow mapping a | sequence of keystrokes. Def: to. :set ttytype=vt??? | Define the terminal type. :set warn | Display warning "No write since last change". Def: | warn. :set window=?? (w) | Display specified number of lines on screen. Def: | depends on line speed and terminal type. :set wrapmargin=?? (wm) | Define right margin to be n number of spaces from | end of line; will automatically insert carriage | returns to break lines. Def: wm=0. :set wrapscan (ws) | Continue search around either end of a file. Def: | ws. :set writeany (wa) | Allow saving to any file. Def: nowa. ******************************************************************************** OTHER NOTES ABOUT VI ******************************************************************************** Some VI commands have opposite lowercase and uppercase meanings. Usually, lowercase means to execute the command after or below the current cursor or line location; uppercase means to execute the command before or above the current cursor or line location. Thus, the VI paste command (P or p) is case-sensitive to have the same effect for copy and move commands as 'b' or 'a' have to denote before or after a specific line number in SPF Edit. Edit commands c (change), d (delete), y (yank) can have a movement command as a suffix to modify the meaning. cc, dd, yy operate on an entire line. But c^ will change text from beginning of line to cursor position, cb will change a word from its beginning up to cursor postion, d$ (or D) will delete from cursor position to end of line, de will delete a word from cursor position to end of word, y$ will yank text to buffer from cursor position to end of line and p will paste the yanked text after the new cursor position, y3w will yank to buffer 3 consecutive words starting from cursor position and P will paste those 3 yanked words before the new cursor position, etc, etc. Thus, change, delete, and yank have the general format (number)(command)(movement) where (number) is the number of occurrences, (command) is either c, d, or y, and (movement) is a movement command. Most VI commands can also have a numeric count as a prefix. Thus, 5w will move the cursor ahead by 5 words, 2( will move the cursor back 2 sentences. VI toggles between the command mode and text input mode by pressing the <escape> key (usually F11). Most keys have a function in command mode. If you are new to VI, and are not sure if you are in command or input mode, or if you think you may have typed a key by mistake, press <escape> until your terminal beeps to get back to command mode. If you typed a key by accident and changed your file, enter 'u' to undo whatever last change was made to the file. EX commands have format :(line_address)(command)(parameters)(count)(flags) where (line_address) defines lines to be affected, (command) defines type of operation, (parameters) define arguments or options, (count) defines optional or required number of lines affected by command, and (flags) define actions to be taken upon completion of command (e.g., p to print line after executing the command; l to print line along with EOL and tabs, c to confirm each change before making it, g to globally repeat command across the line; only g and c are usually needed in vi mode invoking of ex). The EX line_address is usually input in pairs separated by "," or ";". If no beginning address is given, the current line is assumed ".". If ";" is used as a separator, the address before the semicolon becomes the current line address relative to the next address reference. ================================================================================ ################################################################################ E X R C H E L P ################################################################################ Below are settings I have in the .exrc file of my home directory with some comments for each. I'm not sure just how useful each one will be for you, your mileage may vary. Feel free to use, abuse, and hack away at them for your own purposes. Note: do not enter the keymaps as they are shown here; there are many invisible characters and control characters. Instead, if you want to modify them, copy one of the two example exrc files which are in ~hjiwa/text; the exrcproc file contains an example set of keymaps for processing and exrcprog has an example set of programming keymaps. Both keymap sets do not redefine any keys which are already defined by vi with the exception of the "_" character which is mapped to draw a ruler; I keep the ruler keymap here because the "_" character just seems to be more mnemonic to remember as the ruler (besides, the "_" does not have much use anyway). Copy these files to your own .exrc files and then, very carefully, proceed to edit your copy of the .exrc file. Depending on the vi installation you are using, you may not be able to fit all of the keymaps described below into one .exrc file. If you exceed the limits of the .exrc file, whenever you start up VI, you will be flashed with the warning..."TOO MUCH MACRO TEXT". One way around this is to make several .exrc file versions, for instance, one for processing, another for programming, and a third for memos and documents. You can then symbolically link the .exrc file in other directories to the one appropriate for the job. Also, depending upon the implementation of vi that you are using, you may or may not be able to access the .exrc file in your home directory from other subdirectories if that subdirectory does not have an .exrc file itself (this is true of the Hecstations here in New Orleans). You have three options here... (1) create a .exrc in that subdirectory, (2) even better, symbolicaly link to another .exrc that was already created (e.g., in your home directory), or (3) if you only want to use a single .exrc file to do all your editing from, you can set the EXINIT variable in your .login file as such... setenv EXINIT 'set redraw [...any other options] | source ~/.exrc' This will cause vi to properly access the .exrc file in your home directory no matter at what level in your directory tree you are at. The EXINIT variable is first read when you login and it sets vi options globally. If your EXINIT variable is set to source the .exrc file in your home directory, the options in that file are read in next. Finally, if there is also a .exrc file in your current working subdirectory, it is read; any options and keymaps which were previously set by the .exrc file in the home directory may be reset by the .exrc file in your current directory. Note: A ^M character shown here is a <carriage return>, ^[ is an <Escape>, and ^I is a <Tab> character. A "|" character in a keymap (such as the one used in the <_> ruler keymap) requires a double Ctrl-V ^V^V| (which shows up as "^V|") since ex treats the "|" as a command separator. Spaces, tabs, and newlines also must be escaped with Ctrl-V. Further Note: Rules may vary regarding what you can and cannot do within a keymap depending on your implementation of the vi editor. For example, most versions of vi will not allow you to yank from within a keymap (not to mention that most vi version also do a "ye" or "yE" command improperly, yanking everything but the last letter of the word)...just something to consider in making keymaps. After each keymap description, there will be a list of which exrc file(s) uses the keymap...exrcproc or exrcprog. Happy hacking... set noignorecase noautoindent noshowmatch wrapmargin=1 set autowrite nowrapscan magic report=2 shiftwidth=2 tabstop=2 "------------------------------------------------------------------------------- " D E F A U L T E D S E T O P T I O N S " set nolist nonumber mesg noreadonly " set term=xterm ttytype=xterm taglength=0 tags=/usr/lib/tags " set autoprint nobeautify directory=/tmp noedcompatible errorbells hardtabs=8 " set nolisp nomodeline open nooptimize prompt noredraw remap scroll=11 " set shell=/bin/csh slowopen noterse timeout warn window=23 nowriteany " EXINIT set in .login to redraw wm=8 The option settings are arranged so that those most likely to be changed from directory to directory are listed on top. For processing or other text where you know it will be either all upper or lower case, set "ignorecase". "autoindent" is good for most processing or programming; but it fills up its indent space with tab control characters that may cause problems with other programs that have to read the file. But you can use the Ctrl-T keymap shown later to get rid of tabs. Set "showmatch" mainly for programming as an aid in making sure your () and {} brackets are paired correctly (note that % can also be used in command mode to check for matching brackets). Some people like to turn on "wrapscan" during pattern searches (unless you turn it off, it defaults to "wrapscan"); it will wrap around and continue searching for a pattern at the start of the file, like an endless loop. Personally, I like to know when there are no more of the pattern to be found in the file. It is a good idea to set shiftwidth equal to the tabstop value; they both default to 8 spaces. The options which are available but left to default are commented out. Uncomment those that you want to set to something different. (exrcproc, exrcprog) "############################################################################### " C O M M A N D M O D E K E Y M A P S "############################################################################### " Z --mapto--> ZZ (save and exit using just one Z; for lazy pinkies) map Z ZZ^? Okay, so there is not much difference between using Z and ZZ to save and exit a file...but one Z is still quicker than two. Just make sure your typing is reasonably accurate if you are going to use this one. Otherwise, you may save and exit the file without wanting to. The "^?" is a Ctrl-V<backspace>; this is needed because you cannot have tail recursion in a macro. (exrcproc, exrcprog) "=============================================================================== " g --mapto--> go to column 40, the middle of the line map g 40^V| Pressing g in command mode is just a quick way to leapfrog over when you need to edit something in the middle of the line; use 0 or $ to hop to the start or end of a line. (exrcproc, exrcprog) "=============================================================================== " Ctrl-I --mapto--> split text at cursor, resume edit at position of split " action simulates ts text split in SPF Edit map ^V^I i^M^[kA Ctrl-I (there is actually an invisible ^I tab character after the ^V) mimics the ts text split command in SPF Edit. Press Ctrl-I or the <Tab> key in command mode and the line will split in two at the cursor position, leaving you in input mode so you can continue to input at your current cursor position. (exrcproc, exrcprog) "=============================================================================== " Ctrl-A --mapto--> split text at cursor, resume edit at end of split line map ^A i^M^[A Ctrl-A is a variation of the Ctrl-I text split keymap. Do Ctrl-A in command mode and the line will split in two at the cursor position, leaving you in input mode at the end of the original unsplit line where you can continue to append text to the end of this second line. (exrcproc, exrcprog) "=============================================================================== " Ctrl-W --mapto--> find the next occurrence of the word defined at cursor " n or N may be used for repeat finds " to find pattern instead of word, use the second keymap map ^W mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9_]^Md0s/\<^[ea\> ^[D"wdd`w@w "map ^W mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9_]^Md0s/^[ea ^[D"wdd`w@w Ctrl-W takes the word your cursor is currently on and finds the next occurrence of the word; note that it looks for an actual word as opposed to the word being just a embedded pattern of another word. For example, if your cursor is positioned on a word as shown below by the ^ MAIN_PASS-62 ^ Ctrl-W will find "MAIN_PASS", "MAIN_PASS-62", and "MAIN_PASS-48", but not "MAINPASS", "MAIN PASS", "MAIN_PASS62", or "SOUTH_PASS". After the first Ctrl-W, you can use n or N to do repeat finds on "MAIN_PASS". To look for the defined word as any given pattern in the file, uncomment the second commented map, comment the first one. As an example of this alternate map, if the cursor is at the following place ^ NMO ^ Ctrl-W will find "VNMO", "RNMO", "NMO", and "FUNMONGERS". I also find this keymap handy for following the name of a variable in program code to see where it is used next. (exrcproc, exrcprog) "=============================================================================== " Ctrl-X --mapto--> delete spaces/tabs at ends of lines and on blank lines map ^X mz:%s/[ ^I]*$//^M`z Ctrl-X will trim off all extraneous space and tab characters at the ends of lines and on blank lines that have nothing but tabs or white space. This can help to save some disk space. There is actually one space and one tab character within the [ ] brackets. (exrcproc, exrcprog) "=============================================================================== " Ctrl-T --mapto--> globally replace all tabs with white spaces " V---- set number of spaces here to your tabstop setting map ^T :%!expand -2^M1G Ctrl-T will globally replace all tabs, which exist as special characters in the file, with blank spaces and returns you to the top of your file. Many programs (including processing/programming programs and the laser printer) have a problem with the presence of tab characters which are left in the file whenever you hit the <Tab> key or use the autoindent option. If you set the tabstop option to something other than 2, you need to modify the map by changing the expand value. (exrcproc, exrcprog) "=============================================================================== " v --mapto--> shift lines marked a through b one space to the right " assumes begin/end lines are already marked a and b map v :'a,'bs/^/ /^M "------------------------------------------------------------------------------- " V --mapto--> shift lines marked a through b one space to the left " assumes begin/end lines are already marked a and b " to prevent shifting off screen, use the second /^ \ version map V :'a,'bs/^.\(.*\)/\1/^M "map V :'a,'bs/^ \(.*\)/\1/^M The v and V keymaps provide for a continous shifting of a block of lines like the (( )) block shifts in SPF Edit. Before using either one, mark the first and last lines of the block of text you want to shift with "a" and "b", just as you would in SPF Edit using )) on the first and last line of the text block. Having done so, v will shift that block of text one space to the right; if you keep v held down, the text will keep shifting. V will shift the text back to the left in a similar fashion. The map is set up to allow shifting of the text all the way off the screen (and off your file) just as the (( works in SPF Edit. If you are paranoid about this, uncomment the second map and comment the top one to only allow V to shift left if there are more blank spaces. Of course, you can also shift lines in vi using > or <, but with these, the shift increment is hard-wired to your shiftwidth option setting (which you could still set to 1 to achieve space-by-space shifting, but then, this will not function properly when using Ctrl-D in input mode to do reverse tabbing in autoindent mode). (exrcproc, exrcprog) "=============================================================================== " K followed by Ctrl-K simulates the tf text flow line command in SPF Edit " K --mapto--> set up fmt command for justifying margin of paragraph " set expand equal to tabstop, enter line length after - " for constant line length fmt, use the second K keymap below " V---- set number of spaces here to your tabstop setting map K !}expand -2^M!}fmt - "map K !}expand -2^M!}fmt -80^M!}expand -8^M "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " Ctrl-K --mapto--> expand any tabs left by fmt <K> operation to 8 spaces " needed if fmt inserted tabs that shifted the text map ^K !}expand -8^M The K/Ctrl-K keymaps simulate the tf text flow command in SPF Edit. It uses the Unix fmt command to format a paragraph of text at a time. fmt considers a paragraph to be delimited at the end by either an empty line or an indented line following it. To make sure this keymap does not erroneously rearrange text, you might want to use o to open up a empty line below where you want the text flowing to stop (assuming the block of text does not already have a blank line beneath it); note that I said "empty" ...a blank line with white spaces after a block of text is still considered to be an extension of the previous paragraph. If your tabstop is set to something other than 2 spaces, change the number marked with "V-" to the whatever your tabstop setting is. The !}fmt - on the K keymap will then leave a !fmt - prompt; enter the number that you want the length of the blocked text to be; this will typically be either 72 or 80. Thus, !fmt -72 is the same as entering tf72 on SPF Edit. If your text was indented 8 or more spaces to the right prior to the K command, fmt will replace every 8 characters with a tab character; if your tabstop setting is not 8, after pressing K, the blocked text will appear to shift to the left. The Ctrl-K keymap expands the 8-space tabs back into 8 blank spaces. If your tabstop is set to 8, your blocked text will not shift around, but fmt will still insert its tab characters. The alternate keymap that is commented.. "map K ^X!}expand -2^M!}fmt -80^M!}expand -8^M is basically a combination of both K and Ctrl-K together. If you expect to always block your text in the directory to one specific line length (usually 72 or 80), you can use this keymap for K instead and it will not prompt you with a !fmt - (exrcproc, exrcprog) "=============================================================================== " q --mapto--> copy the directory path and date below the current line " change to your user ID -----V map q :r !echo `pwd`/% `date +"\%b \%d \%Y"`^M/hjiwa^Md0f i ^[0 The q keymap outputs to a line below the cursor the directory path, filename, and current date, an example being... hjiwa/Notes/text/exrchelp Sep 10 1992 I like to "stamp" various files with this information. Change the "hjiwa" in the keymap to your user ID. (exrcproc, exrcprog) "=============================================================================== " _ --mapto--> copy ruler below current line (as in SPF Edit COLS command) map _ o^[i----+----1----+----2----+----3----+----4----+----5----+----6----+----7 -^V|--+----8^[0 Pressing _ in command mode will doodle a ruler below the current line, similar to entering COLS on a line in SPF Edit, an example being... ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----8 Either press u next or use dd later to remove the ruler. (exrcproc, exrcprog) "=============================================================================== " * --mapto--> comment line used with # map below " for 72-column, 71a for 80-column, 79a " V------- change character here to appropriate comment symbol map * o^[i#^[79a#^[0 "------------------------------------------------------------------------------- " # --mapto--> comment box with directory path and date after current line " for 72-column, 72l 69A for 80-column, 80l 77A " comment symbol --------------------------VV map # *o^[:.!echo `pwd`/% `date +"\%b \%d \%Y"`^M/hjiwa^Md0i## ^[f i ^[70A ^[0 80lDr#^[*o##^[77A ^[a#^[*k:co-^M "=============================================================================== " = --mapto--> copy several line dividers below current line " for 72-column, 71p for 80-column, 79p " V---------V---------V---------V--- comment symbol map = o^[i#^[79a#^[o*^[79a*^[o=^[79a=^[o-^[79a-^[^ "=============================================================================== " \ --mapto--> three different comment boxes " for 72-column, 71a 69A for 80-column, 79a 77A " V---------------V- comment char -V---------------V----------------V map \ o^[i*^[79a*^[:co-^Mo**^[77A ^[a*^[0jo=^[79a=^[:co-^Mo==^[77A ^[a=^[0jo-^[7 9a-^[:co-^Mo--^[77A ^[a^V|^[0 The keymaps for * # = \ just doodle some lines and boxes. The * just draws a fat line. The # draws a fat box with your current directory path, filename, and date neatly labeled inside it. The = draws more lines; \ draws more boxes. For the # keymap, change the "hjiwa" to your user ID. (exrcproc, exrcprog) "=============================================================================== " <F1> --mapto--> query an MVS dataset with mvsdir to see if it exists map ^[[11~ mz:co-^M`zkmyI ^[A ^[`yll/[ =,"']^MDa'^[?[ =,"']^Md0s:!mvsdir '^["xd d`z@x Pressing F1 in command mode is exactly the same as executing LISTIT on an MVS dataset name in SPF Edit. The cursor must be on some part of the dataset name when F1 is pressed; after a short pause, a message will appear at the bottom of the screen telling you if the Houston MVS dataset exists, and whether it is a tape, disk, or migrated disk dataset. If you press F1 while the cursor is not on the dataset name, the keymap will just go looking for some bogus name. One quirk is that if your cursor is accidentally placed on the = , " or ' character at the end of a dataset name, the command "mvsdir ''" is erroneously executed, which all of the sudden brings up the man pages for mvsdir; just press q to quit and try again. The mvsdir command is part of the Dataprep utilities and you must have it in your path to use this keymap; it runs FTP and executes a 'dir' command on the dataset. For example, if your cursor is positioned on a dataset name as shown below by the ^ DATASET NAME = 'HJIWA.A$.XYZ' ^ Pressing F2 will display the following message at the bottom of the window... Volume Unit Date Ext Used Recfm Lrecl BlkSz Dsorg Dsname TSO028 3380K 09/12/92 3 133 FB 80 9600 PO 'HJIWA.A$.XYZ' [Hit return to continue] If the dataset did not exist, the following message is displayed... No data sets found. [Hit return to continue] (exrcproc) "=============================================================================== " <F1> --mapto--> echo a confirmation warning before the F2 dataset delete map! ^[[11~ :!echo PRESS @x TO CONFIRM DELETION OF ^[f D"ydd`z@y "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F2> --mapto--> create the tsobatch command for F2 delete map below map! ^[[12~ delete '^[:.w! /tmp/$USER.ddel^Md0i:!tsobatch -c ^[$i deleted^[A < / tmp/$USER.ddel^[ "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F2> --mapto--> delete an MVS disk dataset (as in SPF DELIT command) " to bypass delete confirmation, use the second keymap map ^[[12~ mz:co-^M`zkmyI ^[A ^[`yll/[ =,"']^MDa'^[?[ =,"']^Md0s^[[12~:co-^M"xd df'd0s^[[11~ "map ^[[12~ mz:co-^M`zkmyI ^[A ^[`yll/[ =,"']^MDa'^[?[ =,"']^Md0s^[[12~"xdd`z@x These three keymaps work together so that pressing F2 in command mode will execute a command equivalent to the SPF DELIT command to delete a Houston MVS disk dataset. As in the F1 LISTIT keymap above, the cursor must be placed somewhere on the dataset name prior to pressing F2. For example, if your cursor is positioned on a dataset name as shown below by the ^ DATASET NAME = 'SSN.P1ABCW00.BRUTE.STACK.C913114' ^ Pressing F2 will display the following message at the bottom of the window... PRESS @x TO CONFIRM DELETION OF SSN.P1ABCW00.BRUTE.STACK.C913114 Press <Return> and, if you are sure you want to delete the dataset displayed, press @x next ("@" followed by "x"), whereby the following message will appear.. :!tsobatch -c 'SSN.P1ABCW00.BRUTE.STACK.C913114 deleted' < /tmp/userid.ddel This is the tsobatch command that was set up and executed by the keymap to issue a delete command via an MVS batch job. To confirm that the dataset was deleted, either use the F1 LISTIT keymap above to see if it is still catalogued later on, or use IJOBS to view the batch job delete. On IJOBS, for the above example, the delete job will be flagged with the message... SSN.P1ABCW00.BRUTE.STACK.C913114 deleted A condition code of 0000 means that the dataset was deleted; if the condition code is 0008, it probably means that the dataset did not exist to begin with. If you are feeling adventurous, comment the first F2 keymap and uncomment the second one so that pressing F2 will automatically send the tsobatch command without having to press @x to confirm deletion; however, if you use the express version of the keymap, you may accidentally delete a dataset more easily (in which case you'll have to go back and try to do an "HRECOVER" on it). If your dataset has a "$" sign in it, you must uncomment and use the alternate F2 keymap because the keymap with the confirmation message will choke on trying to interpret the "$" sign. As with the DELIT keymap shown above, this one runs tsobatch, which is another program in the Dataprep library (that you must have in your path). You can also modify this keymap to automatically do an hrecover, hmigrate, or other TSO command on the dataset name under the cursor. (exrcproc) "=============================================================================== " <F13> --mapto--> display words similar to the word defined at the cursor " to display words similar to the first 4 characters of " the word under the cursor, use the second keymap map ^[[25~ mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9]^Md0s:!look ^[ea ^V| more ^[D"wdd` w@w "map ^[[25~ mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9]^Md0s:!look ^[4la ^V| more ^[D"wd d`w@w Pressing F13 will execute the Unix "look" command to provide a list of words (matched to the word database in /usr/dict/words) that are similar in spelling to the word currently defined by the cursor. For example, if your cursor is positioned on a word as shown by the ^ letter ^ Pressing F13 will list the following words... letterhead letterman lettermen To look for words which are similar to the first 4 characters of the word under the cursor, uncomment the second keymap, comment the first one. For the example word "letter", this keymap would list the following words... letterhead letterman lettermen letting lettuce Of course, you can adjust the sensitivity of this second keymap by changing the "4" in "4la" to something else. Either keymap can be used as a quick way to check the spelling of common words; for example, if the keymap was executed on the word "leter", no words would be listed and you would just get... [Hit return to continue] (exrcproc) "=============================================================================== " <F14> --mapto--> continuation of F14 command mode keymap below map! ^[[26~ :!page -s ~hjiwa/chessdoc/^[ea ^[D:s/[0-9 ]*$//^M:s/.*/\L&/^M"wdd`w@ w "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F14> --mapto--> display processor reference for CHESS program at cursor " to redisplay previous reference pages, enter :!! map ^[[26~ mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9]^Md0s^[[26~ F14 is keymapped so that pressing it while the cursor is on the name of a CHESS program will bring up the CHESS processor reference for that program; this is analogous to the CDB (Chess Documentation Browser) edit macro on SPF. The keymap parses off any numeric extension to the name (e.g., CHSPLT4 becomes CHSPLT) and converts it to lowercase letters to match the documentation filename in my directory ~hjiwa/chessdoc. For example, if your cursor is placed on a CHESS program as shown below by the ^ EDIT BIN2D04: ^ Pressing F14 will generate the shell command - page -s ~hjiwa/chessdoc/bin2d to "page" through the BIN2D documentation I have stored in ~hjiwa/chessdoc. You can also modify this keymap to view program documentation of other types (such as DISCO or PROMAX ;^) ) that is on-line simply by changing the directory path. (exrcproc) "=============================================================================== " <Help> --mapto--> display man pages for the word defined at the cursor " to redisplay previous man pages, enter :!! map ^[[28~ mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9_]^Md0s:!man ^[ea ^[D"wdd`w@w Pressing the <Help> key while your cursor is on a Unix, X, or C command will bring up the man pages for that command, if it exists. This keymap is especially handy for viewing man pages for wordy X library routines. Note that the keymap is similar to the Ctrl-W word find keymap shown earlier. For example, if your cursor is positioned on a word as show below by the ^ XDrawImageString(dpy, w, *gcp, x, y, str, len); ^ Pressing <Help> will bring up the man pages for XDrawImageString. To return to viewing the man pages you were just through with, you can bring up the command again with :!! One fallacy of this keymap is that it will not find the man pages for any Motif library routine (the Xm library) where the name of the routine is greater than 11 characters. This is simply because the man page filenames for Xm routines are chopped off to a maximum of 11 characters. If you keep this in mind, you can still display Xm man pages using this keymap if you count off the first 11 characters, add a space after the 11th character, and then place the cursor back on the shortened name prior to pressing <Help>. For example, if the Xm routine you were interested in was "XmCreatePanedWindow", to execute <Help> on this will bring up a "No manual entry" error message. But if you split the word so it is "XmCreatePan edWindow", executing <Help> on "XmCreatePan" will bring up the appropriate man pages. (exrcproc, exrcprog) "=============================================================================== " <Do> --mapto--> execute the docard script on the current CHESS file map ^[[29~ :%!docard^M Pressing <Do> filters the entire file of CHESS processing steps through a docard awk script to create a DO card for the CHESS job. (exrcproc) "=============================================================================== " <Find> --mapto--> find next occurrence of pattern defined by marks a b " assumes begin/end of pattern is already marked a and b " entire pattern must reside on one single line " n or N may be used for repeat finds map ^[[1~ `b:co-^M`bkmpja ^[D`ad0i/^["pdd`p@p This keymap for the <Find> key is somewhat similar to the Ctrl-W word find keymap except that it operates on a pattern (which can include blanks and punctuation) marked by "a" at the front of the pattern and "b" at the end. For example, if the following "a" and "b" marks have been placed on a line... EDIT FRFILT1: a b Pressing <Find> will find "EDIT FRFILT", "EDIT FRFILT2", or "EDIT FRFILT3". The "a" and "b" marks must be placed on the same line. As in the Ctrl-W keymap, after the find pattern is set, pressing n or N will do repeat finds on the defined pattern. (exrcproc, exrcprog) "=============================================================================== " <Select> --mapto--> copy text marked a through b to xcopy buffer 1 " assumes begin/end lines are already marked a and b " if u is entered after Ctrl-O, the text is cut to buffer " to keep using buffer 1 over again, use the second keymap map ^[[4~ :'a,'b!xcopy -s 0; xcopy -r 1^Mu "map ^[[4~ :'a,'b!xcopy -s 1^Mu "------------------------------------------------------------------------------- " <InsertHere> --mapto--> put text in xcopy buffer 1 below current line map ^[[2~ mzo^[:.!xcopy -p 1^M`z "------------------------------------------------------------------------------- " <PrevScreen> --mapto--> rotate xcopy buffers backwards map ^[[5~ :!xcopy -r -1^M^M "------------------------------------------------------------------------------- " <NextScreen> --mapto--> rotate xcopy buffers forwards map ^[[6~ :!xcopy -r 1^M^M <Select> in command mode copies a block of lines that was previously marked with "a" at the first line and "b" at the last line into xcopy buffer 0; the buffers are then rotated and pushed down the buffer stack. You can use the commented alternate <Select> keymap to keep using buffer a over and over again, thereby preserving the contents of the other buffers. This action is similar to the COPY2 command in SPF in that you mark the lines of text to be copied with "a" and "b" in the same way you mark them with "CC" prior to executing COPY2 in SPF. If you press u right after pressing <Select>, the marked block of text is cut to buffer 1 instead of just being copied. Pressing <InsertHere> in command mode will paste whatever is in buffer 1 below the current line. Pressing <PrevScreen> will rotate the xcopy buffers backwards so that buffer 2 becomes buffer 1 and buffer 1 now becomes buffer 0. Pressing <NextScreen> rotates the xcopy buffers forward so buffer 0 becomes buffer 1 and buffer 1 moves into buffer 2. I find this quicker for loading the xcopy buffers on a line basis than using the mouse; for copying fragments of lines, you still need to use the mouse though. (exrcproc, exrcprog) "=============================================================================== " <F17> --mapto--> comment out the block of DSS text marked a through b map ^[[31~ :'a,'bs/^/CC/^M "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F18> --mapto--> uncomment the block of commented DSS text marked a to b map ^[[32~ :'a,'bs/^CC//^M "------------------------------------------------------------------------------- " <F19> --mapto--> comment out the block of shell script text marked a to b map ^[[33~ :'a,'bs/^/# /^M "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F20> --mapto--> uncomment block of commented shell script marked a to b map ^[[34~ :'a,'bs/^# //^M F17 function key will comment out a block of DSS TRANCE text which is marked label "a" at the first line and label "b" at the last line. F18 will uncomment the block of DSS TRANCE text which is marked with labels "a" and "b" and which was previously commented using F17. F19 and F20 are analogous block commenting keymaps for commenting out blocks of shell script text. (exrcproc) "=============================================================================== " keypad<.> --mapto--> C comment line divider after the current line map ^[On o^[i/*^[77a*^[o^M*^[77a*^[a/^[k "=============================================================================== " <F17> --mapto--> comment out the current line of C code map ^[[31~ I/* ^[A */^[^ "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F18> --mapto--> uncomment the current commented line of C code map ^[[32~ :s/\/\* \(.*\) \*\//\1/^M "------------------------------------------------------------------------------- " <F19> --mapto--> comment out the block of C code lines marked a through b map ^[[33~ :'a,'bs/^/ * /^Mo^[i */^[mb'ahr/ "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " <F20> --mapto--> uncomment the block of commented C code marked a to b map ^[[34~ :'a,'bs/^...//^Mdd`a The keypad . is mapped to draw a C comment line divider in command mode. The F17 function key will comment out the current line of C code in command mode. F18 will uncomment the current commented line of C code in command mode; it will only work if it finds a "/* " at the front and a " */" at the rear of the current line. F19 will comment out a block of C code which is marked with label "a" at the first line and label "b" at the last line. F20 will uncomment the block of C code which is marked with labels "a" and "b" and which was previously commented using F19. (exrcprog) "=============================================================================== " keypad<PF1> --mapto--> draw lint output comment for lint map below map! ^[OP ^[29a*^[a LINT ^[29a*^[a "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " keypad<0> --mapto--> output lint diagnostics as comments at bottom " after running, use '' to toggle first-last line " first line is marked as label z map ^[Op :w^MGo^[i/^[OP^M^[kmz:+!echo `date`^Mi * ^[o^[i *^[G:r!lint -lc %^V|sed 's/^/ * /'^MGo^[i ^[OP/^['z "------------------------------------------------------------------------------- " keypad<4> --mapto--> move important lint diagnostics at bottom of file map ^[Ot 'z/ ==^MkkmajjmcG? ==^Mkkmb/LINT^M:'a,'bmo-^M "------------------------------------------------------------------------------- " keypad<PF1> --mapto--> place each lint diagnostic below its matching line " each message must be deleted before rerunning " z marks lint block; c marks important lint errors map ^[OP `cjmu/([0-9].*)^Mmv:'u,'vj^M0/([0-9].*)^M:co-^Md0s:m^[wD"xddi** L I N T *^[@x^[[31~ "------------------------------------------------------------------------------- " keypad<7> --mapto--> delete ** L I N T ** line patterns left by PF1 " delete each diagnostic before pressing PF1 again map ^[Ow :g/\* L I N T \*/d^M The keypad 0 4 7 and PF1 work together in command mode. 0 invokes lint on the current file and outputs the diagnostic messages from lint at the bottom of the file as a comment block. Press 4 next; then press PF1 to move each lint error message below the actual line of code where the error occurred; the error message is inserted as a comment. Press 7 to delete the lint comment that was moved by PF1. Then press PF1 again to drag the next lint message up to its appropriate line. Keep doing this until PF1 cannot find any more important lint errors to reposition. (exrcprog) "=============================================================================== " keypad<PF4> --mapto--> draw make output comment for make map below map! ^[OS ^[29a*^[a MAKE ^[29a*^[a "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " keypad<Enter> --mapto--> output make diagnostics as comments at bottom map ^[OM :w^MGo^[i/^[OS^M^[kmz:+!echo `date`^Mi * ^[o^[i *^[G:r!make^V|&sed 's/^ / * /'^MGo^[i ^[OS/^['z "------------------------------------------------------------------------------- " keypad<PF4> --mapto--> place each ccom error below its matching line " each message must be deleted before rerunning " z marks make block map ^[OS `z/ccom:^M:co-^M$F:Dbhd0s:'a,'bm^["xdd3wdwO^[i/** M A K E **^[ma/-^^Mo^ [i ** M A K E **/^[mb@x "------------------------------------------------------------------------------- " keypad<6> --mapto--> place each cpp error below its matching line " each message must be deleted before rerunning " z marks make block map ^[Ov `z/cpp:^M:co-^M$F:Dbhd0s:'a,'bm^["xdd3wdwO^[i/** M A K E **^[ma/cpp:^Mo ^[i ** M A K E **/^[mb@x "------------------------------------------------------------------------------- " keypad<9> --mapto--> delete ** M A K E ** line patterns left by PF4 " delete each diagnostic before pressing PF4 again map ^[Oy 1G/\/\*\* M A K E \*\*^Mma/\*\* M A K E \*\*\/^Mmb:'a,'bd^M The keypad Enter PF4 6 and 9 work together in command mode. <Enter> in command mode invokes make on your makefile and spits out any messages at the bottom of the current file as a comment block. Press PF4 to move an error message issued by the C compiler below the actual line of code where the error occurred; the error message is inserted as a comment block. Press 9 to delete the error message comment block. Press 6 to move an error message issued by the C preprocessor beneath the error location in the code. Pressing 9 also deletes this error message comment. Note that the PF4 and 6 keymaps cannot properly move messages across different files if you have errors from files other than the one you are currently editing :^( . (exrcprog) "=============================================================================== " keypad<PF2> --mapto--> draw make lint comment for make map below map! ^[OQ ^[29a*^[a MAKELINT ^[29a*^[a "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " keypad<PF2> --mapto--> output make lint diagnostics at bottom " after running, use '' to toggle first-last line " first line is marked as label z map ^[OQ :w^MGo^[i/^[OQ^M^[kmz:+!echo `date`^Mi * ^[o^[i *^[G:r!make lint^V|&sed 's/^/ * /'^MGo^[i ^[OQ/^['z Pressing PF2 in command mode invokes the command "make lint" and outputs the lint messages as a comment block at the end of the file. The PF1, 7, and 4 keymaps described earlier can be used to move each message up to the line of code where the error occurred. It will not, however, properly handle error messages from files other than the one you are currently editing :^( (exrcprog) "=============================================================================== " keypad<PF3> --mapto--> draw make all comment for make map below map! ^[OR ^[30a*^[a MAKEALL ^[30a*^[a "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " keypad<PF3> --mapto--> output make all diagnostics at bottom " after running, use '' to toggle first-last line " first line is marked as label z map ^[OR :w^MGo^[i/^[OR^M^[kmz:+!echo `date`^Mi * ^[o^[i *^[G:r!make all^V|&sed 's/^/ * /'^MGo^[i ^[OR/^['z Pressing PF3 in command mode invokes the command "make all" and outputs any messages to the end of the file as a comment block. As in the "make" keymap to the <Enter> key described earlier, PF4, 6, and 9 may be used to relocate the error messages although errors from files other than the one currently being edited are not handled properly :^( :^( . (exrcprog) "############################################################################### " I N P U T M O D E K E Y M A P S "############################################################################### " map keypad numbers and punctuation back into correct input mode values map! ^[Op 0| map! ^[Oq 1| map! ^[Or 2| map! ^[Os 3| map! ^[Ot 4 map! ^[Ou 5| map! ^[Ov 6| map! ^[Ow 7| map! ^[Ox 8| map! ^[Oy 9 map! ^[On .| map! ^[Om -| map! ^[Ol ,| map! ^[OM ^M The above bundle of keymaps in input mode simply restore the keypad numbers back to their correct values for those people who prefer to use the keypad for entering numeric data. For some reason, on the Hecstations, the numeric keymap generates bogus values in input mode (termcap problem???). (exrcproc, exrcprog) "=============================================================================== " u undo after a insert mode arrowkey only undoes the last key movement " arrowkeys --mapto--> arrowkeys in insert mode map! ^[OA ^[ka| map! ^[OB ^[ja| map! ^[OD ^[i| map! ^[OC ^[la The four keymaps above allow you to use the four arrow keys to move around the file while staying in input mode. Note that if you <Escape> back to command mode and enter u to undo a change, the undo will only undo the last changes made on the current line, regardless of how many times you have used the arrows in input mode to move all over the file and make changes. (exrcproc, exrcprog) "=============================================================================== " Ctrl-E --mapto--> move to end of next word to append more text map! ^E ^[ea " Ctrl-B --mapto--> move to start of previous word to insert more text map! ^B ^[bi Ctrl-E in input mode allows you to hop forward to append more text at the end of the following word. If you keep pressing Ctrl-E in input mode, the cursor advances forward word by word. Ctrl-B in input mode allows you to hop backward to insert more text at the start of the preceding word. Both keymaps only add new text to previously existing text; i.e., they are not quite like Ctrl-W which lets you back up on newly added text. (exrcproc, exrcprog) "############################################################################### " I N P U T M O D E A B B R E V I A T I O N S "############################################################################### " main__ --expandto--> C comment box followed by main() ab main__ /*^[77a*^[o^M^[:.!echo `pwd`/% `date`^M9dwf li ^[2dw2w6dwo^M*^[ 77a*^[a/^M^Mmain()^M{^M^M^M}^[kki The above abbreviation outputs a C comment box showing the current directory, filename, and date along with the main() heading. (exrcprog) The following keys in VI have no function and can be safely mapped as commands. Note that if you are using dxterm instead of xterm, you may not be able to map your function keys. ################################################################################ C O M M A N D M O D E K E Y M A P S ################################################################################ # * \ g q v K V Ctrl-A Ctrl-I Ctrl-K Ctrl-O Ctrl-T Ctrl-W Ctrl-X all arrow and function keys all numeric keypad keys ################################################################################ I N P U T M O D E K E Y M A P S ################################################################################ Ctrl-A Ctrl-B Ctrl-E Ctrl-F Ctrl-G Ctrl-H Ctrl-I Ctrl-K Ctrl-L Ctrl-M Ctrl-N Ctrl-O Ctrl-P Ctrl-R Ctrl-T Ctrl-X Ctrl-Y Ctrl-Z all arrow and function keys all numeric keypad keys