Home Explore Blog CI



neovim

60th chunk of `runtime/doc/lua.txt`
b17dbe09ae2563d888b3cb7fa2153ca992da8dc95117d5a90000000100000c76
 (multiple): ~
        (`string?`) Decoded string
        (`string?`) Error message, if any

vim.text.hexencode({str})                               *vim.text.hexencode()*
    Hex encode a string.

    Parameters: ~
      • {str}  (`string`) String to encode

    Return: ~
        (`string`) Hex encoded string

vim.text.indent({size}, {text}, {opts})                    *vim.text.indent()*
    Sets the indent (i.e. the common leading whitespace) of non-empty lines in
    `text` to `size` spaces/tabs.

    Indent is calculated by number of consecutive indent chars.
    • The first indented, non-empty line decides the indent char (space/tab):
      • `SPC SPC TAB …` = two-space indent.
      • `TAB SPC …` = one-tab indent.
    • Set `opts.expandtab` to treat tabs as spaces.

    To "dedent" (remove the common indent), pass `size=0`: >lua
        vim.print(vim.text.indent(0, ' a\n  b\n'))
<

    To adjust relative-to an existing indent, call indent() twice: >lua
        local indented, old_indent = vim.text.indent(0, ' a\n b\n')
        indented = vim.text.indent(old_indent + 2, indented)
        vim.print(indented)
<

    To ignore the final, blank line when calculating the indent, use gsub()
    before calling indent(): >lua
        local text = '  a\n  b\n '
        vim.print(vim.text.indent(0, (text:gsub('\n[\t ]+\n?$', '\n'))))
<

    Parameters: ~
      • {size}  (`integer`) Number of spaces.
      • {text}  (`string`) Text to indent.
      • {opts}  (`{ expandtab?: integer }?`)

    Return (multiple): ~
        (`string`) Indented text.
        (`integer`) Indent size before modification.


==============================================================================
Lua module: tohtml                                                *vim.tohtml*


:[range]TOhtml {file}                                                *:TOhtml*
Converts the buffer shown in the current window to HTML, opens the generated
HTML in a new split window, and saves its contents to {file}. If {file} is not
given, a temporary file (created by |tempname()|) is used.


tohtml.tohtml({winid}, {opt})                         *tohtml.tohtml.tohtml()*
    Converts the buffer shown in the window {winid} to HTML and returns the
    output as a list of string.

    Parameters: ~
      • {winid}  (`integer?`) Window to convert (defaults to current window)
      • {opt}    (`table?`) Optional parameters.
                 • {title}? (`string|false`, default: buffer name) Title tag
                   to set in the generated HTML code.
                 • {number_lines}? (`boolean`, default: `false`) Show line
                   numbers.
                 • {font}? (`string[]|string`, default: `guifont`) Fonts to
                   use.
                 • {width}? (`integer`, default: 'textwidth' if non-zero or
                   window width otherwise) Width used for items which are
                   either right aligned or repeat a character infinitely.
                 • {range}? (`integer[]`, default: entire buffer) Range of
                   rows to use.

    Return: ~
        (`string[]`)


 vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:

Title: vim.text.hexencode, vim.text.indent, :TOhtml, tohtml.tohtml
Summary
This section details `vim.text.hexencode()`, which hex encodes a string, `vim.text.indent()`, which sets the indent of non-empty lines in a text, `:TOhtml`, which converts the buffer to HTML and opens it in a new window, and `tohtml.tohtml()`, which converts a buffer to HTML and returns the output as a list of strings.