Edit file File name : jed011.html Content :<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta name="generator" content="hevea 2.35"> <link rel="stylesheet" type="text/css" href="jed.css"> <title>Basic Editing</title> </head> <body > <a href="jed010.html"><img src="previous_motif.svg" alt="Previous"></a> <a href="index.html"><img src="contents_motif.svg" alt="Up"></a> <a href="jed012.html"><img src="next_motif.svg" alt="Next"></a> <hr> <h2 id="sec17" class="section">10 Basic Editing</h2> <p>Editing with <span style="font-weight:bold">jed</span> is pretty easy— most keys simply insert themselves. Movement around the buffer is usually done using the arrow keys or page up and page down keys. If <code class="verb">edt.sl</code> is loaded, the keypads on VTxxx terminals function as well. Here, only the highlights are touched upon (cut/paste operations are not considered “highlights”). In the following, any character prefixed by the <code class="verb">^</code> character denotes a Control character. On keyboards without an explicit Escape key, <span style="font-variant:small-caps">Ctrl-[</span> will most likely generate and Escape character.</p><p>A “prefix argument” to a command may be generated by first hitting the <span style="font-variant:small-caps">Esc</span> key, then entering the number followed by pressing the desired key. Normally, the prefix argument is used simply for repetition. For example, to move to the right 40 characters, one would press <span style="font-variant:small-caps">Esc 4 0</span> followed immediately by the right arrow key. This illustrates the use of the repeat argument for repetition. However, the prefix argument may be used in other ways as well. For example, to begin defining a region, one would press the <span style="font-variant:small-caps">Ctrl-@</span> key. This sets the mark and begins highlighting. Pressing the <span style="font-variant:small-caps">Ctrl-@</span> key with a prefix argument will abort the act of defining the region and to pop the mark.</p><p>The following list of useful keybindings assumes that <code class="verb">emacs.sl</code> has been loaded.</p><p><span style="font-variant:small-caps">Ctrl-L</span><br> Redraw screen.</p><p><span style="font-variant:small-caps">Ctrl-_</span><br> Undo (Control-underscore, also <span style="font-variant:small-caps">Ctrl-X u</span>).</p><p><span style="font-variant:small-caps">Esc q</span><br> Reformat paragraph (wrap mode). Used with a prefix argument. will justify the paragraph as well.</p><p><span style="font-variant:small-caps">Esc n</span><br> narrow paragraph (wrap mode). Used with a prefix argument will justify the paragraph as well.</p><p><span style="font-variant:small-caps">Esc ;</span><br> Make Language comment (Fortran and C)</p><p><span style="font-variant:small-caps">Esc</span> <code class="verb">\</code><br> Trim whitespace around point</p><p><span style="font-variant:small-caps">Esc !</span><br> Execute shell command</p><p><span style="font-variant:small-caps">Esc $</span><br> Ispell word (unix)</p><p><span style="font-variant:small-caps">Ctrl-X ?</span><br> Show line/column information.</p><p><span style="font-variant:small-caps">‘</span><br> <code class="verb">quoted_insert</code> — insert next char as is (backquote key)</p><p><span style="font-variant:small-caps">Esc s</span><br> Center line.</p><p><span style="font-variant:small-caps">Esc u</span><br> Upcase word.</p><p><span style="font-variant:small-caps">Esc d</span><br> Downcase word.</p><p><span style="font-variant:small-caps">Esc c</span><br> Capitalize word.</p><p><span style="font-variant:small-caps">Esc x</span><br> Get M-x minibuffer prompt with command completion</p><p><span style="font-variant:small-caps">Ctrl-X Ctrl-B</span><br> pop up a list of buffers</p><p><span style="font-variant:small-caps">Ctrl-X Ctrl-C</span><br> exit <span style="font-weight:bold">jed</span></p><p><span style="font-variant:small-caps">Ctrl-X 0</span><br> Delete Current Window</p><p><span style="font-variant:small-caps">Ctrl-X 1</span><br> One Window.</p><p><span style="font-variant:small-caps">Ctrl-X 2</span><br> Split Window.</p><p><span style="font-variant:small-caps">Ctrl-X o</span><br> Other window.</p><p><span style="font-variant:small-caps">Ctrl-X b</span><br> switch to buffer</p><p><span style="font-variant:small-caps">Ctrl-X k</span><br> kill buffer</p><p><span style="font-variant:small-caps">Ctrl-X s</span><br> save some buffers</p><p><span style="font-variant:small-caps">Ctrl-X Esc</span><br> Get <span style="font-family:monospace">S-Lang></span> prompt for interface to the <span style="font-weight:bold">S-Lang</span> interpreter. </p><p><span style="font-variant:small-caps">Esc .</span><br> Find tag (unix ctags compatible)</p><p><span style="font-variant:small-caps">Ctrl-@</span><br> Set Mark (Begin defining a region). Used with a prefix argument aborts the act of defining the region and pops the Mark.</p> <h3 id="sec18" class="subsection">10.1 Undo</h3> <p>One of <span style="font-weight:bold">jed</span>’s nicest features is the ability to undo nearly any change that occurs within a buffer at the touch of a key. If you delete a word, you can undo it. If you delete 10 words in the middle of the buffer, move to the top of the buffer and randomly make changes, you can undo all of that too.</p><p>By default, the <code class="verb">undo</code> function is bound to the key <span style="font-variant:small-caps">Ctrl-_</span> (Ascii 31). Since some terminals are not capable of generating this character, it is also bound to the key sequence <span style="font-variant:small-caps">Ctrl-X</span> u.</p><p>Due to the lack of virtual memory support on IBMPC systems, the <code class="verb">undo</code> function is not enabled on every buffer. In particular, it is not enabled for the <code class="verb">*scratch*</code> buffer. However, it is enabled for any buffer which is associated with a file. A “plus” character on the left hand side of the status line indicates that undo is enabled for the buffer. It is possible to enable undo for any buffer by using the <code class="verb">toggle_undo</code> function.</p> <h3 id="sec19" class="subsection">10.2 Marking Text (Point and Mark)</h3> <p>Many commands work on certain regions of text. A region is defined by the <code class="verb">Point</code> and the <code class="verb">Mark</code> The <code class="verb">Point</code> is the location of the current editing point or cursor position. The <code class="verb">Mark</code> is the location of a mark. The mark is set using the <code class="verb">set_mark_cmd</code> which is bound to <span style="font-variant:small-caps">Ctrl-@</span> (Control-2 or Control-Space on some keyboards). When the mark is set, the <span style="font-family:monospace">m</span> mark indicator will appear on the status line. This indicates that a region is being defined. Moving the cursor (<code class="verb">Point</code>) defines the other end of a region. If the variable <span style="font-family:monospace">HIGHLIGHT</span> is non-zero, <span style="font-weight:bold">jed</span> will highlight the region as it is defined.</p><p>Even without highlighting, it is easy to see where the location of the mark is by using the <code class="verb">exchange</code> command which is bound to <span style="font-variant:small-caps">Ctrl-X</span> <span style="font-variant:small-caps">Ctrl-X</span>. This simply exchanges the <code class="verb">Point</code> and the <code class="verb">Mark</code>. The region is still intact since it is defined only by the <code class="verb">Point</code> and <code class="verb">Mark</code>. Pressing <span style="font-variant:small-caps">Ctrl-X</span> <span style="font-variant:small-caps">Ctrl-X</span> again restores the mark and Point back to their original locations. Try it.</p> <h3 id="sec20" class="subsection">10.3 Tab Issues.</h3> <p>Strictly speaking, <span style="font-weight:bold">jed</span> uses only fixed column tabs whose size is determined by the value of the <code class="verb">TAB</code> variable. Setting the <code class="verb">TAB</code> variable to 0 causes <span style="font-weight:bold">jed</span> to not use tabs as whitespace and to display tabs as <span style="font-variant:small-caps">Ctrl-I</span>. Please note that changing the tab settings on the terminal will have no effect as far as <span style="font-weight:bold">jed</span> is concerned. The <code class="verb">TAB</code> variable is local to each buffer allowing every buffer to have its own tab setting. The variable <code class="verb">TAB_DEFAULT</code> is the tab setting that is given to all newly created buffers. The default value for this variable is 8 which corresponds to eight column tabs.</p><p><span style="font-weight:bold">jed</span> is also able to “simulate” arbitrary tabs as well through the use of user defined tab stops. Calling the function <code class="verb">edit_tab_stops</code> allows the user to interactively set the tab stops. That is, one simply presses <span style="font-variant:small-caps">Esc X</span> to get the <code class="verb">M-x</code> prompt and enters <code class="verb">edit_tab_stops</code>. A window will pop open displaying the current tab settings. To add a tab stop, simply place a <span style="font-variant:small-caps">T</span> in the appropriate column. Use the space bar to remove a tab stop.</p><p>Here an argument is presented in favor of simulated tabs over real tab stops. First, consider what a “tab” really is. A “tab” in a file is nothing more than a character whose ASCII value is 9. For this reason, one also denotes a tab as <code class="verb">^I</code> (<span style="font-variant:small-caps">Ctrl-I</span>). Unlike most other ASCII characters, the effect of the tab character is device dependent and is controlled through the device tab settings. Hence, a file which displays one way on one device may look totally different on another device if the tab settings do not correspond. For this reason, many people avoid tabs altogether and others the adopt “standard” of eight column tabs. Even though people always argue about what the correct tab settings should be, it must be kept in mind that this is primarily a human issue and not a machine issue.</p><p>On a device employing tab stops, a tab will cause the cursor to jump to the position of the next tab stop. Now consider the effect of changing the tab settings. Assume that in one part of a document, text was entered using the first setting and in another part, the second setting was used. When moving from the part of the document where the current tab setting is appropriate to the part where the other tab setting was used will cause the document to look unformatted unless the appropriate tab settings are restored. Wordprocessors store the tab settings in the file with the text so that the tabs may be dynamically changed to eliminate such unwanted behavior. However, text editors such as <span style="font-weight:bold">jed</span>, vi, Emacs, EDT, EVE (TPU), etc, do not store this information in the file. <span style="font-weight:bold">jed</span> avoids this problem by using simulated tabs. When using simulated tabs, tabs are not really used at all. Rather <span style="font-weight:bold">jed</span> inserts the appropriate number of spaces to achieve the desired effect. This also has the advantage of one being able to cut and paste from the part of a document using one tab setting to another part with a different tab setting. This simple operation may lead to unwanted results on some wordprocessors as well as those text editors using real tab stops.</p> <h3 id="sec21" class="subsection">10.4 Searching</h3> <p><span style="font-weight:bold">jed</span> currently has two kinds of searches: ordinary searches and incremental searches. Both types of searches have forward and backward versions. The actual functions for binding purposes are:</p><pre class="verbatim"> search_forward search_backward isearch_forward isearch_backward </pre><p>There is also the <code class="verb">occur</code> function which finds all occurrences of a single word (string). This function has no backwards version. By default it is not bound to any keys, so to use it, <code class="verb">occur</code> must be entered at the <code class="verb">M-x</code> prompt (<span style="font-variant:small-caps">Esc X</span>) or one is always free to bind it to a key.</p><p>In the following only the incremental search is discussed.</p><p>The default type of search in Emacs in the incremental search. However, since this type of search is confusing to the uninitiated, the ordinary type of search has been made the default in <span style="font-weight:bold">jed</span>’s Emacs emulation. For the traditional emacs keybinding, it is up to the user to provide the keybinding.</p><p>As the name suggests, an incremental search performs a search incrementally. That is, as you enter the search string, the editor begins searching right away. For example, suppose you wish to search for the string <span style="font-family:monospace">apple</span>. As soon as the letter <span style="font-variant:small-caps">a</span> is entered into the incremental search prompt, <span style="font-weight:bold">jed</span> will search for the first occurrence of <span style="font-family:monospace">a</span>. Then as soon as the <span style="font-variant:small-caps">p</span> is entered, <span style="font-weight:bold">jed</span> will search from the current point for the string <span style="font-family:monospace">ap</span>, etc. This way, one is able to quickly locate the desired string with only a minimal amount of information.</p><p>Unlike the “ordinary” search, the incremental search is not terminated with the <span style="font-variant:small-caps">Enter</span> key. Hitting the <span style="font-variant:small-caps">Enter</span> key causes <span style="font-weight:bold">jed</span> to search for the next occurrence of the string based on the data currently entered at the prompt. The search is terminated with the <span style="font-variant:small-caps">Esc</span> key.</p><p>Finally, the <span style="font-variant:small-caps">DEL</span> key (<span style="font-variant:small-caps">Ctrl-?</span>) is used to erase the last character entered at the search prompt. In addition to erasing the last character of the search string, <span style="font-weight:bold">jed</span> will return back to the location of the previous match. Erasing all characters will cause the editor to return to the place where the search began. Like many things, this is one of those that is easier to do than explain. Feel free to play around with it.</p> <h3 id="sec22" class="subsection">10.5 Rectangles</h3> <p><span style="font-weight:bold">jed</span> has built-in support for the editing of rectangular regions of text. One corner of rectangle is defined by setting the mark somewhere in the text. The Point (cursor location) defines the opposite corner of the rectangle.</p><p>Once a rectangle is defined, one may use the following functions:</p><p><code class="verb">kill_rect</code><br> Delete text inside the rectangle saving the rectangle in the internal rectangle buffer.</p><p><code class="verb">n_rect</code><br> Push all text in the rectangle to the right outside the rectangle.</p><p><code class="verb">copy_rect</code><br> Copy text inside the rectangle to the internal rectangle buffer.</p><p><code class="verb">blank_rect</code><br> Replace all text inside the rectangle by spaces.</p><p>The function <code class="verb">insert_rect</code> inserts a previously killed or copied rectangle into the text at the Point.</p><p>These functions have no default binding and must be entered into the MiniBuffer by pressing <span style="font-variant:small-caps">Esc X</span> to produce the <code class="verb">M-x</code> prompt.</p> <h3 id="sec23" class="subsection">10.6 Sorting</h3> <p><span style="font-weight:bold">jed</span> is capable of sorting a region of lines using the heapsort algorithm. The region is sorted alphabetically based upon the ASCII values of the characters located within a user defined rectangle in the region. That is, the rectangle simply defines the characters upon what the sort is based. Simply move to the top line of the region and set the mark on the top left corner of the rectangle. Move to the bottom line and place the point at the position which defines the lower right corner of the rectangle. Press <span style="font-variant:small-caps">Esc X</span> to get the <code class="verb">M-x</code> prompt and enter <code class="verb">sort</code> As as example, consider the following data:</p><pre class="verbatim"> Fruit: Quantity: lemons 3 pears 37 peaches 175 apples 200 oranges 56 </pre><p>To sort the data based upon the name, move the Point to the top left corner of the sorting rectangle. In this case, the Point should be moved to the <span style="font-family:monospace">l</span> in the word <span style="font-family:monospace">lemons</span>. Set the mark. Now move to the lower right corner of the rectangle which is immediately after the <span style="font-family:monospace">s</span> in <span style="font-family:monospace">oranges</span>. Pressing <span style="font-variant:small-caps">Esc X</span> and entering <code class="verb">sort</code> yields:</p><pre class="verbatim"> Fruit: Quantity: apples 200 lemons 3 oranges 56 peaches 175 pears 37 </pre><p>Suppose that it is desired to sort by quantity instead. Looking at the original (unsorted) data, move the Point to two spaces before the <span style="font-family:monospace">3</span> on the line containing <span style="font-family:monospace">lemons</span>. The cursor should be right under the <span style="font-family:monospace">u</span> in <span style="font-family:monospace">Quantity</span>. Set the mark. Now move the Point to immediately after <span style="font-family:monospace">56</span> on the <span style="font-family:monospace">oranges</span> line and again press <span style="font-variant:small-caps">Esc X</span> and enter <code class="verb">sort</code>. This yields the desired sort:</p><pre class="verbatim"> Fruit: Quantity: lemons 3 pears 37 oranges 56 peaches 175 apples 200 </pre> <hr> <a href="jed010.html"><img src="previous_motif.svg" alt="Previous"></a> <a href="index.html"><img src="contents_motif.svg" alt="Up"></a> <a href="jed012.html"><img src="next_motif.svg" alt="Next"></a> </body> </html> Save