Home Explore Blog CI



neovim

13th chunk of `runtime/doc/insert.txt`
3d35f39c4aaf73b5ae5b45b1bae9648c609a5d0c2b6ea8510000000100000fa3
 previous matching keyword.

	CTRL-P		Search backwards for next matching keyword.  This
			keyword replaces the previous matching keyword.


Completing words in 'thesaurus'				*compl-thesaurus*

							*i_CTRL-X_CTRL-T*
CTRL-X CTRL-T		Works as CTRL-X CTRL-K, but in a special way.  It uses
			the 'thesaurus' option instead of 'dictionary'.  If a
			match is found in the thesaurus file, all the
			remaining words on the same line are included as
			matches, even though they don't complete the word.
			Thus a word can be completely replaced.

	CTRL-T	or
	CTRL-N		Search forward for next matching keyword.  This
			keyword replaces the previous matching keyword.

	CTRL-P		Search backwards for next matching keyword.  This
			keyword replaces the previous matching keyword.

In the file used by the 'thesaurus' option each line in the file should
contain words with similar meaning, separated by non-keyword characters (white
space is preferred).  Maximum line length is 510 bytes.

For an example, imagine the 'thesaurus' file has a line like this: >
	angry furious mad enraged
Placing the cursor after the letters "ang" and typing CTRL-X CTRL-T would
complete the word "angry"; subsequent presses would change the word to
"furious", "mad" etc.

Other uses include translation between two languages, or grouping API
functions by keyword.

An English word list was added to this github issue:
https://github.com/vim/vim/issues/629#issuecomment-443293282
Unpack thesaurus_pkg.zip, put the thesaurus.txt file somewhere, e.g.
~/.vim/thesaurus/english.txt, and the 'thesaurus' option to this file name.


Completing keywords with 'thesaurusfunc'		*compl-thesaurusfunc*

If the 'thesaurusfunc' option is set, then the user specified function is
invoked to get the list of completion matches and the 'thesaurus' option is
not used. See |complete-functions| for an explanation of how the function is
invoked and what it should return.

Here is an example that uses the "aiksaurus" command (provided by Magnus
Groß): >

    func Thesaur(findstart, base)
      if a:findstart
	return searchpos('\<', 'bnW', line('.'))[1] - 1
      endif
      let res = []
      let h = ''
      for l in systemlist('aiksaurus ' .. shellescape(a:base))
	if l[:3] == '=== '
	  let h = '(' .. substitute(l[4:], ' =*$', ')', '')
	elseif l ==# 'Alphabetically similar known words are: '
	  let h = "\U0001f52e"
	elseif l[0] =~ '\a' || (h ==# "\U0001f52e" && l[0] ==# "\t")
	  call extend(res, map(split(substitute(l, '^\t', '', ''), ', '), {_, val -> {'word': val, 'menu': h}}))
	endif
      endfor
      return res
    endfunc

    if exists('+thesaurusfunc')
      set thesaurusfunc=Thesaur
    endif


Completing keywords in the current and included files	*compl-keyword*

The 'include' option is used to specify a line that contains an include file
name.  The 'path' option is used to search for include files.

							*i_CTRL-X_CTRL-I*
CTRL-X CTRL-I		Search for the first keyword in the current and
			included files that starts with the same characters
			as those before the cursor.  The matched keyword is
			inserted in front of the cursor.

	CTRL-N		Search forwards for next matching keyword.  This
			keyword replaces the previous matching keyword.
			Note: CTRL-I is the same as <Tab>, which is likely to
			be typed after a successful completion, therefore
			CTRL-I is not used for searching for the next match.

	CTRL-P		Search backward for previous matching keyword.  This
			keyword replaces the previous matching keyword.

	CTRL-X CTRL-I	Further use of CTRL-X CTRL-I will copy the words
			following the previous expansion in other contexts
			unless a double CTRL-X is used.

Completing tags						*compl-tag*
							*i_CTRL-X_CTRL-]*
CTRL-X CTRL-]		Search for the first tag that starts with the same
			characters as before the cursor.  The matching tag is
			inserted in front of the cursor.  Alphabetic
			characters and characters in 'iskeyword' are used
			to decide which characters are included in the tag

Title: Thesaurus Completion Details, Custom Completion Functions, and Keyword/Tag Completion
Summary
This section elaborates on thesaurus completion (CTRL-X CTRL-T), detailing how it uses the 'thesaurus' option to suggest words with similar meanings from a file where words are grouped by meaning on each line. It gives an example of how it works and suggests a place to find such a thesaurus file. The text also explains 'thesaurusfunc' allows for the use of a user-defined function to provide completion suggestions, offering an example implementation using the 'aiksaurus' command. Additionally, it covers keyword completion in current and included files (CTRL-X CTRL-I), leveraging the 'include' and 'path' options and tag completion (CTRL-X CTRL-]) based on the 'tags' option.