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/Pmay insert, counting thecountprefix’s multiplication. A count can request terabytes (yythen999999999p), 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, adddelta, leave the cursor on the last digit of the result. Recognises0x/0Xhex 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>andg<C-a>/g<C-x>. Addsdeltato the first number on each selected line. Whensequentialis true the increment grows bydeltafor each successive number found (vim’sg<C-a>): the first getsdelta, the second2*delta, and so on. - build_
indent - Build a leading-whitespace string of
widthcolumns honoringexpandtab(spaces) vsnoexpandtab(tabs for fulltabstopruns, 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’shjkl_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 viarecord_yank_to_hostand the textarea yank buffer (still observed byp/Puntil the paste path is ported), and updatesyank_linewisefor 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 viarecord_yank_to_hostand the textarea’s yank buffer (still observed byp/Puntil 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 atcountpercent 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
\tas advancing to the nexttabstopboundary and a space as one column. - join_
line - Returns
falsewhen 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. Returnsfalsewhen the cursor is on the last line. Seejoin_line.- read_
vim_ range - Read the text in a vim-shaped range without mutating. Used by
Operator::Yankso we can pipe the same range translation ascut_vim_rangebut skip the delete + inverse extraction. - reindent_
block ]p/[preindent: shift every line oftextso the FIRST line’s indent matchestarget_widthcolumns; later lines keep their relative offset.- replace_
char - toggle_
case_ at_ cursor - Returns
falsewhen 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-modeJ). - visual_
paste - Visual-mode
p/P— replace the active selection with the register. Withpthe deleted selection lands in the unnamed register (vim’s swap); withP(before = true) the source register is preserved so it can be pasted over multiple selections in turn.