Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
// ============================================================ //
// Inside of PRESERVE area.
// ============================================================ //
function transposeSubString(input, beg, end, to) {
let txt = input.value;
let head = txt.slice(0, beg);
let left = txt.slice(beg, end);
let right = txt.slice(end, to);
let tail = txt.slice(to);
let {scrollTop, scrollLeft} = input;
input.value = head + right + left + tail;
input.selectionStart = input.selectionEnd = txt.length - tail.length;
if (scrollTop === scrollLeft === 0)
command.inputScrollSelectionIntoView(input);
else
input.scrollTop = scrollTop, input.scrollLeft = scrollLeft;
}
function transposeChars(ev, arg) {
let input = ev.originalTarget;
let begin = input.selectionEnd - 1;
let end = begin + 1;
let to = end + (typeof arg === 'number' ? Math.max(arg, 1) : 1);
transposeSubString(input, begin, end, to);
}
ext.add("transpose-chars", transposeChars, "Interchange characters around point");
// ============================================================ //
// Bottom of the .keysnail.js
// ============================================================ //
key.setEditKey("C-t", function (ev, arg) { ext.exec("transpose-chars", arg, ev); }, "Transpose chars", true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.