Skip to main content

Module command

Module command 

Source
Expand description

Vim FSM: command.

Split out of the monolithic vim.rs (#267 follow-up).

Constants§

MAX_PASTE_BYTES
Upper bound on the bytes one p / P may insert, counting the count prefix’s multiplication. A count can request terabytes (yy then 999999999p), so a bound has to exist; what it must not do is refuse an ordinary large yank.

Functions§

adjust_number
Vim Ctrl-a / Ctrl-x — find the next number at or after the cursor on the current line, add delta, leave the cursor on the last digit of the result. Recognises 0x/0X hex literals (incremented in hex, width and digit case preserved) as well as signed decimals. No-op if the line has no number to the right.
adjust_number_visual
Visual-mode <C-a> / <C-x> and g<C-a> / g<C-x>. Adds delta to the first number on each selected line. When sequential is true the increment grows by delta for each successive number found (vim’s g<C-a>): the first gets delta, the second 2*delta, and so on.
build_indent
Build a leading-whitespace string of width columns honoring expandtab (spaces) vs noexpandtab (tabs for full tabstop runs, spaces remainder).
cut_vim_range
Cut a vim-shaped range through the View edit funnel and return the deleted text. Translates vim’s RangeKind (Linewise/Inclusive/Exclusive) into the buffer’s hjkl_buffer::MotionKind (Line/Char) and applies the right end- position adjustment so inclusive motions actually include the bot cell. Pushes the cut text into the clipboard via record_yank_to_host and the textarea yank buffer (still observed by p/P until the paste path is ported), and updates yank_linewise for linewise cuts.
delete_to_eol
D / C — delete from cursor to end of line through the edit funnel. Pushes the deleted text to the clipboard via record_yank_to_host and the textarea’s yank buffer (still observed by p/P until the paste path is ported). Cursor lands at the deletion start so the caller can decide whether to step it left (D) or open insert mode (C).
do_char_delete
do_paste
goto_percent
[count]% — go to the line at count percent of the file (vim: line (count * line_count + 99) / 100), cursor on the first non-blank.
indent_width
Indent width of a leading-whitespace prefix, counting a \t as advancing to the next tabstop boundary and a space as one column.
join_line
Returns false when the cursor is on the last line (nothing to join) so counted loops can stop instead of spinning.
join_line_raw
gJ — join the next line onto the current one without inserting a separating space or stripping leading whitespace. Returns false when the cursor is on the last line. See join_line.
read_vim_range
Read the text in a vim-shaped range without mutating. Used by Operator::Yank so we can pipe the same range translation as cut_vim_range but skip the delete + inverse extraction.
reindent_block
]p / [p reindent: shift every line of text so the FIRST line’s indent matches target_width columns; later lines keep their relative offset.
replace_char
toggle_case_at_cursor
Returns false when there is no char under the cursor to toggle (end of line / empty line) so counted loops can stop instead of spinning through a saturated count prefix.
visual_join
Visual-mode J (with_space = true) / gJ (with_space = false) — join every line spanned by the selection into one. A single-line selection joins the current line with the one below (matching normal-mode J).
visual_paste
Visual-mode p / P — replace the active selection with the register. With p the deleted selection lands in the unnamed register (vim’s swap); with P (before = true) the source register is preserved so it can be pasted over multiple selections in turn.