Mercurial > vim
comparison runtime/doc/insert.txt @ 25990:ac330e2fecc4 v8.2.3528
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Commit: https://github.com/vim/vim/commit/f4d8b76d304dabc39c06d2344cd4c7b28484811b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 17 14:13:09 2021 +0100
patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Problem: 'thesaurus' and 'thesaurusfunc' do not have the same scope.
Solution: Make 'thesaurusfunc' global-local.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 17 Oct 2021 15:15:04 +0200 |
parents | 416237f1de22 |
children | ebedba7a4898 |
comparison
equal
deleted
inserted
replaced
25989:b2a27d7a9427 | 25990:ac330e2fecc4 |
---|---|
822 keyword replaces the previous matching keyword. | 822 keyword replaces the previous matching keyword. |
823 | 823 |
824 CTRL-P Search backwards for next matching keyword. This | 824 CTRL-P Search backwards for next matching keyword. This |
825 keyword replaces the previous matching keyword. | 825 keyword replaces the previous matching keyword. |
826 | 826 |
827 | |
828 Completing words in 'thesaurus' *compl-thesaurus* | |
829 | |
827 *i_CTRL-X_CTRL-T* | 830 *i_CTRL-X_CTRL-T* |
828 CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses | 831 CTRL-X CTRL-T Works as CTRL-X CTRL-K, but in a special way. It uses |
829 the 'thesaurus' option instead of 'dictionary'. If a | 832 the 'thesaurus' option instead of 'dictionary'. If a |
830 match is found in the thesaurus file, all the | 833 match is found in the thesaurus file, all the |
831 remaining words on the same line are included as | 834 remaining words on the same line are included as |
832 matches, even though they don't complete the word. | 835 matches, even though they don't complete the word. |
833 Thus a word can be completely replaced. | 836 Thus a word can be completely replaced. |
834 | 837 |
835 For an example, imagine the 'thesaurus' file has a | |
836 line like this: > | |
837 angry furious mad enraged | |
838 < Placing the cursor after the letters "ang" and typing | |
839 CTRL-X CTRL-T would complete the word "angry"; | |
840 subsequent presses would change the word to "furious", | |
841 "mad" etc. | |
842 Other uses include translation between two languages, | |
843 or grouping API functions by keyword. | |
844 | |
845 If the 'thesaurusfunc' option is set, then the user | |
846 specified function is invoked to get the list of | |
847 completion matches and the 'thesaurus' option is not | |
848 used. See |complete-functions| for an explanation of | |
849 how the function is invoked and what it should return. | |
850 | |
851 CTRL-T or | 838 CTRL-T or |
852 CTRL-N Search forward for next matching keyword. This | 839 CTRL-N Search forward for next matching keyword. This |
853 keyword replaces the previous matching keyword. | 840 keyword replaces the previous matching keyword. |
854 | 841 |
855 CTRL-P Search backwards for next matching keyword. This | 842 CTRL-P Search backwards for next matching keyword. This |
856 keyword replaces the previous matching keyword. | 843 keyword replaces the previous matching keyword. |
844 | |
845 In the file used by the 'thesaurus' option each line in the file should | |
846 contain words with similar meaning, separated by non-keyword characters (white | |
847 space is preferred). Maximum line length is 510 bytes. | |
848 | |
849 For an example, imagine the 'thesaurus' file has a line like this: > | |
850 angry furious mad enraged | |
851 <Placing the cursor after the letters "ang" and typing CTRL-X CTRL-T would | |
852 complete the word "angry"; subsequent presses would change the word to | |
853 "furious", "mad" etc. | |
854 | |
855 Other uses include translation between two languages, or grouping API | |
856 functions by keyword. | |
857 | |
858 An English word list was added to this github issue: | |
859 https://github.com/vim/vim/issues/629#issuecomment-443293282 | |
860 Unpack thesaurus_pkg.zip, put the thesaurus.txt file somewhere, e.g. | |
861 ~/.vim/thesaurus/english.txt, and the 'thesaurus' option to this file name. | |
862 | |
863 | |
864 Completing keywords with 'thesaurusfunc' *compl-thesaurusfunc* | |
865 | |
866 If the 'thesaurusfunc' option is set, then the user specified function is | |
867 invoked to get the list of completion matches and the 'thesaurus' option is | |
868 not used. See |complete-functions| for an explanation of how the function is | |
869 invoked and what it should return. | |
870 | |
871 Here is an example that uses the "aiksaurus" command (provided by Magnus | |
872 Groß): > | |
873 | |
874 func Thesaur(findstart, base) | |
875 if a:findstart | |
876 let line = getline('.') | |
877 let start = col('.') - 1 | |
878 while start > 0 && line[start - 1] =~ '\a' | |
879 let start -= 1 | |
880 endwhile | |
881 return start | |
882 else | |
883 let res = [] | |
884 let h = '' | |
885 for l in split(system('aiksaurus '.shellescape(a:base)), '\n') | |
886 if l[:3] == '=== ' | |
887 let h = substitute(l[4:], ' =*$', '', '') | |
888 elseif l[0] =~ '\a' | |
889 call extend(res, map(split(l, ', '), {_, val -> {'word': val, 'menu': '('.h.')'}})) | |
890 endif | |
891 endfor | |
892 return res | |
893 endif | |
894 endfunc | |
895 | |
896 if has('patch-8.2.3520') | |
897 set thesaurusfunc=Thesaur | |
898 endif | |
857 | 899 |
858 | 900 |
859 Completing keywords in the current and included files *compl-keyword* | 901 Completing keywords in the current and included files *compl-keyword* |
860 | 902 |
861 The 'include' option is used to specify a line that contains an include file | 903 The 'include' option is used to specify a line that contains an include file |