Skip to content

Commit

Permalink
Give example of the extraKeys option.
Browse files Browse the repository at this point in the history
Issues codemirror#988, codemirror#742, codemirror#612, etc. show that CodeMirror users tend to:

1. Not find how to make the Tab key insert spaces instead of a tab,
2. Miss how to use extraKeys to easily solve the issue.

Adding an example helps them find a solution immediately.
  • Loading branch information
espadrine committed Mar 3, 2013
1 parent c3f655b commit 713e960
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,17 @@ <h2 id="keymaps">Keymaps</h2>
for example, <code>Shift-Ctrl-Space</code> would be a valid key
identifier.</p>

<p>Common example: map the Tab key to insert spaces instead of a tab
character.</p>

<pre data-lang="javascript">
{
Tab: function(cm) {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
cm.replaceSelection(spaces, "end", "+input");
}
}</pre>

<p>Alternatively, a character can be specified directly by
surrounding it in single quotes, for example <code>'$'</code>
or <code>'q'</code>. Due to limitations in the way browsers fire
Expand Down

0 comments on commit 713e960

Please sign in to comment.