Variables
Const backward_char
backward_char: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart) => [null, selectionStart - 1, null],)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const backward_kill_line
backward_kill_line: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {// If the caret is at the beginning of a line, join the linesif (selectionStart > 0 && text[selectionStart - 1] === "\n") {return [text.substring(0, selectionStart - 1) +text.substring(selectionStart),selectionStart,null,]}let newLine// Find the closest newlinefor (newLine = selectionStart;newLine > 0 && text[newLine - 1] !== "\n";--newLine);// Remove everything between the newline and the caretreturn [text.substring(0, newLine) + text.substring(selectionStart),newLine,null,]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const backward_kill_word
backward_kill_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {const boundaries = getWordBoundaries(text, selectionStart, true)if (selectionStart > boundaries[0]) {boundaries[1] = selectionStart// Remove everything between the newline and the caretreturn [text.substring(0, boundaries[0]) +text.substring(boundaries[1]),boundaries[0],null,]} else {return [null, selectionStart, null]}}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const backward_word
backward_word: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart) => {if (selectionStart === 0) return [null, null, null]const boundaries = getWordBoundaries(text, selectionStart, true)return [null, boundaries[0], null]},)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const beginning_of_line
beginning_of_line: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {while (text[selectionStart - 1] !== undefined &&text[selectionStart - 1] !== "\n")selectionStart -= 1return [null, selectionStart, null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const capitalize_word
capitalize_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart, selectionEnd) =>applyWord(text,selectionStart,selectionEnd,word => word[0].toUpperCase() + word.substring(1),),),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const delete_backward_char
delete_backward_char: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart, selectionEnd) => {if (selectionStart !== selectionEnd) {text =text.substring(0, selectionStart) + text.substring(selectionEnd)} else {text =text.substring(0, selectionStart - 1) +text.substring(selectionStart)}selectionStart -= 1return [text, selectionStart, null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const delete_char
delete_char: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart, selectionEnd) => {if (selectionStart !== selectionEnd) {// If the user selected text, then we need to delete that instead of a single chartext =text.substring(0, selectionStart) + text.substring(selectionEnd)} else {text =text.substring(0, selectionStart) +text.substring(selectionStart + 1)}return [text, selectionStart, null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const downcase_word
downcase_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart, selectionEnd) =>applyWord(text, selectionStart, selectionEnd, word =>word.toLowerCase(),),),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const end_of_line
end_of_line: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {while (text[selectionStart] !== undefined &&text[selectionStart] !== "\n")selectionStart += 1return [null, selectionStart, null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const forward_char
forward_char: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart) => [null,selectionStart + 1,null,])
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const forward_word
forward_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {if (selectionStart === text.length) return [null, null, null]const boundaries = getWordBoundaries(text, selectionStart, false)return [null, boundaries[1], null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const insert_text
insert_text: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart, selectionEnd, arg) => [text.slice(0, selectionStart) + arg + text.slice(selectionEnd),selectionStart + arg.length,null,],)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const jumble
jumble: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart, selectionEnd) => [jumble_helper(text.slice(0, selectionStart) + text.slice(selectionEnd)),selectionStart,null,])
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const kill_line
kill_line: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {let newLine = text.substring(selectionStart).search("\n")if (newLine !== -1) {// If the caret is right before the newline, kill the newlineif (newLine === 0) newLine = 1text =text.substring(0, selectionStart) +text.substring(selectionStart + newLine)} else {text = text.substring(0, selectionStart)}return [text, selectionStart, null]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const kill_whole_line
kill_whole_line: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {let firstNewLinelet secondNewLine// Find the newline before the caretfor (firstNewLine = selectionStart;firstNewLine > 0 && text[firstNewLine - 1] !== "\n";--firstNewLine);// Find the newline after the caretfor (secondNewLine = selectionStart;secondNewLine < text.length && text[secondNewLine - 1] !== "\n";++secondNewLine);// Remove everything between the newline and the caretreturn [text.substring(0, firstNewLine) + text.substring(secondNewLine),firstNewLine,null,]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const kill_word
kill_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {const boundaries = getWordBoundaries(text, selectionStart, false)if (selectionStart < boundaries[1]) {boundaries[0] = selectionStart// Remove everything between the newline and the caretreturn [text.substring(0, boundaries[0]) +text.substring(boundaries[1]),boundaries[0],null,]} else {return [null, selectionStart, null]}}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const next_line
next_line: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart) => {const leftNewLinePos = text.slice(0, selectionStart).lastIndexOf("\n")let widthif (leftNewLinePos!==-1) {width = selectionStart - leftNewLinePos} else {width=selectionStart+1}const rightNewLinePos=text.indexOf("\n",selectionStart)let positionif (rightNewLinePos==-1) {position=text.length} else {const nextRightNewLinePos = text.indexOf("\n", rightNewLinePos + 1)if (nextRightNewLinePos == -1 || rightNewLinePos + width < nextRightNewLinePos) {position = rightNewLinePos + width} else {position=nextRightNewLinePos}}return [text, position, null]})
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const previous_line
previous_line: (e: HTMLElement, arg?: any) => boolean = wrap_input((text,selectionStart) => {const leftNewLinePos = text.slice(0, selectionStart).lastIndexOf("\n")let width = 0if (leftNewLinePos!==-1) {width = selectionStart - leftNewLinePos} else {return[text, 0, null]}const previousLeftNewLinePos = text.slice(0, leftNewLinePos).lastIndexOf("\n", selectionStart)let positionif (previousLeftNewLinePos + width < leftNewLinePos) {position = previousLeftNewLinePos + width} else {position=leftNewLinePos}return [text, position, null]})
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const rot13
rot13: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart, selectionEnd) => [rot13_helper(text.slice(0, selectionStart) + text.slice(selectionEnd)),selectionStart,null,])
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const tab_insert
tab_insert: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart, selectionEnd) => {if (selectionStart !== selectionEnd) {text =text.substring(0, selectionStart) +"\t" +text.substring(selectionEnd)} else {text =text.substring(0, selectionStart) +"\t" +text.substring(selectionStart)}selectionStart += 1return [text, selectionStart, null]})
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const transpose_chars
transpose_chars: (e: HTMLElement, arg?: any) => boolean = wrap_input((text, selectionStart) => {if (text.length < 2) return [null, null, null]// When at the beginning of the text, transpose the first and second charactersif (selectionStart === 0) selectionStart = 1// When at the end of the text, transpose the last and second-to-last charactersif (selectionStart >= text.length) selectionStart = text.length - 1text =text.substring(0, selectionStart - 1) +text.substring(selectionStart, selectionStart + 1) +text.substring(selectionStart - 1, selectionStart) +text.substring(selectionStart + 1)selectionStart += 1return [text, selectionStart, null]},)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const transpose_words
transpose_words: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart) => {if (selectionStart >= text.length) {selectionStart = text.length - 1}// Find the word the caret is inlet firstBoundaries = getWordBoundaries(text, selectionStart, false)let secondBoundaries = firstBoundaries// If there is a word after the word the caret is in, use it for the transselectionStartition, otherwise use the word before itconst nextWord = wordAfterPos(text, firstBoundaries[1])if (nextWord > -1) {secondBoundaries = getWordBoundaries(text, nextWord, false)} else {firstBoundaries = getWordBoundaries(text,firstBoundaries[0] - 1,true,)}const firstWord = text.substring(firstBoundaries[0], firstBoundaries[1])const secondWord = text.substring(secondBoundaries[0],secondBoundaries[1],)const beginning =text.substring(0, firstBoundaries[0]) +secondWord +text.substring(firstBoundaries[1], secondBoundaries[0])selectionStart = beginning.lengthreturn [beginning + firstWord + text.substring(secondBoundaries[1]),selectionStart,null,]}),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Const upcase_word
upcase_word: (e: HTMLElement, arg?: any) => boolean = wrap_input(needs_text((text, selectionStart, selectionEnd) =>applyWord(text, selectionStart, selectionEnd, word =>word.toUpperCase(),),),)
Type declaration
-
- (e: HTMLElement, arg?: any): boolean
-
Parameters
-
e: HTMLElement
-
Optional arg: any
Returns boolean
Editor Functions
This file contains functions to manipulate the content of textareas/input fields/contenteditable elements.
If you want to bind them to keyboard shortcuts, be sure to prefix them with "text.". For example, if you want to bind control-a to
beginning_of_line
in all modes, use:bind --mode=ex <C-a> text.beginning_of_line bind --mode=input <C-a> text.beginning_of_line bind --mode=insert <C-a> text.beginning_of_line
Also keep in mind that if you want to bind something in insert mode, you'll probably also want to bind it in input mode (insert mode is entered by clicking on text areas while input mode is entered by using
gi
).If you're looking for command-line only functions, go there.
Contrary to the main tridactyl help page, this one doesn't tell you whether a specific function is bound to something. For now, you'll have to make do with with
:bind
and:viewconfig
.