search history: >vim
call histdel("/", '^\*')
<
The following three are equivalent: >vim
call histdel("search", histnr("search"))
call histdel("search", -1)
call histdel("search", '^' .. histget("search", -1) .. '$')
<
To delete the last search pattern and use the last-but-one for
the "n" command and 'hlsearch': >vim
call histdel("search", -1)
let @/ = histget("search", -1)
<
Parameters: ~
• {history} (`string`)
• {item} (`any?`)
Return: ~
(`0|1`)
histget({history} [, {index}]) *histget()*
The result is a String, the entry with Number {index} from
{history}. See |hist-names| for the possible values of
{history}, and |:history-indexing| for {index}. If there is
no such entry, an empty String is returned. When {index} is
omitted, the most recent item from the history is used.
Examples:
Redo the second last search from history. >vim
execute '/' .. histget("search", -2)
< Define an Ex command ":H {num}" that supports re-execution of
the {num}th entry from the output of |:history|. >vim
command -nargs=1 H execute histget("cmd", 0+<args>)
<
Parameters: ~
• {history} (`string`)
• {index} (`integer|string?`)
Return: ~
(`string`)
histnr({history}) *histnr()*
The result is the Number of the current entry in {history}.
See |hist-names| for the possible values of {history}.
If an error occurred, -1 is returned.
Example: >vim
let inp_index = histnr("expr")
<
Parameters: ~
• {history} (`string`)
Return: ~
(`integer`)
hlID({name}) *hlID()*
The result is a Number, which is the ID of the highlight group
with name {name}. When the highlight group doesn't exist,
zero is returned.
This can be used to retrieve information about the highlight
group. For example, to get the background color of the
"Comment" group: >vim
echo synIDattr(synIDtrans(hlID("Comment")), "bg")
<
Parameters: ~
• {name} (`string`)
Return: ~
(`integer`)
hlexists({name}) *hlexists()*
The result is a Number, which is TRUE if a highlight group
called {name} exists. This is when the group has been
defined in some way. Not necessarily when highlighting has
been defined for it, it may also have been used for a syntax
item.
Parameters: ~
• {name} (`string`)
Return: ~
(`0|1`)
hostname() *hostname()*
The result is a String, which is the name of the machine on
which Vim is currently running. Machine names greater than
256 characters long are truncated.
Return: ~
(`string`)
iconv({string}, {from}, {to}) *iconv()*
The result is a String, which is the text {string} converted
from encoding {from} to encoding {to}.
When the conversion completely fails an empty string is
returned. When some characters could not be converted they
are replaced with "?".
The encoding names are whatever the iconv() library function
can accept, see ":!man 3 iconv".
Note that Vim uses UTF-8 for all Unicode encodings, conversion
from/to UCS-2 is automatically changed to use UTF-8. You
cannot use UCS-2 in a string anyway, because of the NUL bytes.
Parameters: ~
• {string} (`string`)
• {from} (`string`)
• {to} (`string`)
Return: ~
(`string`)
id({expr})