CodeMirror: Search/Replace Demo

1
  <dt id="option_indentWithTabs"><code>indentWithTabs (boolean)</code></dt>
2
  <dd>Whether, when indenting, the first N*8 spaces should be
3
  replaced by N tabs. Default is false.</dd>
4
 
5
  <dt id="option_tabMode"><code>tabMode (string)</code></dt>
6
  <dd>Determines what happens when the user presses the tab key.
7
  Must be one of the following:
8
    <dl>
9
      <dt><code>"classic" (the default)</code></dt>
10
      <dd>When nothing is selected, insert a tab. Otherwise,
11
      behave like the <code>"shift"</code> mode. (When shift is
12
      held, this behaves like the <code>"indent"</code> mode.)</dd>
13
      <dt><code>"shift"</code></dt>
14
      <dd>Indent all selected lines by
15
      one <a href="#option_indentUnit"><code>indentUnit</code></a>.
16
      If shift was held while pressing tab, un-indent all selected
17
      lines one unit.</dd>
18
      <dt><code>"indent"</code></dt>
19
      <dd>Indent the line the 'correctly', based on its syntactic
20
      context. Only works if the
21
      mode <a href="#indent">supports</a> it.</dd>
22
      <dt><code>"default"</code></dt>
23
      <dd>Do not capture tab presses, let the browser apply its
24
      default behaviour (which usually means it skips to the next
25
      control).</dd>
26
    </dl></dd>
27
 
28
  <dt id="option_enterMode"><code>enterMode (string)</code></dt>
29
  <dd>Determines whether and how new lines are indented when the
30
  enter key is pressed. The following modes are supported:
31
    <dl>
32
      <dt><code>"indent" (the default)</code></dt>
33
      <dd>Use the mode's indentation rules to give the new line
34
      the correct indentation.</dd>
35
      <dt><code>"keep"</code></dt>
36
      <dd>Indent the line the same as the previous line.</dd>
37
      <dt><code>"flat"</code></dt>
38
      <dd>Do not indent the new line.</dd>
39
    </dl></dd>
40
 
 

Demonstration of primitive search/replace functionality. The keybindings (which can be overridden by custom keymaps) are:

Ctrl-F / Cmd-F
Start searching
Ctrl-G / Cmd-G
Find next
Shift-Ctrl-G / Shift-Cmd-G
Find previous
Shift-Ctrl-F / Cmd-Option-F
Replace
Shift-Ctrl-R / Shift-Cmd-Option-F
Replace all

Searching is enabled by including addon/search/search.js and addon/search/searchcursor.js. For good-looking input dialogs, you also want to include addon/dialog/dialog.js and addon/dialog/dialog.css.