search.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!doctype html>
  2. <title>CodeMirror: Search/Replace Demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <link rel="stylesheet" href="../addon/dialog/dialog.css">
  7. <script src="../lib/codemirror.js"></script>
  8. <script src="../mode/xml/xml.js"></script>
  9. <script src="../addon/dialog/dialog.js"></script>
  10. <script src="../addon/search/searchcursor.js"></script>
  11. <script src="../addon/search/search.js"></script>
  12. <style type="text/css">
  13. .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
  14. dt {font-family: monospace; color: #666;}
  15. </style>
  16. <div id=nav>
  17. <a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
  18. <ul>
  19. <li><a href="../index.html">Home</a>
  20. <li><a href="../doc/manual.html">Manual</a>
  21. <li><a href="https://github.com/marijnh/codemirror">Code</a>
  22. </ul>
  23. <ul>
  24. <li><a class=active href="#">Search/Replace</a>
  25. </ul>
  26. </div>
  27. <article>
  28. <h2>Search/Replace Demo</h2>
  29. <form><textarea id="code" name="code">
  30. <dl>
  31. <dt id="option_indentWithTabs"><code><strong>indentWithTabs</strong>: boolean</code></dt>
  32. <dd>Whether, when indenting, the first N*<code>tabSize</code>
  33. spaces should be replaced by N tabs. Default is false.</dd>
  34. <dt id="option_electricChars"><code><strong>electricChars</strong>: boolean</code></dt>
  35. <dd>Configures whether the editor should re-indent the current
  36. line when a character is typed that might change its proper
  37. indentation (only works if the mode supports indentation).
  38. Default is true.</dd>
  39. <dt id="option_specialChars"><code><strong>specialChars</strong>: RegExp</code></dt>
  40. <dd>A regular expression used to determine which characters
  41. should be replaced by a
  42. special <a href="#option_specialCharPlaceholder">placeholder</a>.
  43. Mostly useful for non-printing special characters. The default
  44. is <code>/[\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/</code>.</dd>
  45. <dt id="option_specialCharPlaceholder"><code><strong>specialCharPlaceholder</strong>: function(char) → Element</code></dt>
  46. <dd>A function that, given a special character identified by
  47. the <a href="#option_specialChars"><code>specialChars</code></a>
  48. option, produces a DOM node that is used to represent the
  49. character. By default, a red dot (<span style="color: red">•</span>)
  50. is shown, with a title tooltip to indicate the character code.</dd>
  51. <dt id="option_rtlMoveVisually"><code><strong>rtlMoveVisually</strong>: boolean</code></dt>
  52. <dd>Determines whether horizontal cursor movement through
  53. right-to-left (Arabic, Hebrew) text is visual (pressing the left
  54. arrow moves the cursor left) or logical (pressing the left arrow
  55. moves to the next lower index in the string, which is visually
  56. right in right-to-left text). The default is <code>false</code>
  57. on Windows, and <code>true</code> on other platforms.</dd>
  58. </dl>
  59. </textarea></form>
  60. <script>
  61. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "text/html", lineNumbers: true});
  62. </script>
  63. <p>Demonstration of primitive search/replace functionality. The
  64. keybindings (which can be overridden by custom keymaps) are:</p>
  65. <dl>
  66. <dt>Ctrl-F / Cmd-F</dt><dd>Start searching</dd>
  67. <dt>Ctrl-G / Cmd-G</dt><dd>Find next</dd>
  68. <dt>Shift-Ctrl-G / Shift-Cmd-G</dt><dd>Find previous</dd>
  69. <dt>Shift-Ctrl-F / Cmd-Option-F</dt><dd>Replace</dd>
  70. <dt>Shift-Ctrl-R / Shift-Cmd-Option-F</dt><dd>Replace all</dd>
  71. </dl>
  72. <p>Searching is enabled by
  73. including <a href="../addon/search/search.js">addon/search/search.js</a>
  74. and <a href="../addon/search/searchcursor.js">addon/search/searchcursor.js</a>.
  75. For good-looking input dialogs, you also want to include
  76. <a href="../addon/dialog/dialog.js">addon/dialog/dialog.js</a>
  77. and <a href="../addon/dialog/dialog.css">addon/dialog/dialog.css</a>.</p>
  78. </article>