PageRenderTime 59ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/jEdit/tags/jedit-4-2-pre4/doc/users-guide/text-edit.xml

#
XML | 1197 lines | 1190 code | 2 blank | 5 comment | 0 complexity | 134707bfbc0dda9e6d27a18b4b8f7d52 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. ,<!-- jEdit buffer-local properties: -->
  2. <!-- :tabSize=1:indentSize=1:noTabs=true:wrap=soft:maxLineLen=80: -->
  3. <!-- :xml.root=users-guide.xml: -->
  4. <chapter id="editing"><title>Editing Text</title>
  5. <sect1 id="caret"><title>Moving The Caret</title>
  6. <para>
  7. The simplest way to move the caret is to click the
  8. mouse at the desired location in the text area. The caret can also be moved
  9. using the keyboard.
  10. </para>
  11. <para>
  12. The <keycap>Left</keycap>, <keycap>Right</keycap>, <keycap>Up</keycap> and
  13. <keycap>Down</keycap> keys move the caret in the respective direction, and
  14. the <keycap>Page Up</keycap> and <keycap>Page Down</keycap> keys move the
  15. caret up and down one screenful, respectively.
  16. </para>
  17. <para>
  18. When pressed once, the <keycap>Home</keycap> key moves the caret to the first
  19. non-whitespace character of the current screen line. Pressing it a second
  20. time moves the caret to the beginning of the current buffer line. Pressing it
  21. a third time moves the caret to the first visible line.
  22. </para>
  23. <para>
  24. The <keycap>End</keycap> key behaves in a
  25. similar manner, going to the last non-whitespace character of the current
  26. screen line, the end of
  27. the current buffer line, and finally to the last visible line.
  28. </para>
  29. <para>
  30. If soft wrap is disabled, a <quote>screen line</quote> is the
  31. same as a <quote>buffer line</quote>. If soft wrap is enabled,
  32. a screen line is a section of a newline-delimited buffer line that fits
  33. within the wrap margin width. See <xref linkend="word-wrap"/>.
  34. </para>
  35. <para>
  36. <keycombo><keycap>Control</keycap><keycap>Home</keycap></keycombo> and
  37. <keycombo><keycap>Control</keycap><keycap>End</keycap></keycombo> move the
  38. caret to the beginning and end of the buffer, respectively.
  39. </para>
  40. <para>
  41. More advanced caret movement is covered in
  42. <xref linkend="words" />, <xref linkend="lines" /> and
  43. <xref linkend="paragraphs" />.
  44. </para>
  45. <sidebar><title>The Home and End keys</title>
  46. <para>
  47. If you prefer more traditional behavior for the
  48. <keycap>Home</keycap> and <keycap>End</keycap> keys, you can reassign
  49. the respective keyboard shortcuts in the <guibutton>Shortcuts</guibutton>
  50. pane of the
  51. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>; see <xref linkend="shortcuts-pane"/>.
  52. </para>
  53. <para>
  54. By default, the shortcuts are assigned as follows:
  55. </para>
  56. <itemizedlist>
  57. <listitem><para><keycap>Home</keycap> is bound to <guimenuitem>Smart
  58. Home</guimenuitem>.</para></listitem>
  59. <listitem><para><keycap>End</keycap> is bound to <guimenuitem>Smart
  60. End</guimenuitem>.</para></listitem>
  61. <listitem><para><keycombo><keycap>Shift</keycap> <keycap>Home</keycap>
  62. </keycombo> is bound to <guimenuitem>Select to Smart
  63. Home Position</guimenuitem>.</para></listitem>
  64. <listitem><para><keycombo><keycap>Shift</keycap> <keycap>End</keycap>
  65. </keycombo> is bound to <guimenuitem>Select to Smart
  66. End Position</guimenuitem>.</para></listitem>
  67. </itemizedlist>
  68. <para>
  69. However you can rebind them to anything you want, for example, various
  70. combinations of the following, or indeed any other command or macro:
  71. </para>
  72. <itemizedlist>
  73. <listitem><para><guimenuitem>Go to Start/End of White Space</guimenuitem>.</para></listitem>
  74. <listitem><para><guimenuitem>Go to Start/End of Line</guimenuitem>.</para></listitem>
  75. <listitem><para><guimenuitem>Go to Start/End of Buffer</guimenuitem>.</para>
  76. </listitem>
  77. <listitem><para><guimenuitem>Select to Start/End of White Space
  78. </guimenuitem>.</para></listitem>
  79. <listitem><para><guimenuitem>Select to Start/End of Line</guimenuitem>.</para>
  80. </listitem>
  81. <listitem><para><guimenuitem>Select to Start/End of Buffer</guimenuitem>.</para>
  82. </listitem>
  83. </itemizedlist>
  84. </sidebar>
  85. </sect1>
  86. <sect1 id="selection"><title>Selecting Text</title>
  87. <para>
  88. A <firstterm>selection</firstterm> is a a block of text marked for further
  89. manipulation. Range selections cover text between two points in a buffer, and rectangular selections cover a rectangular area. Several chunks of text can be
  90. selected simultaneously.
  91. </para>
  92. <sect2><title>Range Selection</title>
  93. <para>
  94. Dragging the mouse creates a range selection from where the mouse was
  95. pressed to where it was released.
  96. Holding down <keycap>Shift</keycap> while clicking a location in the
  97. buffer will create a selection from the caret position to the clicked
  98. location.
  99. </para>
  100. <para>
  101. Holding down <keycap>Shift</keycap> in addition to a caret movement key
  102. (<keycap>Left</keycap>, <keycap>Up</keycap>, <keycap>Home</keycap>, etc) will
  103. extend a selection in the specified direction.
  104. </para>
  105. <para>
  106. <guimenu>Edit</guimenu>&gt;<guimenuitem>Select All</guimenuitem> (shortcut:
  107. <keycombo><keycap>Control</keycap><keycap>A</keycap></keycombo>) selects the
  108. entire buffer.
  109. </para>
  110. <para>
  111. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Selection</guisubmenu>&gt;<guimenuitem>Select None</guimenuitem> (shortcut:
  112. <keycap>Escape</keycap>) deactivates the selection.
  113. </para>
  114. </sect2>
  115. <sect2 id="rect-select"><title>Rectangular Selection</title>
  116. <para>
  117. Dragging with the <keycap>Control</keycap> key held down will create a
  118. rectangular selection. Holding down
  119. <keycap>Shift</keycap> and <keycap>Control</keycap> while clicking a
  120. location in the buffer will create a rectangular selection from the caret
  121. position to the clicked location.
  122. </para>
  123. <para>
  124. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  125. Selection</guisubmenu>&gt;<guimenuitem>Rectangular Selection</guimenuitem>
  126. toggles keyboard rectangular selection mode. In this mode, commands that
  127. normally create range selections will create rectangular selections.
  128. A status bar indicator is shown when this mode is enabled.
  129. </para>
  130. <para>
  131. Rectangular selections behave differently than range selections when text is inserted. If the text has more lines than the rectangular selection, the text insertion proceeds as if the rectangular selection was automatically resized to the appropriate height. If the text to insert has less lines than the rectangular selection, the lines are repeated as many times as necessary to fill the selection.
  132. </para>
  133. <para>
  134. It is possible to select a rectangle with zero width but non-zero height.
  135. This can be used to insert a new column between two existing
  136. columns, for example. Such zero-width selections are shown as a thin
  137. vertical line.
  138. </para>
  139. <para>
  140. Range selections and non-zero-width rectangular selections are deactivated after text is inserted, while zero-width rectangular selections are shifted horizontally. This makes them behave like a <quote>tall caret</quote>. For example, to insert a string at a specific column on a number of lines,
  141. select a zero width rectangle at that column, and type the desired string.
  142. </para>
  143. <para>
  144. Rectangles can be deleted, copied, pasted, and operated on using ordinary
  145. editing commands. If necessary, rectangular selections are automatically filled in with whitespace to maintain alignment.
  146. </para>
  147. <para>
  148. Rectangular selections can extend beyond the end of a line into
  149. <quote>virtual space</quote>. Furthermore,
  150. if keyboard rectangular selection mode is on or if the
  151. <keycap>Control</keycap> key is being held down, clicking beyond the
  152. end of a line will insert the appropriate amount of whitespace in order
  153. to position the cursor at the clicked location.
  154. </para>
  155. <note>
  156. <para>
  157. Rectangular selections are implemented using character offsets,
  158. not absolute screen positions, so they might not behave as you might
  159. expect if a proportional-width font is being used or if soft wrap is
  160. enabled. The text area font can be changed in the
  161. <guibutton>Text Area</guibutton> pane of the
  162. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  163. dialog box. For information about soft wrap,
  164. see <xref linkend="word-wrap" />.
  165. </para>
  166. </note>
  167. </sect2>
  168. <sect2 id="multi-select"><title>Multiple Selection</title>
  169. <para>
  170. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  171. Selection</guisubmenu>&gt;<guimenuitem>Multiple Selection</guimenuitem>
  172. (keyboard shortcut: <keycombo><keycap>Control</keycap>
  173. <keycap>\</keycap></keycombo>)
  174. turns multiple selection mode on and
  175. off. In multiple selection mode, multiple fragments of text can be selected
  176. and operated on simultaneously, and the caret can be moved independently
  177. of the selection. The status bar indicates if multiple
  178. selection mode is active; see <xref linkend="status-bar"/>.
  179. </para>
  180. <para>
  181. Various jEdit commands behave differently with multiple selections:
  182. </para>
  183. <itemizedlist>
  184. <listitem><para>Commands that copy text place the contents of
  185. each selection, separated by line breaks, in the specified register.
  186. </para></listitem>
  187. <listitem><para>Commands that insert (or paste) text replace each selection
  188. with the entire text that is being inserted.</para></listitem>
  189. <listitem><para>Commands that filter text (such as <guimenuitem>Spaces to
  190. Tabs</guimenuitem>, <guimenuitem>Range Comment</guimenuitem>,
  191. <guimenuitem>Replace in Selection</guimenuitem>, and so on) behave as if
  192. each block was selected independently, and the command invoked on each in
  193. turn.</para></listitem>
  194. <listitem><para>Line-based commands (such as <guimenuitem>Shift Indent
  195. Left</guimenuitem>, <guimenuitem>Shift Indent Right</guimenuitem>, and
  196. <guimenuitem>Line Comment</guimenuitem>) operate on each line that contains
  197. at least one selection.
  198. </para></listitem>
  199. <listitem><para>Caret movement commands that would normally deactivate the
  200. selection (such as the arrow keys, while <keycap>Shift</keycap> is not being
  201. held down), move the caret, leaving the selection as-is.</para></listitem>
  202. <listitem><para>Some older plugins may not support multiple selection at
  203. all.</para></listitem>
  204. </itemizedlist>
  205. <para>
  206. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  207. Selection</guisubmenu>&gt;<guimenuitem>Select None</guimenuitem>
  208. (shortcut: <keycap>Escape</keycap>) deactivates the selection containing the
  209. caret, if there is one. Otherwise it deactivates all active selections.
  210. </para>
  211. <para>
  212. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  213. Selection</guisubmenu>&gt;<guimenuitem>Invert Selection</guimenuitem>
  214. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  215. <keycap>I</keycap>) selects a set of text chunks such that all text
  216. that was formerly part of a selection is now unselected, and all text that
  217. wasn't, is selected.
  218. </para>
  219. <note>
  220. <para>
  221. Deactivating multiple selection
  222. mode while multiple blocks of text are selected will leave the selections
  223. in place, but you will not be able to add new selections until
  224. multiple selection mode is reactivated.
  225. </para>
  226. </note>
  227. </sect2>
  228. </sect1>
  229. <sect1 id="entering-text"><title>Inserting and Deleting Text</title>
  230. <para>
  231. Text entered at the keyboard is inserted into the buffer. If
  232. overwrite mode is on, one character is deleted from in
  233. front of the caret position for every character that is inserted.
  234. To activate overwrite mode, press <keycap>Insert</keycap>. The caret is
  235. drawn as horizontal line while in overwrite
  236. mode. The status bar also indicates if overwrite mode is active; see
  237. <xref linkend="status-bar"/> for details.
  238. </para>
  239. <para>
  240. Inserting text while there is a selection will replace the selection
  241. with the inserted text.
  242. </para>
  243. <para>
  244. When inserting text, keep in mind that the <keycap>Tab</keycap> and
  245. <keycap>Enter</keycap> keys might
  246. not behave entirely like you expect because of various indentation
  247. features; see <xref linkend="indent" /> for details.
  248. </para>
  249. <para>
  250. The simplest way to delete text is with the
  251. <keycap>Backspace</keycap> and <keycap>Delete</keycap> keys. If nothing is
  252. selected, they delete the character before or after the caret,
  253. respectively. If a selection exists, both delete the
  254. selection.
  255. </para>
  256. <para>
  257. More advanced deletion commands are described in
  258. <xref linkend="words" />, <xref linkend="lines" /> and
  259. <xref linkend="paragraphs" />.
  260. </para>
  261. </sect1>
  262. <sect1 id="undo-redo"><title>Undo and Redo</title>
  263. <para>
  264. <guimenu>Edit</guimenu>&gt;<guimenuitem>Undo</guimenuitem> (shortcut:
  265. <keycombo><keycap>Control</keycap><keycap>Z</keycap></keycombo>) reverses the
  266. most recent editing command. For example, this can be
  267. used to restore unintentionally deleted text. More complicated operations,
  268. such as a search and replace, can also be undone. By default, information
  269. about the last 100 edits is retained; older edits cannot be undone.
  270. The maximum number of undos can be changed in the <guibutton>Editing</guibutton> pane
  271. of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  272. Options</guimenuitem> dialog box; see <xref linkend="editing-pane"/>.
  273. </para>
  274. <para>
  275. If you undo too many changes,
  276. <guimenu>Edit</guimenu>&gt;<guimenuitem>Redo</guimenuitem> (shortcut:
  277. <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>) can restore
  278. the changes again. For example, if some
  279. text was inserted, <guimenuitem>Undo</guimenuitem> will remove it from the
  280. buffer. <guimenuitem>Redo</guimenuitem> will insert it again.
  281. </para>
  282. </sect1>
  283. <sect1 id="words"><title>Working With Words</title>
  284. <para>
  285. <keycombo><keycap>Control</keycap><keycap>Left</keycap></keycombo>
  286. and
  287. <keycombo><keycap>Control</keycap><keycap>Right</keycap></keycombo>
  288. moves the caret a word at
  289. a time. Holding down <keycap>Shift</keycap> in addition to the above
  290. extends the selection a word at a time.
  291. </para>
  292. <para>
  293. A single word can be selected by double-clicking with the mouse,
  294. or using the
  295. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  296. Selection</guisubmenu>&gt;<guimenuitem>Select
  297. Word</guimenuitem> command (shortcut:
  298. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo> <keycap>W</keycap>).
  299. A selection that begins and ends on word boundaries can be created by
  300. double-clicking and dragging.
  301. </para>
  302. <para>
  303. <keycombo><keycap>Control</keycap><keycap>Backspace</keycap></keycombo>
  304. and <keycombo><keycap>Control</keycap><keycap>Delete</keycap></keycombo>
  305. deletes the word
  306. before or after the caret, respectively.
  307. </para>
  308. <para>
  309. <guimenu>Edit</guimenu>&gt;<guimenuitem>Word Count</guimenuitem>
  310. displays a dialog box with the number of characters,
  311. words and lines in the current buffer.
  312. </para>
  313. <para>
  314. <guimenu>Edit</guimenu>&gt;<guimenuitem>Complete Word</guimenuitem> (shortcut:
  315. <keycombo><keycap>Control</keycap><keycap>B</keycap></keycombo>) locates
  316. possible completions for the word at the caret, first by looking in the
  317. current edit mode's syntax highlighting
  318. keyword list, and then in the current buffer for words that begin with the
  319. word at the caret. This serves as a very basic code completion feature.
  320. </para>
  321. <para>
  322. If there is only one completion, it will be inserted into the buffer
  323. immediately.
  324. If multiple completions were found, they will be listed in a popup below
  325. the caret position. To insert a completion from the list, either click it
  326. with the mouse,
  327. or select it using the <keycap>Up</keycap> and <keycap>Down</keycap> keys and
  328. press <keycap>Enter</keycap>, or press a digit to insert one of the first
  329. ten completions (1 is the first completion; 9 is the 9th; 0 is the 10th).
  330. </para>
  331. <para>Typing while the popup is
  332. visible will automatically update the popup and narrow the set of
  333. completions as necessary.
  334. To close the popup without inserting a
  335. completion, press <keycap>Escape</keycap>.
  336. </para>
  337. <sidebar><title>For power users</title>
  338. <para>
  339. The default behavior of the
  340. <keycombo><keycap>Control</keycap><keycap>Left</keycap></keycombo> and
  341. <keycombo><keycap>Control</keycap><keycap>Right</keycap></keycombo> commands is to
  342. stop both at the beginning and the end of each word. However this can be
  343. changed by remapping these keystrokes to alternative actions whose names end
  344. with <guimenuitem>(Eat Whitespace)</guimenuitem> in the
  345. <guibutton>Shortcuts</guibutton> pane of the
  346. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  347. dialog box; see <xref linkend="shortcuts-pane"/>.
  348. </para>
  349. </sidebar>
  350. </sect1>
  351. <sect1 id="lines"><title>Working With Lines</title>
  352. <para>
  353. An entire line can be selected by triple-clicking with the mouse,
  354. or using the
  355. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  356. Selection</guisubmenu>&gt;<guimenuitem>Select
  357. Line</guimenuitem> command (shortcut:
  358. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo> <keycap>L</keycap>).
  359. A selection that begins and ends on line boundaries can be created
  360. by triple-clicking and dragging.
  361. </para>
  362. <para>
  363. <guimenu>Edit</guimenu>&gt;<guimenuitem>Go to Line</guimenuitem> (shortcut:
  364. <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>) prompts
  365. for a line number and moves the caret there.
  366. </para>
  367. <para>
  368. <guimenu>Edit</guimenu>&gt;<guisubmenu>More
  369. Selection</guisubmenu>&gt;<guimenuitem>Select Line Range</guimenuitem>
  370. (shortcut
  371. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  372. <keycombo><keycap>Control</keycap><keycap>L</keycap></keycombo>)
  373. prompts for two line numbers and selects all text between them.
  374. </para>
  375. <para>
  376. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Delete
  377. Line</guimenuitem>
  378. (shortcut: <keycombo><keycap>Control</keycap><keycap>D</keycap></keycombo>)
  379. deletes the current line.
  380. </para>
  381. <para>
  382. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Delete
  383. to Start Of Line</guimenuitem>
  384. (shortcut:
  385. <keycombo><keycap>Control</keycap><keycap>Shift</keycap><keycap>Backspace</keycap></keycombo>)
  386. deletes all text from the start of the current line to the caret.
  387. </para>
  388. <para>
  389. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Delete
  390. to End Of Line</guimenuitem>
  391. (shortcut:
  392. <keycombo><keycap>Control</keycap><keycap>Shift</keycap><keycap>Delete</keycap></keycombo>) deletes
  393. all text from the caret to the end of the current line.
  394. </para>
  395. <para>
  396. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Join
  397. Lines</guimenuitem> (shortcut:
  398. <keycombo><keycap>Control</keycap><keycap>J</keycap></keycombo>)
  399. removes any whitespace from the start of the next line and joins it with
  400. the current line.
  401. The caret is moved to the position where the two lines were joined.
  402. For example, if you invoke <guimenuitem>Join Lines</guimenuitem>
  403. with the caret on the first line of the following Java code:
  404. </para>
  405. <screen>new Widget(Foo
  406. .createDefaultFoo());</screen>
  407. <para>
  408. It will be changed to:
  409. </para>
  410. <screen>new Widget(Foo.createDefaultFoo());</screen>
  411. </sect1>
  412. <sect1 id="paragraphs"><title>Working With Paragraphs</title>
  413. <para>
  414. As far as jEdit is concerned, <quote>paragraphs</quote> are delimited by
  415. double newlines. This is also how <application>TeX</application>
  416. defines a paragraph. Note that jEdit doesn't parse HTML files for
  417. <quote>&lt;P&gt;</quote> tags, nor does it support paragraphs delimited only
  418. by a leading indent.
  419. </para>
  420. <para>
  421. <keycombo><keycap>Control</keycap><keycap>Up</keycap></keycombo> and
  422. <keycombo><keycap>Control</keycap><keycap>Down</keycap></keycombo>
  423. move the caret to the previous and next paragraph, respectively.
  424. Holding down <keycap>Shift</keycap> in addition to the above
  425. extends the selection a paragraph at a time.
  426. </para>
  427. <para>
  428. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Selection</guisubmenu>&gt;<guimenuitem>Select
  429. Paragraph</guimenuitem> (shortcut:
  430. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  431. <keycap>P</keycap>)
  432. selects the paragraph containing the caret.
  433. </para>
  434. <para>
  435. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Format
  436. Paragraph</guimenuitem> (shortcut:
  437. <keycombo><keycap>Control</keycap><keycap>E</keycap>
  438. </keycombo> <keycap>F</keycap>) splits and joins lines in the current
  439. paragraph to make it fit within the wrap column position. See
  440. <xref linkend="word-wrap" /> for information and word wrap and
  441. changing the wrap column.
  442. </para>
  443. <para>
  444. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Delete
  445. Paragraph</guimenuitem> (shortcut:
  446. <keycombo><keycap>Control</keycap><keycap>E</keycap>
  447. </keycombo> <keycap>D</keycap>)
  448. deletes the paragraph containing the caret.
  449. </para>
  450. </sect1>
  451. <sect1 id="word-wrap"><title>Wrapping Long Lines</title>
  452. <para>
  453. The <firstterm>word wrap</firstterm> feature splits lines at word
  454. boundaries in
  455. order to fit text within a specified wrap margin.
  456. The wrap margin
  457. position is indicated in the text are as a faint blue vertical line.
  458. There are two <quote>wrap modes</quote>, <quote>soft</quote> and
  459. <quote>hard</quote>; they are described below. The wrap mode can be
  460. changed in one of the following ways:
  461. </para>
  462. <itemizedlist>
  463. <listitem><para>On a global or mode-specific
  464. basis in the
  465. <guibutton>Editing</guibutton> pane
  466. of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  467. dialog box. See <xref linkend="editing-pane" />.</para></listitem>
  468. <listitem><para>In the current buffer
  469. for the duration of the editing session in the
  470. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  471. dialog box. See <xref linkend="buffer-opts" />.
  472. </para></listitem>
  473. <listitem><para>In the current buffer
  474. for future editing sessions by placing
  475. the following in one of the first or last 10 lines of the buffer, where
  476. <replaceable>mode</replaceable> is either <quote>none</quote>, <quote>soft</quote> or
  477. <quote>hard</quote>, and
  478. <replaceable>column</replaceable> is the desired wrap margin:
  479. </para>
  480. <screen>:wrap=<replaceable>mode</replaceable>:maxLineLen=<replaceable>column</replaceable>:</screen>
  481. </listitem>
  482. </itemizedlist>
  483. <sect2><title>Soft Wrap</title>
  484. <para>
  485. In soft wrap mode, lines are automatically wrapped when displayed on screen.
  486. Newlines are not inserted at the wrap positions, and the wrapping is
  487. automatically updated when text is inserted or removed.
  488. </para>
  489. <para>
  490. If end of line markers are enabled in the <guibutton>Text Area</guibutton>
  491. pane of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  492. dialog box, a colon (<quote>:</quote>) is painted at the end of wrapped lines. See <xref linkend="text-area-pane"/>.
  493. </para>
  494. </sect2>
  495. <sect2><title>Hard Wrap</title>
  496. <para>
  497. In hard wrap mode,
  498. inserting text at the end of a line will automatically break the line if
  499. it extends beyond the wrap margin. Inserting or removing text in the middle
  500. of a line has no effect, however text can be re-wrapped using the
  501. <guimenu>Edit</guimenu>&gt;<guisubmenu>Text</guisubmenu>&gt;<guimenuitem>Format
  502. Paragraph</guimenuitem> command. See <xref linkend="paragraphs"/>.
  503. </para>
  504. <para>
  505. Hard wrap is implemented using character offsets, not screen
  506. positions, so it might not behave like you expect if a
  507. proportional-width font is being used. The text area font can be changed in the
  508. <guibutton>Text Area</guibutton> pane of the
  509. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  510. dialog box.
  511. </para>
  512. </sect2>
  513. </sect1>
  514. <sect1 id="scrolling"><title>Scrolling</title>
  515. <para>
  516. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Scroll to
  517. Current Line</guimenuitem> (shortcut:
  518. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  519. <keycombo><keycap>Control</keycap><keycap>J</keycap></keycombo>) scrolls the
  520. text area in order to make the caret visible, if necessary. It does nothing if the
  521. caret is already visible.
  522. </para>
  523. <para>
  524. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Center Caret
  525. on Screen</guimenuitem> (shortcut:
  526. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  527. <keycombo><keycap>Control</keycap><keycap>I</keycap></keycombo>)
  528. moves the caret to the
  529. line in the middle of the screen.
  530. </para>
  531. <para>
  532. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Line
  533. Scroll Up</guimenuitem> (shortcut:
  534. <keycombo><keycap>Control</keycap><keycap>'</keycap></keycombo>)
  535. scrolls the text area up by one line.
  536. </para>
  537. <para>
  538. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Line
  539. Scroll Down</guimenuitem> (shortcut:
  540. <keycombo><keycap>Control</keycap><keycap>/</keycap></keycombo>) scrolls the
  541. text area down by one line.
  542. </para>
  543. <para>
  544. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Page
  545. Scroll Up</guimenuitem> (shortcut:
  546. <keycombo><keycap>Alt</keycap><keycap>'</keycap></keycombo>) scrolls the text
  547. area up by one screenful.
  548. </para>
  549. <para>
  550. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Page
  551. Scroll Down</guimenuitem> (shortcut:
  552. <keycombo><keycap>Alt</keycap><keycap>/</keycap></keycombo>) scrolls the text
  553. area down by one screenful.
  554. </para>
  555. <para>
  556. The above scrolling commands differ from the caret movement commands
  557. in that they don't actually move the caret; they just change the
  558. scroll bar position.
  559. </para>
  560. <para>
  561. <guimenu>View</guimenu>&gt;<guisubmenu>Scrolling</guisubmenu>&gt;<guimenuitem>Synchronized
  562. Scrolling</guimenuitem> is a check box menu item. If it is selected,
  563. scrolling one text area in a split view will scroll all other text areas
  564. in the view. Has no effect if the view is not split.
  565. </para>
  566. <sidebar><title>Mouse Wheel Scrolling</title>
  567. <para>
  568. If you have a mouse with a scroll wheel and are running Java 2
  569. version 1.4, you can use the
  570. wheel to scroll up and down in the text area. Various modifier keys
  571. change the action of the wheel:
  572. </para>
  573. <itemizedlist>
  574. <listitem><para><keycap>Shift</keycap> - scrolls an entire page at a time.</para></listitem>
  575. <listitem><para><keycap>Control</keycap> - scrolls a single line at a time.</para></listitem>
  576. <listitem><para><keycap>Alt</keycap> - moves the caret up and down instead of scrolling.</para></listitem>
  577. <listitem><para><keycombo><keycap>Alt</keycap><keycap>Shift</keycap></keycombo>
  578. - extends the selection up and down instead of scrolling.</para></listitem>
  579. </itemizedlist>
  580. </sidebar>
  581. </sect1>
  582. <sect1 id="text-transfer"><title>Transferring Text</title>
  583. <para>
  584. jEdit provides a rich set of commands for moving and copying text. Commands
  585. are provided for moving chunks of text from buffers to
  586. <firstterm>registers</firstterm> and vice-versa. A register is a holding area
  587. for an arbitrary length of text, with a single-character name.
  588. The system clipboard is mapped to the register named <filename>$</filename>.
  589. jEdit offers clipboard-manipulation commands similar
  590. to those found in other applications, in addition to a more flexible
  591. set of commands for working with registers directly.
  592. </para>
  593. <sect2><title>The Clipboard</title>
  594. <para>
  595. <guimenu>Edit</guimenu>&gt;<guimenuitem>Cut</guimenuitem>
  596. (shortcut: <keycombo><keycap>Control</keycap><keycap>X</keycap></keycombo>)
  597. places the selected text in the clipboard and removes it from the buffer.
  598. </para>
  599. <para>
  600. <guimenu>Edit</guimenu>&gt;<guimenuitem>Copy</guimenuitem>
  601. (shortcut: <keycombo><keycap>Control</keycap><keycap>C</keycap></keycombo>)
  602. places the selected text in the clipboard and leaves it in the buffer.
  603. </para>
  604. <para>
  605. <guimenu>Edit</guimenu>&gt;<guimenuitem>Paste</guimenuitem>
  606. (shortcut: <keycombo><keycap>Control</keycap><keycap>V</keycap></keycombo>)
  607. inserts the clipboard contents in place of the selection (or at the
  608. caret position, if there is no selection).
  609. </para>
  610. <para>
  611. The <guimenuitem>Cut</guimenuitem> and <guimenuitem>Copy</guimenuitem>
  612. commands replace the old clipboard contents with the selected text.
  613. There are two alternative commands which add the selection at the end of
  614. the existing clipboard contents, instead of replacing it.
  615. </para>
  616. <para>
  617. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Cut Append</guimenuitem>
  618. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  619. <keycombo><keycap>Control</keycap><keycap>U</keycap></keycombo>)
  620. appends the selected text to the clipboard, then removes it from the
  621. buffer. After this command has been invoked, the clipboard will consist of
  622. the former clipboard contents, followed by a newline, followed by the
  623. selected text.
  624. </para>
  625. <para>
  626. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Copy Append</guimenuitem>
  627. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  628. <keycombo><keycap>Control</keycap><keycap>A</keycap></keycombo>)
  629. is the same as <guimenuitem>Cut Append</guimenuitem> except it does not
  630. remove the selection from the buffer.
  631. </para>
  632. </sect2>
  633. <sect2 id="quick-copy"><title>Quick Copy</title>
  634. <para>
  635. Quick copy is disabled by default, but it can be enabled in the
  636. <guibutton>Text Area</guibutton> pane of the
  637. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  638. dialog box.
  639. </para>
  640. <para>
  641. The quick copy feature enables the following behavior:
  642. </para>
  643. <itemizedlist>
  644. <listitem><para>
  645. Clicking the middle mouse button in the text area inserts the most recently
  646. selected text at the clicked location.
  647. If you only have a two-button mouse, you can click the left mouse button
  648. while holding down <keycap>Alt</keycap> instead of middle-clicking.
  649. </para></listitem>
  650. <listitem><para>
  651. Dragging with the middle mouse button
  652. creates a selection without moving the
  653. caret. As soon as the mouse button is released, the selected text is
  654. inserted at the caret position and the selection is deactivated.
  655. A message is shown in the status bar while text is being selected to
  656. remind you that this is not an ordinary selection.
  657. </para></listitem>
  658. <listitem><para>
  659. Holding down <keycap>Shift</keycap> while clicking the middle mouse
  660. button will duplicate text between the caret and the clicked location.
  661. </para></listitem>
  662. <listitem><para>
  663. Holding down <keycap>Control</keycap> while clicking the middle mouse
  664. button on a bracket will insert all text in that bracket's scope at the
  665. caret position.
  666. </para></listitem>
  667. </itemizedlist>
  668. <para>
  669. Quick copy is implemented by storing the most recently selected text
  670. in the register named <filename>%</filename>.
  671. </para>
  672. <para>
  673. If jEdit is being run under Java 2 version 1.4 on Unix, you will be
  674. able to transfer text with other X Windows applications using the
  675. quick copy feature. On other platforms and Java versions, the contents
  676. of the quick copy register are only accessible from within jEdit.
  677. </para>
  678. </sect2>
  679. <sect2 id="registers"><title>General Register Commands</title>
  680. <para>
  681. These commands require more keystrokes than the two methods shown above,
  682. but they can operate on any register, allowing an arbitrary number of
  683. text chunks to be retained at a time.
  684. </para>
  685. <para>
  686. Each command prompts for a single-character register name to be entered
  687. after being invoked.
  688. Pressing <keycap>Escape</keycap> instead of specifying a register name
  689. will cancel the operation.
  690. </para>
  691. <para>
  692. Note that the content of registers other than the clipboard and
  693. quick copy text are automatically saved between jEdit sessions.
  694. </para>
  695. <para>
  696. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Cut
  697. to Register</guimenuitem>
  698. (shortcut: <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>
  699. <keycombo><keycap>Control</keycap><keycap>X</keycap></keycombo>
  700. <keycap><replaceable>key</replaceable></keycap>)
  701. stores the selected text in the specified
  702. register, removing it from the buffer.
  703. </para>
  704. <para>
  705. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Copy
  706. to Register</guimenuitem>
  707. (shortcut: <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>
  708. <keycombo><keycap>Control</keycap><keycap>C</keycap></keycombo>
  709. <keycap><replaceable>key</replaceable></keycap>)
  710. stores the selected text in the specified
  711. register, leaving it in the buffer.
  712. </para>
  713. <para>
  714. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Cut
  715. Append to Register</guimenuitem>
  716. (shortcut: <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>
  717. <keycombo><keycap>Control</keycap><keycap>U</keycap></keycombo>
  718. <keycap><replaceable>key</replaceable></keycap>)
  719. adds the selected text to the existing contents of the specified
  720. register, and removes it from the buffer.
  721. </para>
  722. <para>
  723. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Copy
  724. Append to Register</guimenuitem>
  725. (shortcut: <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>
  726. <keycombo><keycap>Control</keycap><keycap>A</keycap></keycombo>
  727. <keycap><replaceable>key</replaceable></keycap>)
  728. adds the selected text to the existing contents of the specified
  729. register, without removing it from the buffer.
  730. </para>
  731. <para>
  732. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Paste
  733. from Register</guimenuitem>
  734. (shortcut: <keycombo><keycap>Control</keycap><keycap>R</keycap></keycombo>
  735. <keycombo><keycap>Control</keycap><keycap>V</keycap></keycombo>
  736. <keycap><replaceable>key</replaceable></keycap>)
  737. replaces the selection with the
  738. contents of the specified register.
  739. </para>
  740. <para>
  741. The last two commands display dialog boxes instead of prompting for a
  742. register name.
  743. </para>
  744. <para>
  745. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Paste Previous</guimenuitem>
  746. (shortcut:
  747. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  748. <keycombo><keycap>Control</keycap><keycap>V</keycap></keycombo>)
  749. displays a dialog box listing recently copied and
  750. pasted text. By default, the last 20 strings are remembered; this can be
  751. changed in the <guibutton>General</guibutton> pane of the
  752. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  753. dialog box; see <xref linkend="global-opts" />.
  754. </para>
  755. <para>
  756. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>Paste Deleted</guimenuitem>
  757. (shortcut:
  758. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  759. <keycombo><keycap>Control</keycap><keycap>Y</keycap></keycombo>) is not really a register command; it
  760. displays a dialog box listing recently deleted text. As with the <guimenuitem>Paste Previous</guimenuitem> dialog box, the last 20 strings are listed by default.
  761. </para>
  762. <para>
  763. <guimenu>Edit</guimenu>&gt;<guisubmenu>More Clipboard</guisubmenu>&gt;<guimenuitem>View
  764. Registers</guimenuitem> displays a dialog box for
  765. viewing the contents of registers (including the clipboard).
  766. </para>
  767. </sect2>
  768. </sect1>
  769. <sect1 id="markers"><title>Markers</title>
  770. <para>
  771. A <firstterm>marker</firstterm> is a pointer to a specific location within
  772. a buffer, which may or may not have a single-character <firstterm>shortcut</firstterm> associated with it.
  773. Markers are persistent; they are saved to
  774. <filename>.<replaceable>filename</replaceable>.marks</filename>, where
  775. <filename><replaceable>filename</replaceable></filename> is the name of the
  776. buffer. (The dot prefix
  777. makes the markers file hidden on Unix systems.) Marker
  778. saving can be
  779. disabled in the <guibutton>General</guibutton> pane of the
  780. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  781. dialog box; see <xref linkend="general-pane" />.
  782. </para>
  783. <para>
  784. <guimenu>Markers</guimenu>&gt;<guimenuitem>Add/Remove Marker</guimenuitem>
  785. (shortcut:
  786. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  787. <keycombo><keycap>Control</keycap><keycap>M</keycap></keycombo>) adds a
  788. marker without a shortcut pointing to the current line. If a marker is
  789. already set on the current line, the marker is removed instead.
  790. If text is selected,
  791. markers are added to the first and last line of each selection.
  792. </para>
  793. <para>
  794. <guimenu>Markers</guimenu>&gt;<guimenuitem>Remove All Markers</guimenuitem>
  795. removes all markers set in the current buffer.
  796. </para>
  797. <para>
  798. Markers are listed in the <guimenu>Markers</guimenu> menu; selecting a marker
  799. from this menu will move the caret to its location.
  800. </para>
  801. <para>
  802. <guimenu>Markers</guimenu>&gt;<guimenuitem>Go to Previous
  803. Marker</guimenuitem>
  804. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  805. <keycombo><keycap>Control</keycap><keycap>,</keycap></keycombo>) goes
  806. to the marker immediately before the caret position.
  807. </para>
  808. <para>
  809. <guimenu>Markers</guimenu>&gt;<guimenuitem>Go to Next Marker</guimenuitem>
  810. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  811. <keycombo><keycap>Control</keycap><keycap>.</keycap></keycombo>)
  812. goes to the marker immediately after the caret position.
  813. </para>
  814. <para>Markers with shortcuts allow for quicker keyboard-based navigation.
  815. The following commands all prompt for a single-character shortcut when
  816. invoked. Pressing <keycap>Escape</keycap>
  817. instead of specifying a shortcut will cancel the operation.
  818. </para>
  819. <para>
  820. <guimenu>Markers</guimenu>&gt;<guimenuitem>Add Marker With
  821. Shortcut</guimenuitem>
  822. (shortcut: <keycombo><keycap>Control</keycap><keycap>T</keycap></keycombo>
  823. <keycap><replaceable>key</replaceable></keycap>) adds a marker with the
  824. specified shortcut. If marker with that shortcut
  825. already exists, it will remain in the buffer but lose its shortcut.
  826. </para>
  827. <para>
  828. <guimenu>Markers</guimenu>&gt;<guimenuitem>Go to Marker</guimenuitem>
  829. (shortcut: <keycombo><keycap>Control</keycap><keycap>Y</keycap></keycombo>
  830. <keycap><replaceable>key</replaceable></keycap>) moves the caret to
  831. the location of the marker with the specified shortcut.
  832. </para>
  833. <para>
  834. <guimenu>Markers</guimenu>&gt;<guimenuitem>Select to Marker</guimenuitem>
  835. (shortcut: <keycombo><keycap>Control</keycap><keycap>U</keycap></keycombo>
  836. <keycap><replaceable>key</replaceable></keycap>) creates a selection from
  837. the caret location to the marker with the specified shortcut.
  838. </para>
  839. <para>
  840. <guimenu>Markers</guimenu>&gt;<guimenuitem>Swap Caret and
  841. Marker</guimenuitem> (shortcut:
  842. <keycombo><keycap>Control</keycap><keycap>U</keycap></keycombo>
  843. <keycap><replaceable>key</replaceable></keycap>)
  844. moves the caret to the location of the marker with the specified shortcut,
  845. and reassigns the marker to point to the former caret location. Invoke
  846. this command multiple times to flip between two locations in the buffer.
  847. </para>
  848. <para>
  849. Lines which contain markers are indicated in the gutter with a highlight.
  850. Moving the mouse over the highlight displays a tool tip showing the marker's
  851. shortcut, if it has one. See <xref linkend="textarea" /> for information
  852. about the gutter.
  853. </para>
  854. </sect1>
  855. <sect1 id="search-replace"><title>Search and Replace</title>
  856. <sect2><title>Searching For Text</title>
  857. <para>
  858. <guimenu>Search</guimenu>&gt;<guimenuitem>Find</guimenuitem> (shortcut:
  859. <keycombo><keycap>Control</keycap><keycap>F</keycap></keycombo>) displays
  860. the search and replace dialog box.
  861. </para>
  862. <para>
  863. The search string can be entered in the <guibutton>Search for</guibutton>
  864. text field. This text field remembers previously entered strings; see
  865. <xref linkend="history" /> for details.
  866. </para>
  867. <para>
  868. If text was selected in the text area and the selection
  869. does not span a line break, the selected text becomes the default search
  870. string.
  871. </para>
  872. <para>
  873. If the selection spans a line break, the
  874. <guibutton>Search in Selection</guibutton>
  875. and <guibutton>HyperSearch</guibutton>
  876. buttons will be pre-selected, and the search string field will be
  877. initially blank. (See <xref linkend="hypersearch"/> for information about
  878. the HyperSearch feature.)
  879. <!-- Note that finding the next or previous
  880. occurrence cannot be constrained to a selected range; only
  881. replacement and HyperSearch can be (see <xref linkend="hypersearch" />). -->
  882. </para>
  883. <para>
  884. Selecting the <guibutton>Ignore
  885. case</guibutton> check box makes the search case insensitive -
  886. for example, searching for
  887. <quote>Hello</quote> will match <quote>hello</quote>, <quote>HELLO</quote>
  888. and <quote>HeLlO</quote>.
  889. </para>
  890. <para>
  891. Selecting the <guibutton>Regular expressions</guibutton> check
  892. box allows a regular expression to be used in the search string. Regular
  893. expressions can
  894. match inexact sequences of text that optionally span more than one line.
  895. Regular expression syntax is described in
  896. <xref linkend="regexps" />.
  897. </para>
  898. <para>
  899. The <guibutton>Backward</guibutton> and <guibutton>Forward</guibutton>
  900. buttons specify the search direction.
  901. Note that regular expressions can only be used when
  902. searching in a forward direction.
  903. </para>
  904. <para>
  905. Clicking <guibutton>Find</guibutton> will locate the next occurrence of
  906. the search string (or previous occurrence, if
  907. searching backwards). If the
  908. <guibutton>Keep dialog</guibutton> check box is selected, the dialog box
  909. will remain open after the search string has been located; otherwise,
  910. it will close.
  911. </para>
  912. <para>
  913. If no occurrences could be found and the
  914. <guibutton>Auto wrap</guibutton> check box is selected, the search will
  915. automatically restart from the beginning of the buffer (or the end, if
  916. searching backwards).
  917. If <guibutton>Auto wrap</guibutton> is not selected, a confirmation dialog
  918. box is shown before restarting the search.
  919. </para>
  920. <para>
  921. <guimenu>Search</guimenu>&gt;<guimenuitem>Find Next</guimenuitem> (shortcut:
  922. <keycombo><keycap>Control</keycap><keycap>G</keycap></keycombo>) locates the
  923. next occurrence of the most recent search string without displaying the
  924. search and replace dialog box.
  925. </para>
  926. <para>
  927. <guimenu>Search</guimenu>&gt;<guimenuitem>Find Previous</guimenuitem>
  928. (shortcut: <keycombo><keycap>Control</keycap><keycap>H</keycap></keycombo>)
  929. locates the previous occurrence of the most recent search string without
  930. displaying the search and replace dialog box.
  931. </para>
  932. </sect2>
  933. <sect2><title>Replacing Text</title>
  934. <para>
  935. The replace string text field of the search dialog
  936. remembers previously entered strings;
  937. see <xref linkend="history" /> for details.
  938. </para>
  939. <para>
  940. Clicking <guibutton>Replace &amp; Find</guibutton> will perform a
  941. replacement in the current selection and locate the next occurrence of the
  942. search string. Clicking <guibutton>Replace All</guibutton> will replace all
  943. occurrences of the search string with the replacement string in the current
  944. search scope (which is either the selection, the current buffer, or a set of
  945. buffers, as specified in the search and replace dialog box).
  946. </para>
  947. <para>
  948. Occurrences of the search string can be replaced with either a replacement
  949. string, or the return value of a BeanShell script snippet. Two radio buttons
  950. in the search and replace dialog box select between the two replacement
  951. modes, which are described in detail below.
  952. </para>
  953. <sect3><title>Text Replace</title>
  954. <para>
  955. If the <guibutton>Text</guibutton> button is selected,
  956. the search string is simply replaced with the replacement
  957. string.
  958. </para>
  959. <para>
  960. If regular expressions are enabled, positional parameters
  961. (<literal>$0</literal>, <literal>$1</literal>, <literal>$2</literal>, and so
  962. on) can be used to insert the contents of matched subexpressions in the
  963. replacement string; see <xref linkend="regexps" /> for more information.
  964. </para>
  965. <para>
  966. If the search is case-insensitive, jEdit attempts to modify the
  967. case of the replacement string to match that of the particular instance
  968. of the search string being replaced. For example, searching
  969. for <quote>label</quote> and replacing it with <quote>text</quote>, will
  970. perform the following replacements:
  971. </para>
  972. <itemizedlist>
  973. <listitem><para><quote>String label</quote> would become <quote>String text</quote>
  974. </para></listitem>
  975. <listitem><para><quote>setLabel</quote> would become <quote>setText</quote>
  976. </para></listitem>
  977. <listitem><para><quote>DEFAULT_LABEL</quote> would become <quote>DEFAULT_TEXT</quote>
  978. </para></listitem>
  979. </itemizedlist>
  980. </sect3>
  981. <sect3><title>BeanShell Replace</title>
  982. <para>
  983. In BeanShell replacement mode, the search string is replaced with the return
  984. value of a BeanShell snippet. The following predefined variables can be
  985. referenced in the snippet:
  986. </para>
  987. <itemizedlist><listitem><para><varname>_0</varname> -- the text to be
  988. replaced</para>
  989. </listitem><listitem><para><varname>_1</varname> - <varname>_9</varname> --
  990. if regular expressions are enabled, these contain the values of matched
  991. subexpressions.
  992. </para></listitem></itemizedlist>
  993. <para>
  994. BeanShell syntax and features are covered in great detail in
  995. <xref linkend="writing-macros-part" />, but here are some examples:
  996. </para>
  997. <informalexample>
  998. <para>
  999. To replace each occurrence of <quote>Windows</quote> with <quote>Linux</quote>,
  1000. and each occurrence of <quote>Linux</quote> with <quote>Windows</quote>,
  1001. search for the following regular expression:
  1002. </para>
  1003. <programlisting>(Windows|Linux)</programlisting>
  1004. <para>
  1005. Replacing it with the following BeanShell snippet:
  1006. </para>
  1007. <programlisting>_1.equals("Windows") ? "Linux" : "Windows"</programlisting>
  1008. </informalexample>
  1009. <informalexample>
  1010. <para>
  1011. To convert all HTML tags to lower case, search
  1012. for the following regular expression:
  1013. </para>
  1014. <programlisting><![CDATA[<(.*?)>]]></programlisting>
  1015. <para>
  1016. Replacing it with the following BeanShell snippet:
  1017. </para>
  1018. <programlisting><![CDATA["<" + _1.toLowerCase() + ">"]]></programlisting>
  1019. </informalexample>
  1020. <informalexample>
  1021. <para>
  1022. To replace arithmetic expressions contained in curly braces with the
  1023. result of evaluating the expression,
  1024. search for the following regular expression:
  1025. </para>
  1026. <programlisting><![CDATA[\{(.+?)\}]]></programlisting>
  1027. <para>
  1028. Replacing it with the following BeanShell snippet:
  1029. </para>
  1030. <programlisting><![CDATA[eval(_1)]]></programlisting>
  1031. </informalexample>
  1032. <para>
  1033. These examples only scratch the surface; the possibilities are endless.
  1034. </para>
  1035. </sect3>
  1036. </sect2>
  1037. <sect2 id="hypersearch"><title>HyperSearch</title>
  1038. <para>
  1039. If the <guibutton>HyperSearch</guibutton> check box in the search and
  1040. replace dialog box is selected, clicking <guibutton>Find</guibutton>
  1041. lists all occurrences of the search string, instead of locating the next
  1042. match.
  1043. </para>
  1044. <para>
  1045. HyperSearch results are shown in a new window;
  1046. the window can be set to dock into the view
  1047. in the <guibutton>Docking</guibutton> pane of the
  1048. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  1049. dialog box; see <xref linkend="docking" />.
  1050. </para>
  1051. <para>
  1052. If the <guibutton>Multiple results</guibutton> check box is selected in
  1053. the results window, past search results are retained.
  1054. </para>
  1055. <para>
  1056. Running searches can be stopped in the
  1057. <guimenu>Utilities</guimenu>&gt;<guisubmenu>Troubleshooting</guisubmenu>&gt;<guimenuitem>I/O Progress
  1058. Monitor</guimenuitem> dialog box.
  1059. </para>
  1060. </sect2>
  1061. <sect2><title>Multiple File Search</title>
  1062. <para>
  1063. Search and replace commands can be performed over an arbitrary set of files
  1064. in one step. The set of files to search is selected with a set of buttons in
  1065. the search dialog box.
  1066. </para>
  1067. <para>
  1068. If the <guibutton>Current buffer</guibutton> button is selected, only the
  1069. current buffer is searched. This is the default behavior.
  1070. </para>
  1071. <para>
  1072. If the <guibutton>All buffers</guibutton> button is selected, all open
  1073. buffers whose names match the glob pattern
  1074. entered in the <guibutton>Filter</guibutton> text field will be searched.
  1075. See <xref linkend="globs" /> for more information about glob patterns.
  1076. </para>
  1077. <para>
  1078. If the <guibutton>Directory</guibutton> radio button is selected, all files
  1079. contained in the specified directory whose names match the glob will be
  1080. searched. The
  1081. directory to search in can either be entered in the
  1082. <guibutton>Directory</guibutton> text field, or chosen in a file selector
  1083. dialog box by clicking the <guibutton>Choose</guibutton> button next to
  1084. the field.
  1085. If the <guibutton>Search subdirectories</guibutton> check box is selected,
  1086. all subdirectories of the specified directory will also be searched. Keep
  1087. in mind that searching through directories containing many files can take
  1088. a long time.
  1089. </para>
  1090. <para>
  1091. The <guibutton>Directory</guibutton> and <guibutton>Filter</guibutton>
  1092. text fields remember previously entered strings; see <xref linkend="history" />
  1093. for details.
  1094. </para>
  1095. <para>
  1096. Note that clicking the <guibutton>All Buffers</guibutton> or
  1097. <guibutton>Directory</guibutton> radio buttons also selects the
  1098. <guibutton>HyperSearch</guibutton> check box
  1099. since that is what you would want, most of the time.
  1100. However, normal match-by-match searching is supported for multiple files as
  1101. well.
  1102. </para>
  1103. <para>
  1104. Two convenience commands are provided for performing multiple file searches.
  1105. </para>
  1106. <para>
  1107. <guimenu>Search</guimenu>&gt;<guimenuitem>Search in Open
  1108. Buffers</guimenuitem> (shortcut:
  1109. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  1110. <keycombo><keycap>Control</keycap><keycap>B</keycap></keycombo>) displays
  1111. the search dialog box and selects the <guibutton>All
  1112. buffers</guibutton> button.
  1113. </para>
  1114. <para>
  1115. <guimenu>Search</guimenu>&gt;<guimenuitem>Search in Directory</guimenuitem>
  1116. (shortcut:
  1117. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  1118. <keycombo><keycap>Control</keycap><keycap>D</keycap></keycombo>) displays
  1119. the search dialog box and selects the
  1120. <guibutton>Directory</guibutton> button.
  1121. </para>
  1122. </sect2>
  1123. <sect2 id="search-bar"><title>The Search Bar</title>
  1124. <para>
  1125. The search bar feature provides a convenient way to search in the current
  1126. buffer without
  1127. opening the search dialog box. The search bar does not support replacement or multiple file. Previously entered strings can be recalled in the
  1128. search bar with the <keycap>Up</keycap> and <keycap>Down</keycap> arrow
  1129. keys; see <xref linkend="history" />.
  1130. </para>
  1131. <para>
  1132. By default, the search bar remains hidden until one of the quick search
  1133. commands (described below) is invoked; however you can choose to have it
  1134. always visible in the <guibutton>View</guibutton> pane of the
  1135. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  1136. dialog box; see <xref linkend="view-pane"/>.
  1137. </para>
  1138. <para>
  1139. <guimenu>Search</guimenu>&gt;<guimenuitem>Incremental Search Bar</guimenuitem>
  1140. (shortcut: <keycombo><keycap>Control</keycap><keycap>,</keycap></keycombo>)
  1141. displays the search bar if necessary, and gives it keyboard focus.
  1142. If this command is invoked while there is a selection, the selection is
  1143. placed in the search string field.
  1144. </para>
  1145. <para>
  1146. <guimenu>Search</guimenu>&gt;<guimenuitem>Incremental Search
  1147. for Word</guimenuitem>
  1148. (shortcut: <keycombo><keycap>Alt</keycap><keycap>,</keycap></keycombo>)
  1149. behaves like the above command except it places the word at the caret in
  1150. the search string field.
  1151. </para>
  1152. <para>
  1153. Unless the <guibutton>HyperSearch</guibutton> check box is selected, the
  1154. search bar will perform an <firstterm>incremental search</firstterm>.
  1155. In incremental search mode, the first occurrence of the search
  1156. string is located in the current buffer as it is being typed.
  1157. Pressing <keycap>Enter</keycap>
  1158. and <keycombo><keycap>Shift</keycap><keycap>Enter</keycap></keycombo>
  1159. searches for the next and previous occurrence, respectively.
  1160. Once the desired occurrence has been located, pressing <keycap>Escape</keycap>
  1161. returns keyboard focus to the text area. Unless the search bar is set to be
  1162. always visible (see above), pressing <keycap>Escape</keycap> will also hide
  1163. the search bar.
  1164. </para>
  1165. <note>
  1166. <para>
  1167. Incremental searches cannot be not recorded in macros. If your macro
  1168. needs to perform a search, use the
  1169. search and replace dialog box instead. See <xref linkend="using-macros" />
  1170. for information about macros.
  1171. </para>
  1172. </note>
  1173. <para>
  1174. <guimenu>Search</guimenu>&gt;<guimenuitem>HyperSearch Bar</guimenuitem>
  1175. (shortcut: <keycombo><keycap>Control</keycap><keycap>.</keycap></keycombo>)
  1176. displays the search bar if necessary, gives it keyboard focus,
  1177. and selects the <guibutton>HyperSearch</guibutton> check box.
  1178. If this command is invoked while there is a selection, the selected text
  1179. will be searched for immediately and the search bar will not be shown.
  1180. </para>
  1181. <para>
  1182. If the <guibutton>HyperSearch</guibutton> check box is
  1183. selected, pressing <keycap>Enter</keycap> in the search string field
  1184. will perform a HyperSearch in the current buffer.
  1185. </para>
  1186. <para>
  1187. <guimenu>Search</guimenu>&gt;<guimenuitem>HyperSearch
  1188. for Word</guimenuitem>
  1189. (shortcut: <keycombo><keycap>Alt</keycap><keycap>.</keycap></keycombo>)
  1190. performs a HyperSearch for the word at the caret. This command does not
  1191. show the search bar or give it keyboard focus.
  1192. </para>
  1193. </sect2>
  1194. </sect1>
  1195. </chapter>