Module _m.textadept.editing

Editing commands for the textadept module.

Functions

autocomplete_word (word_chars) Pops up an autocompletion list for the current word based on other words in the document.
autocomplete_word_from_dict (dict) Pops up an autocompletion list for the current word based on the path to a dictionary of words.
block_comment (comment) Block comments or uncomments code with a given comment string.
convert_indentation () Converts indentation between tabs and spaces.
current_word (action) Selects the current word under the caret and if action indicates, deletes it.
enclose (str) Encloses text in an enclosure set.
get_preceding_number () [Local function] Returns the number to the left of the caret.
get_sel_or_line () [Local function] Returns the current selection or the contents of the current line.
goto_line (line) Goes to the requested line.
grow_selection (amount) Grows the selection by a character amount on either end.
insert_into_kill_ring (txt) [Local function] Inserts text into kill_ring.
join_lines () Joins the current line with the line below, eliminating whitespace.
lua_exec () Executes the selection or contents of the current line as Lua code, replacing the text with the output.
match_brace (select) Goes to a matching brace position, selecting the text inside if specified.
move_line (direction) Moves the current line in the specified direction up or down.
prepare_for_save () Prepares the buffer for saving to a file.
reformat_paragraph () Reformats the selected text or current paragraph using the 'fmt' command.
ruby_exec () Executes the selection or contents of the current line as Ruby code, replacing the text with the output.
scroll_kill_ring (direction) [Local function] Scrolls kill_ring in the specified direction.
select_enclosed (str) Selects text in a specified enclosure.
select_indented_block () Selects indented blocks intelligently.
select_line () Selects the current line.
select_paragraph () Selects the current paragraph.
select_scope () Selects all text with the same scope/style as under the caret.
show_call_tip (api, start) Displays a call tip based on the word to the left of the cursor and a given API table.
smart_cutcopy (copy) Cuts or copies text ranges intelligently.
smart_paste (action, reindent) Retrieves the top item off the kill-ring and pastes it.
squeeze (char) Reduces multiple characters occurances to just one.
transpose_chars () Transposes characters intelligently.

Tables

braces [Local table] Brace characters.
char_matches [Local table] Character matching.
comment_strings [Local table] Comment strings for various lexer languages.
current_call_tip [Local table] The current call tip.
enclosure [Local table] Enclosures for enclosing or selecting ranges of text.
kill_ring [Local table] The kill-ring.


Functions

autocomplete_word (word_chars)
Pops up an autocompletion list for the current word based on other words in the document.

Parameters

  • word_chars: String of chars considered to be part of words.
autocomplete_word_from_dict (dict)
Pops up an autocompletion list for the current word based on the path to a dictionary of words.

Parameters

  • dict: Path to a dictionary of words.
block_comment (comment)
Block comments or uncomments code with a given comment string.

Parameters

  • comment: The comment string inserted or removed from the beginning of each line in the selection.
convert_indentation ()
Converts indentation between tabs and spaces.
current_word (action)
Selects the current word under the caret and if action indicates, deletes it.

Parameters

  • action: Optional action to perform with selected word. If 'delete', it is deleted.
enclose (str)
Encloses text in an enclosure set. If text is selected, it is enclosed. Otherwise, the previous word is enclosed. The n previous words can be enclosed by appending n (a number) to the end of the last word. When enclosing with a character, append the character to the end of the word(s). To enclose previous word(s) with n characters, append n (a number) to the end of character set. Examples: enclose this2 -> 'enclose this' (enclose in sng_quotes) enclose this2**2 -> **enclose this**

Parameters

  • str: The enclosure type in enclosure.

See also:

get_preceding_number ()
[Local function] Returns the number to the left of the caret. This is used for the enclose function.

See also:

get_sel_or_line ()
[Local function] Returns the current selection or the contents of the current line.
goto_line (line)
Goes to the requested line.

Parameters

  • line: Optional line number to go to.
grow_selection (amount)
Grows the selection by a character amount on either end.

Parameters

  • amount: The amount to grow the selection on either end.
insert_into_kill_ring (txt)
[Local function] Inserts text into kill_ring. If it grows larger than maxn, the oldest inserted text is replaced.

Parameters

  • txt:

See also:

join_lines ()
Joins the current line with the line below, eliminating whitespace.
lua_exec ()
Executes the selection or contents of the current line as Lua code, replacing the text with the output.
match_brace (select)
Goes to a matching brace position, selecting the text inside if specified.

Parameters

  • select: If true, selects the text between matching braces.
move_line (direction)
Moves the current line in the specified direction up or down.

Parameters

  • direction: 'up' moves the current line up, 'down' moves it down.
prepare_for_save ()
Prepares the buffer for saving to a file. Strips trailing whitespace off of every line, ensures an ending newline, and converts non-consistent EOLs.
reformat_paragraph ()
Reformats the selected text or current paragraph using the 'fmt' command.
ruby_exec ()
Executes the selection or contents of the current line as Ruby code, replacing the text with the output.
scroll_kill_ring (direction)
[Local function] Scrolls kill_ring in the specified direction.

Parameters

  • direction: The direction to scroll: 'forward' (default) or 'reverse'.

See also:

select_enclosed (str)
Selects text in a specified enclosure.

Parameters

  • str: The enclosure type in enclosure. If str is not specified, matching character pairs defined in char_matches are searched for from the caret outwards.

See also:

select_indented_block ()
Selects indented blocks intelligently. If no block of text is selected, all text with the current level of indentation is selected. If a block of text is selected and the lines to the top and bottom of it are one indentation level lower, they are added to the selection. In all other cases, the behavior is the same as if no text is selected.
select_line ()
Selects the current line.
select_paragraph ()
Selects the current paragraph. Paragraphs are delimited by two or more consecutive newlines.
select_scope ()
Selects all text with the same scope/style as under the caret.
show_call_tip (api, start)
Displays a call tip based on the word to the left of the cursor and a given API table.

Parameters

  • api: Table of functions call tips can be displayed for. Each key is a function name, and each value is a table of tables. Each of those tables represents a function. It has 2 indexes: parameters and a description. This enables call tips for 'overloaded' functions. Even if there is just one function, it must be enclosed in a table. You can get an API table from a file via textadept.io.read_api_file().
  • start: Flag indicating whether or not to start a call tip. If the user clicks an arrow, you should call show_call_tip again with this value being false to display the next function.

See also:

smart_cutcopy (copy)
Cuts or copies text ranges intelligently. (Behaves like Emacs.) If no text is selected, all text from the cursor to the end of the line is cut or copied as indicated by action and pushed onto the kill-ring. If there is text selected, it is cut or copied and pushed onto the kill-ring.

Parameters

  • copy: If false, the text is cut. Otherwise it is copied.

See also:

smart_paste (action, reindent)
Retrieves the top item off the kill-ring and pastes it. If an action is specified, the text is kept selected for scrolling through the kill-ring.

Parameters

  • action: If given, specifies whether to cycle through the kill-ring in normal or reverse order. A value of 'cycle' cycles through normally, 'reverse' in reverse.
  • reindent: Flag indicating whether or not to reindent the pasted text.

See also:

squeeze (char)
Reduces multiple characters occurances to just one. If char is not given, the character to be squeezed is the one under the caret.

Parameters

  • char: The character (integer) to be used for squeezing.
transpose_chars ()
Transposes characters intelligently. If the carat is at the end of the current word, the two characters before the caret are transposed. Otherwise the characters to the left and right of the caret are transposed.

Tables

braces
[Local table] Brace characters. Used for going to matching brace positions.
char_matches
[Local table] Character matching. Used for auto-matching parentheses, brackets, braces, and quotes.
comment_strings
[Local table] Comment strings for various lexer languages. Used for the block_comment function.
current_call_tip
[Local table] The current call tip. Used for displaying call tips.
enclosure
[Local table] Enclosures for enclosing or selecting ranges of text. Note chars and tag enclosures are generated at runtime.
kill_ring
[Local table] The kill-ring. Fields
  • maxn: The maximum size of the kill-ring.

Valid XHTML 1.0!