comparison runtime/doc/insert.txt @ 659:d6a69271cb9a v7.0194

updated for version 7.0194
author vimboss
date Wed, 08 Feb 2006 09:20:24 +0000
parents 8157079cea85
children 21ab9abf0f08
comparison
equal deleted inserted replaced
658:903088c7a7c6 659:d6a69271cb9a
1 *insert.txt* For Vim version 7.0aa. Last change: 2006 Jan 30 1 *insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 07
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
954 954
955 FUNCTIONS FOR FINDING COMPLETIONS *complete-functions* 955 FUNCTIONS FOR FINDING COMPLETIONS *complete-functions*
956 956
957 This applies to 'completefunc' and 'omnifunc'. 957 This applies to 'completefunc' and 'omnifunc'.
958 958
959 The function will be invoked with two arguments. First the function is called 959 The function is called in two different ways:
960 to find the start of the text to be completed. Secondly the function is 960 - First the function is called to find the start of the text to be completed.
961 called to actually find the matches. 961 - Later the function is called to actually find the matches.
962 962
963 On the first invocation the arguments are: 963 On the first invocation the arguments are:
964 a:findstart 1 964 a:findstart 1
965 a:base empty 965 a:base empty
966 966
967 The function must return the column of where the completion starts. It must 967 The function must return the column where the completion starts. It must be a
968 be a number between zero and the cursor column "col('.')". This involves 968 number between zero and the cursor column "col('.')". This involves looking
969 looking at the characters just before the cursor and including those 969 at the characters just before the cursor and including those characters that
970 characters that could be part of the completed item. The text between this 970 could be part of the completed item. The text between this column and the
971 column and the cursor column will be replaced with the matches. Return -1 if 971 cursor column will be replaced with the matches. Return -1 if no completion
972 no completion can be done. 972 can be done.
973 973
974 On the second invocation the arguments are: 974 On the second invocation the arguments are:
975 a:findstart 0 975 a:findstart 0
976 a:base the text with which matches should match, what was 976 a:base the text with which matches should match; the text that was
977 located in the first call (can be empty) 977 located in the first call (can be empty)
978 978
979 The function must return a List with the matching words. These matches 979 The function must return a List with the matching words. These matches
980 usually include the "a:base" text. When there are no matches return an empty 980 usually include the "a:base" text. When there are no matches return an empty
981 List. When one of the items in the list cannot be used as a string (e.g., a 981 List.
982 Dictionary) then an error message is given and further items in the list are 982
983 not used. 983 Each list item can either be a string or a Dictionary. When it is a string it
984 is used as the completion. When it is a Dictionary it can contain these
985 items:
986 word the completion, mandatory
987 menu extra text for the popup menu
988 info more information about the item
989 kind single letter indicating the type of completion
990
991 All of these must be a string. If an item does not meet these requirements
992 then an error message is given and further items in the list are not used.
993 You can mix string and Dictionary items in the returned list.
994
995 The "menu" item is used in the popup menu and may be truncated, thus it should
996 be relatively short. The "info" item can be longer, it may be displayed in a
997 balloon.
998
999 The "kind" item uses a single letter to indicate the kind of completion. This
1000 may be used to show the completion differently (different color or icon).
1001 Currently these types can be used:
1002 v variable
1003 f function or method
1004 c composite (struct, object)
984 1005
985 When searching for matches takes some time call |complete_add()| to add each 1006 When searching for matches takes some time call |complete_add()| to add each
986 match to the total list. These matches should then not appear in the returned 1007 match to the total list. These matches should then not appear in the returned
987 list! Call |complete_check()| now and then to allow the user to press a key 1008 list! Call |complete_check()| now and then to allow the user to press a key
988 while still searching for matches. Stop searching when it returns non-zero. 1009 while still searching for matches. Stop searching when it returns non-zero.
989 1010
990 The function may move the cursor, it is restored afterwards. This option 1011 The function is allowed to move the cursor, it is restored afterwards. This
991 cannot be set from a |modeline| or in the |sandbox|, for security reasons. 1012 option cannot be set from a |modeline| or in the |sandbox|, for security
1013 reasons.
992 1014
993 An example that completes the names of the months: > 1015 An example that completes the names of the months: >
994 fun! CompleteMonths(findstart, base) 1016 fun! CompleteMonths(findstart, base)
995 if a:findstart 1017 if a:findstart
996 " locate the start of the word 1018 " locate the start of the word
1048 - The 'completeopt' option contains "menu". 1070 - The 'completeopt' option contains "menu".
1049 - The terminal supports at least 8 colors. 1071 - The terminal supports at least 8 colors.
1050 - There are at least two matches. 1072 - There are at least two matches.
1051 1073
1052 While the menu is displayed these keys have a special meaning: 1074 While the menu is displayed these keys have a special meaning:
1053 <CR> and <Enter>: Accept the currently selected match 1075 <CR> and <Enter> Accept the currently selected match
1054 <Up>: Select the previous match, as if CTRL-P was used 1076 <Up> Select the previous match, as if CTRL-P was used
1055 <Down>: Select the next match, as if CTRL-N was used 1077 <Down> Select the next match, as if CTRL-N was used
1056 <PageUp>: Select a match several entries back 1078 <PageUp> Select a match several entries back
1057 <PageDown>: Select a match several entries further 1079 <PageDown> Select a match several entries further
1080 <BS> and CTRL-H Delete one character, find the matches for the shorter word
1081 before the cursor. This may find more matches.
1082 CTRL-L Add one character from the current match, may reduce the
1083 number of matches. Does not work after selecting one of the
1084 matches with CTRL-N, <Up>, etc.
1058 1085
1059 The colors of the menu can be changed with these highlight groups: 1086 The colors of the menu can be changed with these highlight groups:
1060 Pmenu normal item |hl-Pmenu| 1087 Pmenu normal item |hl-Pmenu|
1061 PmenuSel selected item |hl-PmenuSel| 1088 PmenuSel selected item |hl-PmenuSel|
1062 PmenuSbar scrollbar |hl-PmenuSbar| 1089 PmenuSbar scrollbar |hl-PmenuSbar|
1071 Completion of C code requires a tags file. You should use Exuberant ctags, 1098 Completion of C code requires a tags file. You should use Exuberant ctags,
1072 because it adds extra information that is needed for completion. You can find 1099 because it adds extra information that is needed for completion. You can find
1073 it here: http://ctags.sourceforge.net/ 1100 it here: http://ctags.sourceforge.net/
1074 For version 5.5.4 you should add a patch that adds the "typename:" field: 1101 For version 5.5.4 you should add a patch that adds the "typename:" field:
1075 ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch 1102 ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch
1103 A compiled .exe for MS-Windows can be found at:
1104 http://georgevreilly.com/vim/ctags.html
1076 1105
1077 If you want to complete system functions you can do something like this. Use 1106 If you want to complete system functions you can do something like this. Use
1078 ctags to generate a tags file for all the system header files: > 1107 ctags to generate a tags file for all the system header files: >
1079 % ctags -R -f ~/.vim/systags /usr/include /usr/local/include 1108 % ctags -R -f ~/.vim/systags /usr/include /usr/local/include
1080 In your vimrc file add this tags file to the 'tags' option: > 1109 In your vimrc file add this tags file to the 'tags' option: >
1102 1131
1103 Complete properties and their appropriate values according to CSS 2.1 1132 Complete properties and their appropriate values according to CSS 2.1
1104 specification. 1133 specification.
1105 1134
1106 1135
1107 (X)HTML *ft-html-omni* 1136 HTML and XHTML *ft-html-omni*
1108 *ft-xhtml-omni* 1137 *ft-xhtml-omni*
1109 1138
1110 CTRL-X CTRL-O provides completion of various elements of (X)HTML files. 1139 CTRL-X CTRL-O provides completion of various elements of (X)HTML files.
1111 It is designed to support writing of XHTML 1.0 Strict files but will 1140 It is designed to support writing of XHTML 1.0 Strict files but will
1112 also works for other versions of HTML. Features: 1141 also works for other versions of HTML. Features:
1113 1142
1114 - after "<" complete tag name depending on context (no div suggest 1143 - after "<" complete tag name depending on context (no div suggestion
1115 inside of an a tag) 1144 inside of an a tag)
1116 - inside of tag complete proper attributes (no width attribute for an 1145 - inside of tag complete proper attributes (no width attribute for an
1117 a tag) 1146 a tag)
1118 - when attribute has limited number of possible values help to complete 1147 - when attribute has limited number of possible values help to complete
1119 them 1148 them
1120 - complete names of entities 1149 - complete names of entities
1121 - complete values of "class" and "id" attributes with data obtained from 1150 - complete values of "class" and "id" attributes with data obtained from
1122 style tag and included CSS files 1151 style tag and included CSS files
1123 - when completing "style" attribute or working inside of "style" tag 1152 - when completing value of "style" attribute or working inside of "style" tag
1124 switch to |ft-css-omni| completion 1153 switch to |ft-css-omni| completion
1154 - when completing values of events attributes or working inside of "script" tag
1155 switch to |ft-javascript-omni| completion
1125 - when used after "</" CTRL-X CTRL-O will close the last opened tag 1156 - when used after "</" CTRL-X CTRL-O will close the last opened tag
1126 1157
1127 Note: When used first time completion menu will be shown with little delay 1158 Note: When used first time completion menu will be shown with little delay
1128 - this is time needed for loading of data file. 1159 - this is time needed for loading of data file.
1160 Note: Completion may fail in badly formatted documents. In such case try to
1161 run |:make| command to detect formatting problems.
1129 1162
1130 1163
1131 JAVASCRIPT *ft-javascript-omni* 1164 JAVASCRIPT *ft-javascript-omni*
1132 1165
1133 Completion of most elements of JavaScript language and HTML DOM. 1166 Completion of most elements of JavaScript language and DOM elements.
1134 1167
1135 Complete: 1168 Complete:
1136 1169
1137 - variables 1170 - variables
1138 - function name 1171 - function name
1139 - function arguments 1172 - function arguments
1140 - properties of variables trying to detect type of variable 1173 - properties of variables trying to detect type of variable
1141 - complete HTML DOM objects and properties depending on context 1174 - complete DOM objects and properties depending on context
1142 - keywords of language 1175 - keywords of language
1143 1176
1144 Completion works in separate JavaScript files (&ft==javascript) and inside of 1177 Completion works in separate JavaScript files (&ft==javascript), inside of
1145 <script> tag of (X)HTML. Note: scanning will be only in scope of current tag. 1178 <script> tag of (X)HTML and in values of event attributes (including scanning
1146 At the moment separate files are not taken into account. 1179 of external files.
1147 1180
1148 DOM compatibility 1181 DOM compatibility
1149 1182
1150 At the moment (beginning of 2006) there are two main browsers - MS Internet 1183 At the moment (beginning of 2006) there are two main browsers - MS Internet
1151 Explorer and Mozilla Firefox. These two applications are covering over 90% of 1184 Explorer and Mozilla Firefox. These two applications are covering over 90% of
1152 market. Theoretically standards are created by W3C organisation 1185 market. Theoretically standards are created by W3C organisation