PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/doc/users-guide/source-edit.xml

#
XML | 605 lines | 599 code | 4 blank | 2 comment | 0 complexity | feb23bb3a555d1dcd23260a997cd7285 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: -->
  3. <chapter id="source-edit"><title>Editing Source Code</title>
  4. <sect1 id="modes"><title>Edit Modes</title>
  5. <para>
  6. An <firstterm>edit mode</firstterm> specifies syntax highlighting
  7. rules, auto indent behavior, and various other customizations for editing
  8. a certain file type. This section
  9. only covers using and selecting edit modes; information about writing your
  10. own can be found in <xref linkend="writing-modes-part" />.
  11. </para>
  12. <sect2 id="mode-selection"><title>Mode Selection</title>
  13. <para>
  14. When a file is opened, jEdit first checks the file name against a list
  15. of known patterns. For example, files whose names end with <quote>.c</quote>
  16. are edited in C mode, and files named <filename>Makefile</filename> are
  17. edited in Makefile mode. If a suitable match based on file name cannot be
  18. found, jEdit checks the first line of the file. For example, files whose
  19. first line is <quote>#!/bin/sh</quote> are edited in shell script mode.
  20. </para>
  21. <para>
  22. File name and first line globs can be changed in the
  23. <guibutton>Mode-Specific</guibutton> pane of the
  24. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  25. dialog box (see <xref linkend="global-opts"/>).
  26. </para>
  27. <para>
  28. If automatic mode selection is not appropriate, the edit mode can
  29. be specified manually. The current buffer's edit mode can be set
  30. on a one-time basis in the
  31. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  32. dialog box; see <xref linkend="buffer-opts" />. To set a buffer's edit mode
  33. for future editing sessions,
  34. place the following in one of the first or last 10 lines of the buffer,
  35. where <replaceable>edit mode</replaceable> is the name of the desired edit
  36. mode:
  37. </para>
  38. <screen>:mode=<replaceable>edit mode</replaceable>:</screen>
  39. <para>
  40. A list of edit modes can be found in the
  41. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  42. dialog box.
  43. </para>
  44. </sect2>
  45. <sect2 id="syntax-hilite"><title>Syntax Highlighting</title>
  46. <para>
  47. Syntax highlighting is the display of programming language
  48. tokens using different fonts and colors. This makes code
  49. easier to follow and errors such as misplaced quotes easier to spot.
  50. All edit modes except for
  51. the plain text mode perform syntax highlighting.
  52. </para>
  53. <para>
  54. The colors and styles used to highlight syntax tokens can be changed
  55. in the <guibutton>Styles</guibutton> pane of the
  56. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  57. dialog box; see <xref linkend="global-opts" />.
  58. </para>
  59. </sect2>
  60. </sect1>
  61. <sect1 id="abbrevs"><title>Abbreviations</title>
  62. <para>
  63. Using abbreviations reduces the time spent typing long but commonly used
  64. strings. For example, in Java mode, the abbreviation <quote>sout</quote> is
  65. defined to expand to <quote>System.out.println()</quote>, so to insert
  66. <quote>System.out.println()</quote> in a Java buffer, you only need to type
  67. <quote>sout</quote> followed by
  68. <keycombo><keycap>Control</keycap><keycap>;</keycap></keycombo>.
  69. Each abbreviation can either be global, in which case it will expand in all
  70. edit modes, or mode-specific. Abbreviations can be edited
  71. in the <guibutton>Abbreviations</guibutton> pane of the
  72. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  73. dialog box; see <xref linkend="global-opts" />. The Java, VHDL and XSL edit
  74. modes include some pre-defined abbreviations you might find useful.
  75. </para>
  76. <para>
  77. <guimenu>Edit</guimenu>&gt;<guimenuitem>Expand Abbreviation</guimenuitem>
  78. (keyboard shortcut: <keycombo><keycap>Control</keycap><keycap>;</keycap></keycombo>)
  79. attempts to expand the word before the caret. If no expansion could
  80. be found, it will offer to define one.
  81. </para>
  82. <para>
  83. Automatic abbreviation expansion can be enabled in the
  84. <guibutton>Abbreviations</guibutton> pane of the
  85. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  86. dialog box; see <xref linkend="global-opts" />. If enabled, pressing the
  87. space bar after entering an
  88. abbreviation will automatically expand it.
  89. </para>
  90. <para>
  91. If automatic expansion
  92. is enabled, a space can be inserted without expanding the word before
  93. the caret by pressing
  94. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  95. <keycap>V</keycap> <keycap>Space</keycap>.
  96. </para>
  97. <sect2 id="positional-params"><title>Positional Parameters</title>
  98. <para>
  99. Positional parameters are an advanced feature that make abbreviations much
  100. more useful. The best way to describe them is with an example.
  101. </para>
  102. <para>
  103. Suppose you have an abbreviation <quote>F</quote> that is set to expand to
  104. the following:
  105. </para>
  106. <programlisting>for(int $1 = 0; $1 &lt; $2; $1++)</programlisting>
  107. <para>
  108. Now, simply entering <quote>F</quote> in the buffer and expanding it will
  109. insert the above text as-is. However, if you expand
  110. <literal>F#j#array.length#</literal>,
  111. the following will be inserted:
  112. </para>
  113. <programlisting>for(int j = 0; j &lt; array.length; j++)</programlisting>
  114. <para>
  115. Expansions can contain up to nine positional parameters. Note that a
  116. trailing hash character (<quote>#</quote>) must be entered when expanding an
  117. abbreviation with parameters.
  118. </para>
  119. <para>
  120. If you do not specify the correct number of positional parameters when
  121. expanding an abbreviation, any missing parameters will appear
  122. blank in the expansion, and extra parameters will be ignored.
  123. A status bar message will be shown stating what
  124. the correct number of parameters is.
  125. </para>
  126. </sect2>
  127. </sect1>
  128. <sect1 id="bracket-matching"><title>Bracket Matching</title>
  129. <para>
  130. Misplaced and unmatched brackets are one of the most common syntax
  131. errors encountered when writing code. jEdit has several features
  132. to make brackets easier to deal with.
  133. </para>
  134. <para>
  135. Positioning the caret immediately after a bracket will highlight the
  136. corresponding closing or opening bracket (assuming it is visible)
  137. and draw a scope indicator in the gutter. If the highlighted bracket is
  138. not visible, the text of the matching line will be shown in the status
  139. bar. If the matching line consists of only whitespace and the bracket
  140. itself, the <emphasis>line before</emphasis> is shown instead. This
  141. feature is very useful for code with brackets indented like so:
  142. </para>
  143. <programlisting>public void someMethod()
  144. {
  145. if(isOK)
  146. {
  147. doSomething();
  148. }
  149. }</programlisting>
  150. <para>
  151. Invoking
  152. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  153. Code</guisubmenu>&gt;<guimenuitem>Go to Matching
  154. Bracket</guimenuitem> (shortcut:
  155. <keycombo><keycap>Control</keycap><keycap>]</keycap></keycombo>), or
  156. clicking the scope indicator in the gutter moves the caret to the
  157. highlighted bracket.
  158. </para>
  159. <para>
  160. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  161. Code</guisubmenu>&gt;<guimenuitem>Select Code Block</guimenuitem>
  162. (shortcut: <keycombo><keycap>Control</keycap><keycap>[</keycap></keycombo>)
  163. selects all text between the two brackets surrounding the caret.
  164. </para>
  165. <para>
  166. Holding down <keycap>Control</keycap> while clicking the scope indicator
  167. or a bracket in the text area will select all text
  168. between the two matching brackets.
  169. </para>
  170. <para>
  171. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  172. Code</guisubmenu>&gt;<guimenuitem>Go to Previous
  173. Bracket</guimenuitem> (shortcut:
  174. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  175. <keycap>[</keycap>) moves the caret to the previous opening bracket.
  176. </para>
  177. <para>
  178. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  179. Code</guisubmenu>&gt;<guimenuitem>Go to Next Bracket</guimenuitem> (shortcut:
  180. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo> <keycap>]</keycap>)
  181. moves the caret to the next closing bracket.
  182. </para>
  183. <para>
  184. Bracket highlighting for the text area and gutter, respectively,
  185. can be disabled in the
  186. <guibutton>Text Area</guibutton> and <guibutton>Gutter</guibutton> panes of the
  187. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem>
  188. dialog box; see <xref linkend="global-opts" />.
  189. </para>
  190. <note>
  191. <para>
  192. jEdit's bracket matching algorithm only checks syntax tokens with the same
  193. type as the original bracket for matches. So brackets inside string
  194. literals and comments will not cause problems, as they will
  195. be skipped.
  196. </para>
  197. </note>
  198. </sect1>
  199. <sect1 id="indent"><title>Tabbing and Indentation</title>
  200. <para>
  201. jEdit makes a distinction between the <firstterm>tab width</firstterm>,
  202. which is is used when displaying tab characters, and the <firstterm>indent
  203. width</firstterm>, which is used when a level of indent is to be added or
  204. removed, for example by mode-specific smart indent routines. Both can be
  205. changed in one of several ways:
  206. </para>
  207. <itemizedlist>
  208. <listitem><para>On a global or mode-specific basis in
  209. <guibutton>Editing</guibutton> and <guibutton>Mode-Specific</guibutton> panes
  210. of the the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  211. Options</guimenuitem> dialog box.
  212. </para></listitem>
  213. <listitem><para>In the current buffer
  214. for the duration of the editing session in the
  215. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  216. dialog box; see <xref linkend="buffer-opts" />.</para></listitem>
  217. <listitem><para>In the current buffer
  218. for future editing sessions by placing the
  219. following in one of the first or last 10 lines of the buffer, where
  220. <replaceable>n</replaceable> is the desired tab width, and
  221. <replaceable>m</replaceable> is the desired indent width:
  222. </para>
  223. <screen>:tabSize=<replaceable>n</replaceable>:indentSize=<replaceable>m</replaceable>:</screen>
  224. </listitem>
  225. </itemizedlist>
  226. <para>
  227. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  228. Code</guisubmenu>&gt;<guisubmenu>Shift Indent Left</guisubmenu>
  229. (shortcut: <keycombo><keycap>Shift</keycap><keycap>Tab</keycap></keycombo>
  230. or <keycombo><keycap>Alt</keycap><keycap>Left</keycap></keycombo>)
  231. adds one level of indent to each selected line, or the current line
  232. if there is no selection.
  233. </para>
  234. <para>
  235. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  236. Code</guisubmenu>&gt;<guisubmenu>Shift Indent Right</guisubmenu>
  237. (shortcut: <keycombo><keycap>Alt</keycap><keycap>Right</keycap></keycombo>)
  238. removes one level of indent from each selected line, or the current line
  239. if there is no selection. Pressing <keycap>Tab</keycap> while a multi-line
  240. selection is active has the same effect.
  241. </para>
  242. <sect2 id="soft-tabs"><title>Soft Tabs</title>
  243. <para>
  244. Because files indented using tab characters may look less than ideal when
  245. viewed on a system with a different default tab size, it is sometimes
  246. desirable to use multiple spaces, known as <firstterm>soft tabs</firstterm>,
  247. instead of real tab characters, to indent code.
  248. </para>
  249. <para>
  250. Soft tabs can be enabled or disabled in one of several ways:
  251. </para>
  252. <itemizedlist>
  253. <listitem><para>On a global or edit mode-specific basis in the
  254. <guibutton>Editing</guibutton> and <guibutton>Mode-Specific</guibutton>
  255. panes of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  256. Options</guimenuitem> dialog box.</para></listitem>
  257. <listitem><para>In the current buffer for
  258. the duration of the editing session in the
  259. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  260. dialog box; see <xref linkend="buffer-opts" />.</para></listitem>
  261. <listitem><para>In the current buffer for
  262. future editing sessions by placing the following in one of the first
  263. or last 10 lines of the buffer, where <replaceable>flag</replaceable> is either
  264. <quote>true</quote> or <quote>false</quote>:
  265. </para>
  266. <screen>:noTabs=<replaceable>flag</replaceable>:</screen>
  267. </listitem>
  268. </itemizedlist>
  269. <para>
  270. Changing the soft tabs setting has no effect on existing tab characters;
  271. it only affects subsequently-inserted tabs.
  272. </para>
  273. <para>
  274. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source</guisubmenu>&gt;<guimenuitem>Spaces
  275. to Tabs</guimenuitem>
  276. converts soft tabs to hard tabs in the current selection, or the entire
  277. buffer if nothing is selected.
  278. </para>
  279. <para>
  280. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source</guisubmenu>&gt;<guimenuitem>Tabs
  281. to Spaces</guimenuitem>
  282. converts hard tabs to soft tabs in the current selection, or the entire
  283. buffer if nothing is selected.
  284. </para>
  285. </sect2>
  286. <sect2 id="autoindent"><title>Automatic Indent</title>
  287. <para>
  288. The auto indent feature inserts the appropriate number of tabs or
  289. spaces at the beginning of a line.
  290. </para>
  291. <para>
  292. If indent on enter is enabled, pressing <keycap>Enter</keycap>
  293. will create a new line with the appropriate amount of
  294. indent automatically. If indent on tab is enabled, pressing
  295. <keycap>Tab</keycap> at the beginning of, or inside the leading
  296. whitespace of, a line will insert the appropriate amount of
  297. indentation. Pressing it again will insert a tab character.
  298. </para>
  299. <para>
  300. By default, both indent on enter and indent on tab is enabled.
  301. This can be changed in one of several ways:
  302. </para>
  303. <itemizedlist>
  304. <listitem><para>On a global or mode-specific
  305. basis in the <guibutton>Editing</guibutton> and
  306. <guibutton>Mode-Specific</guibutton> panes
  307. of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  308. Options</guimenuitem> dialog box.</para></listitem>
  309. <listitem><para>In the current buffer for the duration of the editing
  310. session in the
  311. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  312. dialog box; see <xref linkend="buffer-opts" />. </para></listitem>
  313. <listitem><para>In the current buffer for future editing sessions
  314. by placing the following in the first or last 10 lines of a buffer,
  315. where <replaceable>flag</replaceable> is either <quote>true</quote> or
  316. <quote>false</quote>:
  317. </para>
  318. <screen>:indentOnEnter=<replaceable>flag</replaceable>:indentOnTab=<replaceable>flag</replaceable>:</screen>
  319. </listitem>
  320. </itemizedlist>
  321. <para>
  322. Auto indent behavior is mode-specific. In most edit modes,
  323. the indent of the previous line is simply copied over.
  324. However, in C-like languages (C, C++, Java, JavaScript), curly
  325. brackets and language statements are taken into account and indent
  326. is added and removed as necessary.
  327. </para>
  328. <para>
  329. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  330. Code</guisubmenu>&gt;<guisubmenu>Indent Selected Lines</guisubmenu>
  331. (shortcut: <keycombo><keycap>Control</keycap><keycap>I</keycap></keycombo>)
  332. indents all selected lines, or the current line if there is no
  333. selection.
  334. </para>
  335. <para>
  336. To insert a literal tab or newline without performing
  337. indentation, prefix the tab or newline with
  338. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  339. <keycap>V</keycap>. For example,
  340. to create a new line without any indentation, type
  341. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  342. <keycap>V</keycap> <keycap>Enter</keycap>.
  343. </para>
  344. </sect2>
  345. </sect1>
  346. <sect1 id="commenting"><title>Commenting Out Code</title>
  347. <para>
  348. Most programming and markup languages support <quote>comments</quote>, or
  349. regions of code which are ignored by the compiler/interpreter. jEdit
  350. has commands which make inserting comments more convenient.
  351. </para>
  352. <para>
  353. Comment strings are mode-specific, and modes such as HTML where
  354. different parts of a buffer can have different comment strings
  355. (for example, in HTML text and inline JavaScript) are handled correctly.
  356. </para>
  357. <para>
  358. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  359. Code</guisubmenu>&gt;<guimenuitem>Range Comment</guimenuitem>
  360. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  361. <keycombo><keycap>Control</keycap><keycap>C</keycap></keycombo>) encloses the
  362. selection with comment start and end strings, for example <literal>/*</literal>
  363. and <literal>*/</literal> in Java mode.
  364. </para>
  365. <para>
  366. <guimenu>Edit</guimenu>&gt;<guisubmenu>Source
  367. Code</guisubmenu>&gt;<guimenuitem>Line Comment</guimenuitem>
  368. (shortcut: <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  369. <keycombo><keycap>Control</keycap><keycap>K</keycap></keycombo>) inserts the
  370. line comment string, for example <literal>//</literal> in Java mode,
  371. at the start of each selected line.
  372. </para>
  373. </sect1>
  374. <sect1 id="folding"><title>Folding</title>
  375. <para>
  376. Program source code and other structured text files can be thought of
  377. as a hierarchy of sections, which themselves might contain sub-sections.
  378. The folding feature lets you selectively hide and show these sections,
  379. replacing hidden ones with a single line that serves as an
  380. <quote>overview</quote> of that section.
  381. </para>
  382. <para>
  383. Folding is disabled by default. To enable it, you must choose one of the
  384. two available <quote>folding modes</quote>. <quote>Indent</quote>
  385. mode creates folds based on a line's leading whitespace; the more
  386. leading whitespace a block of text has, the further down it is
  387. in the hierarchy. For example:
  388. </para>
  389. <screen>This is a section
  390. This is a sub-section
  391. This is another sub-section
  392. This is a sub-sub-section
  393. Another top-level section</screen>
  394. <para>
  395. <quote>Explicit</quote> mode folds away blocks of
  396. text surrounded with <quote>{{{</quote> and <quote>}}}</quote>.
  397. For example:
  398. </para>
  399. <screen>{{{ The first line of a fold.
  400. When this fold is collapsed, only the above line will be visible.
  401. {{{ A sub-section.
  402. With text inside it.
  403. }}}
  404. {{{ Another sub-section.
  405. }}}
  406. }}}</screen>
  407. <para>
  408. Both modes have distinct advantages and disadvantages; indent folding
  409. requires no changes to be made to a buffer's text and does a decent
  410. job with most program source. Explicit folding requires <quote>fold
  411. markers</quote> to be inserted into the text, but is more flexible in
  412. exactly what to fold away.
  413. </para>
  414. <para>
  415. Folding can be enabled in one of several ways:
  416. </para>
  417. <itemizedlist>
  418. <listitem><para>On a global or mode-specific
  419. basis in the <guibutton>Editing</guibutton> and
  420. <guibutton>Mode-Specific</guibutton> panes
  421. of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  422. Options</guimenuitem> dialog box.</para></listitem>
  423. <listitem><para>In the current buffer for the duration of the editing
  424. session in the
  425. <guimenu>Utilities</guimenu>&gt;<guimenuitem>Buffer Options</guimenuitem>
  426. dialog box; see <xref linkend="buffer-opts" />. </para></listitem>
  427. <listitem><para>In the current buffer for future editing sessions
  428. by placing the following in the first or last 10 lines of a buffer,
  429. where <replaceable>mode</replaceable> is either <quote>indent</quote> or
  430. <quote>explicit</quote>:
  431. </para>
  432. <screen>:folding=<replaceable>mode</replaceable>:</screen>
  433. </listitem>
  434. </itemizedlist>
  435. <warning>
  436. <para>
  437. When using indent folding, portions of the buffer may become
  438. inaccessible if you change the leading indent of the first line of a
  439. collapsed fold. If you experience this, you will need to use the
  440. <guimenuitem>Expand All Folds</guimenuitem> command to make the text
  441. visible again.
  442. </para>
  443. </warning>
  444. <sect2><title>Collapsing and Expanding Folds</title>
  445. <para>
  446. The first line of each fold has a triangle
  447. drawn next to it in the gutter (see <xref linkend="textarea"/> for
  448. more information about the gutter). The triangle points toward the
  449. line when the fold is collapsed, and downward when the fold is
  450. expanded.
  451. Clicking the triangle collapses and
  452. expands the fold. To expand all sub-folds as well, hold down the
  453. <keycap>Shift</keycap> while clicking.
  454. </para>
  455. <para>
  456. The first line of a collapsed fold is also drawn
  457. with a different background color, and the number of lines in the
  458. fold is shown to the right of the line's text.
  459. </para>
  460. <para>
  461. Folds can also be collapsed and expanded using menu item commands and
  462. keyboard shortcuts.
  463. </para>
  464. <para>
  465. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Collapse
  466. Fold</guimenuitem> (keyboard shortcut:
  467. <keycombo><keycap>Alt</keycap><keycap>Backspace</keycap></keycombo>)
  468. collapses the fold
  469. containing the caret position.
  470. </para>
  471. <para>
  472. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Expand
  473. Fold One Level</guimenuitem> (keyboard shortcut:
  474. <keycombo><keycap>Alt</keycap><keycap>Enter</keycap></keycombo>) expands the
  475. fold containing the caret position. Nested folds will remain collapsed,
  476. and the caret is positioned on the first nested fold (if any).
  477. </para>
  478. <para>
  479. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Expand
  480. Fold Fully</guimenuitem> (keyboard shortcut:
  481. <keycombo><keycap>Alt</keycap><keycap>Shift</keycap><keycap>Enter</keycap></keycombo>)
  482. expands the fold
  483. containing the caret position, also expanding any nested folds.
  484. </para>
  485. <para>
  486. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Collapse
  487. All Folds</guimenuitem> (keyboard shortcut:
  488. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  489. <keycap>C</keycap>) collapses all folds in the buffer.
  490. </para>
  491. <para>
  492. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Expand
  493. All Folds</guimenuitem> (keyboard shortcut:
  494. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  495. <keycap>X</keycap>)
  496. expands all folds, thus making all lines in the buffer visible.
  497. </para>
  498. </sect2>
  499. <sect2><title>Navigating Around With Folds</title>
  500. <para>
  501. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Go to Parent
  502. Fold</guimenuitem> (keyboard shortcut:
  503. <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>) moves
  504. the caret to the fold containing the one at the caret position.
  505. </para>
  506. <para>
  507. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Go to Previous
  508. Fold</guimenuitem> (keyboard shortcut:
  509. <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>) moves
  510. the caret to the fold immediately before the caret position.
  511. </para>
  512. <para>
  513. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Go to Next
  514. Fold</guimenuitem> (keyboard shortcut:
  515. <keycombo><keycap>Alt</keycap><keycap>Up</keycap></keycombo>) moves
  516. the caret to the fold immediately after the caret position.
  517. </para>
  518. </sect2>
  519. <sect2><title>Miscellaneous Folding Commands</title>
  520. <para>
  521. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Add
  522. Explicit Fold</guimenuitem> (keyboard shortcut:
  523. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  524. <keycap>A</keycap>) is a convenience command that surrounds the
  525. selection with <quote>{{{</quote> and <quote>}}}</quote>. If the
  526. current buffer's edit mode defines comment strings (see
  527. <xref linkend="commenting" />) the explicit fold markers will
  528. automatically be commented out as well.
  529. </para>
  530. <para>
  531. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Select
  532. Fold</guimenuitem>
  533. (keyboard shortcut:
  534. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  535. <keycap>S</keycap>)
  536. selects all lines within the fold containing the caret position.
  537. <keycap>Control</keycap>-clicking a fold expansion triangle
  538. in the gutter has the same effect.
  539. </para>
  540. <para>
  541. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Expand
  542. Folds With Level</guimenuitem> (keyboard shortcut:
  543. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  544. <keycap>Enter</keycap> <keycap><replaceable>key</replaceable></keycap>)
  545. reads the next character entered at the keyboard, and
  546. expands folds in the buffer
  547. with a fold level less than that specified, while collapsing all others.
  548. </para>
  549. <para>
  550. You can have all folds with a fold level higher than that specified
  551. be collapsed automatically when a buffer is loaded. This can be configured
  552. as follows:
  553. </para>
  554. <itemizedlist>
  555. <listitem><para>On a global or mode-specific
  556. basis in the <guibutton>Editing</guibutton> and
  557. <guibutton>Mode-Specific</guibutton> panes
  558. of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global
  559. Options</guimenuitem> dialog box.</para></listitem>
  560. <listitem><para>In the current buffer for future editing sessions
  561. by placing the following in the first or last 10 lines of a buffer,
  562. where <replaceable>level</replaceable> is the desired fold level:
  563. </para>
  564. <screen>:collapseFolds=<replaceable>level</replaceable>:</screen>
  565. </listitem>
  566. </itemizedlist>
  567. </sect2>
  568. <sect2 id="narrowing"><title>Narrowing</title>
  569. <para>
  570. The narrowing feature temporarily <quote>narrows</quote> the display
  571. of a buffer to a specified region. Text outside the region is not
  572. shown, but is still present in the buffer. Both folding and
  573. narrowing are implemented using the same code internally.
  574. </para>
  575. <para>
  576. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Narrow
  577. Buffer to Fold</guimenuitem> (keyboard shortcut:
  578. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  579. <keycap>N</keycap> <keycap>N</keycap>) hides all lines the buffer except
  580. those in the fold containing the caret.
  581. When this command is invoked, a message is shown in the
  582. status bar reminding you that you need to invoke
  583. <guimenuitem>Expand All Folds</guimenuitem> to make the rest of the buffer
  584. visible again.
  585. </para>
  586. <para>
  587. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Narrow
  588. Buffer to Selection</guimenuitem> (keyboard shortcut:
  589. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  590. <keycap>N</keycap> <keycap>S</keycap>) hides all lines the buffer
  591. except those in the selection.
  592. </para>
  593. <para>
  594. <guisubmenu>Folding</guisubmenu>&gt;<guimenuitem>Expand
  595. All Folds</guimenuitem> (keyboard shortcut:
  596. <keycombo><keycap>Control</keycap><keycap>E</keycap></keycombo>
  597. <keycap>X</keycap>) will make visible any lines hidden by narrowing.
  598. </para>
  599. </sect2>
  600. </sect1>
  601. </chapter>