Home Explore Blog CI



neovim

59th chunk of `runtime/doc/vimfn.txt`
e3e06758781038e73c8d0eccdb8c994fdab04e2580bfe7780000000100000fb6
 rhs (what it is
		mapped to) and this mapping exists in one of the modes
		indicated by {mode}.
		The arguments {what} and {mode} are strings.
		When {abbr} is there and it is |TRUE| use abbreviations
		instead of mappings.  Don't forget to specify Insert and/or
		Command-line mode.
		Both the global mappings and the mappings local to the current
		buffer are checked for a match.
		If no matching mapping is found FALSE is returned.
		The following characters are recognized in {mode}:
			n	Normal mode
			v	Visual and Select mode
			x	Visual mode
			s	Select mode
			o	Operator-pending mode
			i	Insert mode
			l	Language-Argument ("r", "f", "t", etc.)
			c	Command-line mode
		When {mode} is omitted, "nvo" is used.

		This function is useful to check if a mapping already exists
		to a function in a Vim script.  Example: >vim
			if !hasmapto('\ABCdoit')
			   map <Leader>d \ABCdoit
			endif
<		This installs the mapping to "\ABCdoit" only if there isn't
		already a mapping to "\ABCdoit".

                Parameters: ~
                  • {what} (`any`)
                  • {mode} (`string?`)
                  • {abbr} (`boolean?`)

                Return: ~
                  (`0|1`)

histadd({history}, {item})                                           *histadd()*
		Add the String {item} to the history {history} which can be
		one of:					*hist-names*
			"cmd"	 or ":"	  command line history
			"search" or "/"   search pattern history
			"expr"	 or "="   typed expression history
			"input"  or "@"	  input line history
			"debug"  or ">"   debug command history
			empty		  the current or last used history
		The {history} string does not need to be the whole name, one
		character is sufficient.
		If {item} does already exist in the history, it will be
		shifted to become the newest entry.
		The result is a Number: TRUE if the operation was successful,
		otherwise FALSE is returned.

		Example: >vim
			call histadd("input", strftime("%Y %b %d"))
			let date=input("Enter date: ")
<		This function is not available in the |sandbox|.

                Parameters: ~
                  • {history} (`string`)
                  • {item} (`any`)

                Return: ~
                  (`0|1`)

histdel({history} [, {item}])                                        *histdel()*
		Clear {history}, i.e. delete all its entries.  See |hist-names|
		for the possible values of {history}.

		If the parameter {item} evaluates to a String, it is used as a
		regular expression.  All entries matching that expression will
		be removed from the history (if there are any).
		Upper/lowercase must match, unless "\c" is used |/\c|.
		If {item} evaluates to a Number, it will be interpreted as
		an index, see |:history-indexing|.  The respective entry will
		be removed if it exists.

		The result is TRUE for a successful operation, otherwise FALSE
		is returned.

		Examples:
		Clear expression register history: >vim
			call histdel("expr")
<
		Remove all entries starting with "*" from the 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.

Title: Documentation for `hasmapto()`, `histadd()`, `histdel()`, and `histget()` functions (continued)
Summary
This section continues detailing the `hasmapto()` function and then introduces the `histadd()`, `histdel()`, and `histget()` functions. `histadd()` adds an item to a specified history (command line, search, etc.). `histdel()` clears a history or removes specific entries based on a string pattern or index. `histget()` retrieves a history entry at a given index.