CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/codemirror/extensions/tab-as-space.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import * as CodeMirror from "codemirror";
7
8
CodeMirror.defineExtension("tab_as_space", function () {
9
// @ts-ignore
10
const cm: any = this;
11
const selections = cm.listSelections();
12
selections.reverse();
13
for (const sel of selections) {
14
for (let i = 0; i < cm.options.tabSize; i++) {
15
cm.replaceRange(" ", sel.head);
16
}
17
}
18
});
19
20