MED(1) MED(1) NNAAMMEE med - screen editor SSYYNNOOPPSSIISS med [ -n ] [ -r ] [ -t ] [ -T _t_a_b_f_i_l_e]] _f_i_l_e [[_s_t_a_r_t_l_i_n_e]] [[_s_e_a_r_c_h_k_e_y]] mmeedd -- mmeedd DDEESSCCRRIIPPTTIIOONN _m_e_d calls the MED editor, which allows you to edit a file using the screen of your terminal and the cursor keys, somewhat like paper, pencil and eraser. If you call the editor with mmeedd _f_i_l_e, the first lines of _f_i_l_e will be shown on the terminal screen. If _f_i_l_e does not exist, it will be created. _m_e_d called with no arguments continues where the previous _m_e_d session ended. _m_e_d called with argument "-" restores only the current file from the last session. --nn Disables file changes (noediting). Files may be viewed but not altered (i.e. they are treated as read only files). --rr Saves all the keystrokes in the file _$_S_A_V_E_/_M_E_K_*. This file may be used for recovery by redoing the complete editing session. Files that are recovered must have exactly the same content as they had prior to when keystroke saving started. --tt Prevents replacement of starting blanks by tabula- tors on an edited line. --TT _t_a_b_f_i_l_e initializes tabulator positions. Tabulators will be set at columns where characters in the first line of the tabfile are different than the previ- ous. The purpose of a screen editor is to view and change existing files. _m_e_d allows you to see a file by moving a _w_i_n_d_o_w (the text shown on the screen) over the file text. The window may be moved up, down, to the left or to the right. The _c_u_r_s_o_r (a blinking underline or box) shows where _m_e_d is at the moment. Initially _m_e_d is in _r_e_p_l_a_c_e _m_o_d_e, i.e. the characters typed will replace those under the cu_r_s_or_.__ T_h_e__cu_r_s_o_r may be m_o_v_e_d__a_r_ound_w_i_t_h__the a_r_r_o_w_ keys |_|^_|_ |_|v_|_ |_<_-_|_ |_-_>_|_ or with |_r_e_t_u_r_n_|_ or |_h_o_m_e_|_ or |_t_a_b_|_ . To change text on the screen, move the cursor to the desired position on the screen and type in new characters. 1 MED(1) MED(1) _______ |_d_e_l_c_h_|_ deletes the character under the cursor. To insert characters in__t_h_e__m_i_ddle of a word (like a _d in _m_i_d_l_e), press the |_i_n_s_e_r_t_|_ key. Then you can type in the new characters, and the_r_e_s_t__o_f_ the line will move to the right. Pressing |_i_n_s_e_r_t_|_ again, switches _m_e_d back to _r_e_p_l_a_c_e _m_o_d_e. _F_u_n_c_t_i_o_n _k_e_y_s are special keys along the top or the right of the keyboard. Each function key does one job, such as moving lines, looking for a word, or accessing another file. A chart of all the different function keys for your terminal should be included in your documentation. Some functions take arguments such as a _n_u_m_b_e_r_, a _s_e_a_r_c_h _s_t_r_i_n_g_, a _f_i_l_e _n_a_m_e_, etc. To enter an argument, type the sequence_:______ __________ _______|_e_n_t_e_r_|_ _n_u_m_b_e_r _o_r _s_t_r_i_n_g |_f_u_n_c_t_i_o_n_|_ . |_e_n_t_e_r_|_ leaves a @ marker on the screen to remind you where the cursor was. The cursor then moves to the status line at bottom of the screen to read the argument. This status line is also used to display error messages. MMIISSCCEELLLLAANNEEOOUUSS What do the characters in the margins mean? II This is normal. \\ This means this is past the end of the file. You may still continue typing - there just wasn't any- thing there before. Even if you type something on a line, the character won't go away until the line is rewritten by the editor. << There is still more text to the left (possibly blanks). >> There is still more text to the right (not only blanks). When editing a file for which you don't have write permis- sion, the appropriate editor functions will be disabled. RREECCOOVVEERRIINNGG AAUUTTOOMMAATTIICC BBAACCKKUUPP FFIILLEESS You are protected from loss of files by MED's automatic backup system. If you edit a file named _f_o_o, the old file _f_o_o is renamed _f_o_o_._b_a_k (any previous _f_o_o_._b_a_k is deleted). If you do not like the results of your edit, use the UNIX command: mmvv ffoooo..bbaakk ffoooo to restore the original file _f_o_o. RREEMMAARRKK ____ ____ ______ ______ ______ Wherever |_<_-_|_ |_-_>_|_ are used, |_e_o_l_n_|_ |_s_o_l_n_|_ |_s_k_i_p_|_ and 2 MED(1) MED(1) ______ |_b_a_c_k_|_ may be used as well. 3 MED(1) MED(1) FFUUNNCCTTIIOONN KKEEYYSS Move around: box tab(#); lbw(1.8c) lw(5.2c). |^ |v <- ->#Move cursor eoln#Skip to end of line soln#Move cursor to start of line skip#Skip to end+1 of next word back#Back to start of previous word return#Move cursor to start of next line +-tab#Skip to next/previous tab stop +-page#Move to next/previous page +-line#Move a halfpage up/down +-search#Search for a word goto#Goto line _n left#Move win- dow left right#Move window right Use another file or window: box tab(#); lbw(1.8c) lw(5.2c). use#Use another file window#Create/delete a window chwin#Go to next window Cut and paste: box tab(#); lbw(1.8c) lw(5.2c). backspace#Delete character left of cursor close#Delete line(s) into CLOSE buffer delch#Delete character open#Insert blank line(s) pick#Copy text to PICK buffer put#Get text from PICK buffer restore#Get text from CLOSE buffer Others: box tab(#); lbw(1.8c) lw(5.2c). do#Run a UNIX command enter#Enter a parameter exit#Go back to UNIX insert#Flip insert mode control#Control character escape refresh#Refresh save#Write changes to disk settab#Change _______tabs__m_a_c_r_o_#_Collect keystrokes |_e_n_t_e_r_|_ _n |_|^_|v_<_-_M-_o>_v|_e the cursor _n lines/columns in the direction of the arrow. ___________ |_b_a_c_k_s_p_a_c_e_|_ Rem_o_v_e___t_h_e__l_ast character entered; thus typing EE RR XX |_b_a_c_k_s_p_a_c_e_|_ RR is the same as EE RR RR. This also works in insert mode. ________ |__s__e__t__t__a__b__|_______S_e_t a tab stop at the current position. |__e__n__t__e__r__|__ |_s_e_t_t_a_b_R|_em_o_v_e__t_h_e_ tab stop at the current position. |_e_n_t_e_r_|_ _t_a_b_f_i_l_eSe|_ts_e_tt_at_ba_b_s|_tops (see option --TT). _______ |__c__h__w__i__n__|__ ____G_o__to the next window. |_e_n_t_e_r_|_ _n |_c_h_w_i_Gn_o|_ to window _n. Windows are numbered in the order _______ _t_h_e_y__a_re created. |_e_n_t_e_r_|_ <--> |_c_Ah_rw_gi_un_m|_ent defined by the cursor is used as window number. _______ |__c__l__o__s__e__|__ ______D_elete one line. It is saved in the CLOSE buffer. |_e_n_t_e_r_|_ |_c_l_o_s_e_|_Delete the rest of the line, replacing it with the _______ ____l_i_n_e below. |_e_n_t_e_r_|_ _n |_c_l_o_s_De_e|_lete _n lines and save them in the CLOSE buffer. 4 MED(1) MED(1) _______ _______ |_e_n_t_e_r_|_ |^|v<-->D|_ec_ll_eo_ts_ee_|_lines or a rectangle defined by the cursor and put it into the CLOSE buffer. _______ |_d_e_l_c_h_|_ Delete the character at the current cursor posi- tion, moving the following characters to the left. ____ |_d_o_|_ Run the previous DO command exactly as it was _______ ____ given. |_e_n_t_e_r_|_ |_d_o_|_ Take the current line as a command for the shell. _______ __R_e_sults are inserted below the current line. |_e_n_t_e_r_|_ _c_m_d |_d_o__c|__m_d is a UNIX command in the format [[nn[[ll]]]] pprrgg [[aarrgg......]] (in shell notation). It replaces _n para- graphs (or _n lines if ll appears) by the result of running filter pprrgg on that text with given aarrggss. The replaced paragraphs are saved in the CLOSE buffer. ______ |_e_x_i_t_|_ Exit _m_e_d, writing back the changed files to disk (a _______ ______backup file named _*_._b_a_k is created). |__e__n__t__e__r__|__ |_e_x__i__t__|__W_r_ite all changed files to disk without exiting. |__e__n__t__e__r__|__ aa |_e__x__i__t_E_|_x_i_t, but do not save files. |_e_n_t_e_r_|_ aadd |_e_x_i_Tt_e|_rminate with core dump. ______ |__g__o__t__o__|___ ______Move window to top of file. |__e__n__t__e__r__|__ |_g_o__t__o__|__M_o_ve window to end of file. |__e__n__t__e__r__|__ _n |_g_o_t__o_M_|_o_v_e__to the _nth line. |_e_n_t_e_r_|_ <--> |_g_Ao_rt_go_u|_ment defined by the cursor is used as line num- ber. ________ |_i_n_s_e_r_t_|_ Put the editor into insert mode. Subsequent char- acters are inserted at the cursor, i.e., characters to the right of the cursor are _n_o_t___r_e_placed but moved to the right. Pressing |_i_n_s_e_r_t_|_ again will place _m_e_d back to replace mode. ______ |__l__e__f__t__|___ ______Move window left (about a 1/3 window width). |__e__n__t__e__r__|__ |_l_e__f__t__|__M_a_ke the current column the last one (if possible). |_e_n_t_e_r_|_ _n |_l_e_f_t_M|_ove window _n columns left. _______ |__+__l__i__n__e__|__ ______M_ove window down (about 1/3 page). |__e__n__t__e__r__|__ |_+_l__i__n__e__|_M_a_k_e the current line the top one. |_e_n_t_e_r_|_ _n |_+_l_i_n_Me_o|_ve window down _n lines. _______ |__-__l__i__n__e__|__ ______M_ove window up (about 1/3 page). |__e__n__t__e__r__|__ |_-_l__i__n__e__|_M_a_k_e the current line the bottom one (if possible). |_e_n_t_e_r_|_ _n |_-_l_i_n_Me_o|_ve window up _n lines. ______ |__o__p__e__n__|___ ______Open up one blank line. |__e__n__t__e__r__|__ |_o_p__e__n__|__S_p_lit the line exactly at cursor position. |_e_n_t_e_r_|_ _n |_o_p_e_n_O|_pen up for _n blank lines. 5 MED(1) MED(1) _______ ______ |_e_n_t_e_r_|_ |^|v<-->I|_no_sp_ee_rn_t|_blank lines or rectangle in area defined by cursor. _______ |__+__p__a__g__e__|__ ____M_o_v_e window down one page (page = size of window). |_e_n_t_e_r_|_ _n |_+_p_a_g_Me_o|_ve down _n pages. _______ |__-__p__a__g__e__|__ ____M_o_v_e window up one page. |_e_n_t_e_r_|_ _n |_-_p_a_g_Me_o|_ve up _n pages. ______ |__p__i__c__k__|___ ____P_u_t the current line into the PICK buffer. |__e__n__t__e__r__|__ _n |_p_i_c_k_P|_u_t___n__l_ines into the PICK buffer. |_e_n_t_e_r_|_ |^|v<-->P|_lp_ai_cc_ek_|_lines or rectangle defined by cursor in PICK buffer. _____ |_p_u_t_|_ Insert the contents of the PICK buffer (i.e. the lines or rectangle last "picked") at the current _______ ____p_osition. |_e_n_t_e_r_|_ _n |_p_u_t_|_Insert _n copies of the PICK buffer at the current _______ _p_o_s_i_tion. |_e_n_t_e_r_|_ <--> |_p_Au_rt_g|_ument defined by the cursor is used as number of copies. _________ |_c_o_n_t_r_o_l_|_ T_o____p_u_t__ a control character into the file. |_c_o_n_t_r_o_l_|_ echoes as a @@, and whatever key on the keyboard you press next appears as some printable character. The two characters now behave as two characters on the screen, but they are really the single control character in the file. Changing the second letter changes the control character; chang- ing the preceding mark results in two ordinary characters. _________ |_r_e_f_r_e_s_h_|_ Redraw terminal display. _________ |_r_e_s_t_o_r_e_|_ Insert the contents of the CLOSE buffer (i.e. the lines or rectangle last deleted). Insertion is _______ ____d_o_n_e__at the current position. |_e_n_t_e_r_|_ _n |_r_e_s_t_Io_nr_se_e|_rt _n copies of the CLOSE buffer at the current _______ _p_o_s_i_t_i_o_n_. |_e_n_t_e_r_|_ <--> |_r_Ae_rs_gt_uo_mr_ee_n|_t defined by the cursor is used as number of copies. _______ |__r__i__g__h__t__|__ ______M_ove window right (about a 1/3 window width). |__e__n__t__e__r__|__ |_r_i__g__h__t__|_M_a_k_e current column the first one. |_e_n_t_e_r_|_ _n |_r_i_g_h_Mt_o|_ve window right _n columns. ______ |__s__a__v__e__|___ _S_a_v_e__the file shown in the current window. |_e_n_t_e_r_|_ _n_a_m_e |_s_Sa_av_ve_e|_ the file shown in the current window under _______ _f_i_l_e_n_ame _n_a_m_e. |_e_n_t_e_r_|_ <--> |_s_Aa_rv_ge_u|_ment defined by the cursor is used as filename. 6 MED(1) MED(1) _________ |_+_s_e_a_r_c_h_|_ Search forwards (from the cursor towards the end of the file) for an occurrence of the search key last _______ ______u_s_e_d. |_e_n_t_e_r_|_ |_+_s_e_a_r_c_Sh_e|_arch key used is from cursor position up to next _______ _b_l_a_n_k_.___ |__e__n__t__e__r__|__ _w_o_r_d |__+_S_s_e_e_a_a_r_r_c_c_h_h__|_f_or the next occurrence of _w_o_r_d. |_e_n_t_e_r_|_ <--> |_+_As_re_ga_ur_mc_eh_n|_t defined by the cursor is used as search key. _________ |_-_s_e_a_r_c_h_|_ Search backwards (from the cursor towards the beginning of the file) for an occurrence of the _______ ______s_e_a_rch key last used. |_e_n_t_e_r_|_ |_-_s_e_a_r_c_Sh_e|_arch key used is from cursor position up to next _______ _b_l_a_n_k_.___ |__e__n__t__e__r__|__ _w_o_r_d |__-_S_s_e_e_a_a_r_r_c_c_h_h__|_f_or the next occurrence of _w_o_r_d. |_e_n_t_e_r_|_ <--> |_-_As_re_ga_ur_mc_eh_n|_t defined by the cursor is used as search key. _____ |__u__s__e__|____ _____ Switch to the file previously used. |_e_n_t_e_r_|_ |_u_s_e_|_ Edit file, taking its name from cursor position up _______ _t_o__n_ext blank. |_e_n_t_e_r_|_ _n_a_m_e |_u_Ms_ae_k|_e the current window look at file _n_a_m_e. A linenumber and/or searchkey can be specified (as in the _m_e_d command). A --nn prepended to the filename _______ _w_i_l_l_ disallow editing. |_e_n_t_e_r_|_ <--> |_u_As_re_g|_ument defined by the cursor is used as filename. ________ |_w_i_n_d_o_w_|_ Make another window on the real screen, so that you now have two, or three, or more windows. A _d_e_f_a_u_l_t _f_i_l_e is_u_s_e_d_. It may be set to look at a file using |_u_s_e_|_ , and all other functions work within this little window. If the cursor is on the first or last column of your window the line separating the two windows goes horizontally on the line where the cursor is. The separating line goes vertically if the cursor is on the first or last line of your window. You may have two windows looking at the same file. In fact, it is rather useful, since changes made by editing in either window are reflected (at reasonable intervals) in the other _______ ______w_i_ndow. |_e_n_t_e_r_|_ |_w_i_n_d_o_w_D|_elete last created window and return to the previ- _______ _o_u_s__o_n_e_. |_e_n_t_e_r_|_ _n_a_m_e |_w_Ci_rn_ed_ao_tw_e|_another window displaying file _n_a_m_e. 7 MED(1) MED(1) MMAACCRROOSS Typing _______ _______ |_m_a_c_r_o_|_ _k_e_y_s_t_r_o_k_e_s |_m_a_c_r_o_|_ _k_e_y stores the _k_e_y_s_t_r_o_k_e_s sequence into the _k_e_y. To avoid trouble, _k_e_y can only be a printable character. >From now on pressing the _k_e_y is equivalent to typing the (long) _k_e_y_s_t_r_o_k_e_s sequence.__T_h_e__s_eq_u_e_n_c_e__ |_m_a_c_r_o_|_ |_m_a_c_r_o_|_ _k_e_y restores the original function of the _k_e_y. FFIILLEESS tab(#); l l. /tmp/MED* #temporary workfile (PICK- and CLOSE-buffer) $SAVE/MED* #saves state of editing session $SAVE/MEK* #saves keystrokes for a recovery session /usr/lib/med/default#default file *.bak #backup files SSEEEE AALLSSOO terminfo(5), curses(3X), med_keycap(5). BBUUGGSS Editor crashes can leave your terminal in a strange state, e.g. with disabled keyboard. The UNIX command: stty san_e_________ activated with |_l_i_n_e_f_e_e_d_|_ will enable the keyboard. 8