search.html 4.4 KB

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