after deleting a line
with `dd`, this field will be "1",
which is the register that got the
deleted text.
The {regname} argument is a string. If {regname} is invalid
or not set, an empty Dictionary will be returned.
If {regname} is not specified, |v:register| is used.
The returned Dictionary can be passed to |setreg()|.
Parameters: ~
• {regname} (`string?`)
Return: ~
(`table`)
getregion({pos1}, {pos2} [, {opts}]) *getregion()*
Returns the list of strings from {pos1} to {pos2} from a
buffer.
{pos1} and {pos2} must both be |List|s with four numbers.
See |getpos()| for the format of the list. It's possible
to specify positions from a different buffer, but please
note the limitations at |getregion-notes|.
The optional argument {opts} is a Dict and supports the
following items:
type Specify the region's selection type.
See |getregtype()| for possible values,
except that the width can be omitted
and an empty string cannot be used.
(default: "v")
exclusive If |TRUE|, use exclusive selection
for the end position.
(default: follow 'selection')
You can get the last selection type by |visualmode()|.
If Visual mode is active, use |mode()| to get the Visual mode
(e.g., in a |:vmap|).
This function is useful to get text starting and ending in
different columns, such as a |charwise-visual| selection.
*getregion-notes*
Note that:
- Order of {pos1} and {pos2} doesn't matter, it will always
return content from the upper left position to the lower
right position.
- If 'virtualedit' is enabled and the region is past the end
of the lines, resulting lines are padded with spaces.
- If the region is blockwise and it starts or ends in the
middle of a multi-cell character, it is not included but
its selected part is substituted with spaces.
- If {pos1} and {pos2} are not in the same buffer, an empty
list is returned.
- {pos1} and {pos2} must belong to a |bufloaded()| buffer.
- It is evaluated in current window context, which makes a
difference if the buffer is displayed in a window with
different 'virtualedit' or 'list' values.
- When specifying an exclusive selection and {pos1} and {pos2}
are equal, the returned list contains a single character as
if selection is inclusive, to match the behavior of an empty
exclusive selection in Visual mode.
Examples: >vim
xnoremap <CR>
\ <Cmd>echom getregion(
\ getpos('v'), getpos('.'), #{ type: mode() })<CR>
<
Parameters: ~
• {pos1} (`[integer, integer, integer, integer]`)
• {pos2} (`[integer, integer, integer, integer]`)
• {opts} (`{type?:string, exclusive?:boolean}?`)
Return: ~
(`string[]`)
getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
Same as |getregion()|, but returns a list of positions
describing the buffer text segments bound by {pos1} and
{pos2}.
The segments are a pair of positions for every line: >
[[{start_pos}, {end_pos}], ...]
<
The position is a |List| with four numbers:
[bufnum, lnum, col, off]
"bufnum" is the buffer number.
"lnum" and "col" are the position in the buffer. The first
column is 1.
If the "off" number of a starting position is non-zero, it is
the offset in screen columns from the start of the character.
E.g., a position within a <Tab> or after the last character.
If the "off" number of an ending position is non-zero, it is
the offset of the character's first cell not included in the
selection, otherwise all its cells are included.
Apart from the options supported by |getregion()|, {opts} also
supports the following:
eol If |TRUE|, indicate positions beyond
the end of a line with "col" values
one more than the length of the