robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 9a29622b3b00ddb601

master
88.1 KiB2180 linesraw
1*insert.txt*    Nvim
2
3
4		  VIM REFERENCE MANUAL	  by Bram Moolenaar
5
6
7						*Insert* *Insert-mode*
8Inserting and replacing text				*mode-ins-repl*
9
10Most of this file is about Insert and Replace mode.  At the end are a few
11commands for inserting text in other ways.
12
13An overview of the most often used commands can be found in chapter 24 of the
14user manual |usr_24.txt|.
15
16Also see 'virtualedit', for moving the cursor to positions where there is no
17character.  Useful for editing a table.
18
19                                      Type |gO| to see the table of contents.
20
21==============================================================================
221. Special keys						*ins-special-keys*
23
24In Insert and Replace mode, the following characters have a special meaning;
25other characters are inserted directly.  To insert one of these special
26characters into the buffer, precede it with CTRL-V.  To insert a <Nul>
27character use "CTRL-V CTRL-@" or "CTRL-V 000".  On some systems, you have to
28use "CTRL-V 003" to insert a CTRL-C.  Note: When CTRL-V is mapped you can
29often use CTRL-Q instead |i_CTRL-Q|.
30
31If you are working in a special language mode when inserting text, see the
32'langmap' option, 'langmap', on how to avoid switching this mode on and off
33all the time.
34
35char		action	~
36-----------------------------------------------------------------------
37						*i_CTRL-[* *i_<Esc>*
38<Esc> or CTRL-[	End insert or Replace mode, go back to Normal mode.  Finish
39		abbreviation.
40		Note: If your <Esc> key is hard to hit, try CTRL-[ instead.
41						*i_META* *i_ALT*
42		ALT (|META|) may act like <Esc> if the chord is not mapped.
43		For example <A-x> acts like <Esc>x if <A-x> does not have an
44		insert-mode mapping.
45						*i_CTRL-C*
46CTRL-C		Quit insert mode, go back to Normal mode.  Do not check for
47		abbreviations.  Does not trigger the |InsertLeave| autocommand
48		event.
49
50						*i_CTRL-@*
51CTRL-@		Insert previously inserted text and stop insert.
52
53						*i_CTRL-A*
54CTRL-A		Insert previously inserted text.
55
56						*i_CTRL-H* *i_<BS>* *i_BS*
57<BS> or CTRL-H	Delete the character before the cursor (see |i_backspacing|
58		about joining lines).
59						*i_<Del>* *i_DEL*
60<Del>		Delete the character under the cursor.  If the cursor is at
61		the end of the line, and the 'backspace' option includes
62		"eol" (the default), delete the <EOL>; the next line is
63		appended after the current one.
64						*i_CTRL-W*
65CTRL-W		Delete the word before the cursor (see |i_backspacing| about
66		joining lines).  See the section "word motions",
67		|word-motions|, for the definition of a word.
68						*i_CTRL-W-default*
69		By default, sets a new undo point before deleting.
70		|default-mappings|
71						*i_CTRL-U*
72CTRL-U		Delete all characters that were entered after starting Insert
73		mode and before the cursor in the current line.
74		If there are no newly entered characters and 'backspace' is
75		not empty, delete all characters before the cursor in the
76		current line.
77		If C-indenting is enabled the indent will be adjusted if the
78		line becomes blank.
79		See |i_backspacing| about joining lines.
80						*i_CTRL-U-default*
81		By default, sets a new undo point before deleting.
82		|default-mappings|
83						*i_CTRL-I* *i_<Tab>* *i_Tab*
84<Tab> or CTRL-I Insert a tab.  If the 'expandtab' option is on, the
85		equivalent number of spaces is inserted (use CTRL-V <Tab> to
86		avoid the expansion; use CTRL-Q <Tab> if CTRL-V is mapped
87		|i_CTRL-Q|).  See also the 'smarttab' option and
88		|ins-expandtab|.
89						*i_CTRL-J* *i_<NL>*
90<NL> or CTRL-J	Begin new line.
91						*i_CTRL-M* *i_<CR>*
92<CR> or CTRL-M	Begin new line.
93						*i_CTRL-K*
94CTRL-K {char1} [char2]
95		Enter digraph (see |digraphs|).  When {char1} is a special
96		key, the code for that key is inserted in <> form.  For
97		example, the string "<S-Space>" can be entered by typing
98		<C-K><S-Space> (two keys).  Neither char is considered for
99		mapping.
100
101CTRL-N		Find next keyword (see |i_CTRL-N|).
102CTRL-P		Find previous keyword (see |i_CTRL-P|).
103
104CTRL-R {register}				*i_CTRL-R*
105		Insert the contents of a register. Between typing CTRL-R and
106		the second character, '"' will be displayed to indicate that
107		you are expected to enter the name of a register. When used
108		with named or clipboard registers (A-Z,a-z,0-9,+) text is
109		inserted literally like pasting with "p". For other registers,
110		the text is inserted as if you typed it, but mappings and
111		abbreviations are not used.  If you have options like
112		'textwidth', 'formatoptions', or 'autoindent' set, this will
113		influence what will be inserted. This is different from what
114		happens with the "p" command and pasting with the mouse.
115		Special registers:
116			'"'	the unnamed register, containing the text of
117				the last delete or yank
118			'%'	the current file name
119			'#'	the alternate file name
120			"*"	the clipboard contents (X11: primary selection)
121			'+'	the clipboard contents
122			'/'	the last search pattern
123			':'	the last command-line
124			'.'	the last inserted text
125							*i_CTRL-R_-*
126			'-'	the last small (less than a line) delete
127				register.  This is repeatable using |.| since
128				it remembers the register to put instead of
129				the literal text to insert.
130							*i_CTRL-R_=*
131			'='	the expression register: you are prompted to
132				enter an expression (see |expression|)
133				Note that 0x80 (128 decimal) is used for
134				special keys.  E.g., you can use this to move
135				the cursor up:
136					CTRL-R ="\<Up>"
137				you can use this to insert a register as
138				typed with CTRL-R =@reg.
139				Use CTRL-R CTRL-R to insert text literally.
140				When the result is a |List| the items are used
141				as lines.  They can have line breaks inside
142				too.
143				When the result is a Float it's automatically
144				converted to a String.
145				When append() or setline() is invoked the undo
146				sequence will be broken.
147		See |registers| about registers.
148
149CTRL-R CTRL-R {register}			*i_CTRL-R_CTRL-R*
150		Insert the contents of a register.  Works like using a single
151		CTRL-R, but the text is inserted literally, not as if typed.
152		This differs when the register contains characters like <BS>.
153		Example, where register a contains "ab^Hc": >
154	CTRL-R a		results in "ac".
155	CTRL-R CTRL-R a		results in "ab^Hc".
156<		Options 'textwidth', 'formatoptions', etc. still apply.  If
157		you also want to avoid these, use CTRL-R CTRL-O, see below.
158		The '.' register (last inserted text) is still inserted as
159		typed.
160		After this command, the '.' register contains the text from
161		the register as if it was inserted by typing it.
162
163CTRL-R CTRL-O {register}			*i_CTRL-R_CTRL-O*
164		Insert the contents of a register literally and don't
165		auto-indent.  Does the same as pasting with the mouse
166		|<MiddleMouse>|.  When the register is linewise this will
167		insert the text above the current line, like with `P`.
168		The '.' register (last inserted text) is still inserted as
169		typed.
170		After this command, the '.' register contains the command
171		typed and not the text.  I.e., the literals "^R^O" and not the
172		text from the register.
173		Does not replace characters in |Replace-mode|!
174
175CTRL-R CTRL-P {register}			*i_CTRL-R_CTRL-P*
176		Insert the contents of a register literally and fix the
177		indent, like |[<MiddleMouse>|.
178		The '.' register (last inserted text) is still inserted as
179		typed.
180		After this command, the '.' register contains the command
181		typed and not the text.  I.e., the literals "^R^P" and not the
182		text from the register.
183		Does not replace characters in |Replace-mode|!
184
185						*i_CTRL-T*
186CTRL-T		Insert one shiftwidth of indent at the start of the current
187		line.  The indent is always rounded to a 'shiftwidth'.
188						*i_CTRL-D*
189CTRL-D		Delete one shiftwidth of indent at the start of the current
190		line.  The indent is always rounded to a 'shiftwidth'.
191
192						*i_0_CTRL-D*
1930 CTRL-D	Delete all indent in the current line.
194
195						*i_^_CTRL-D*
196^ CTRL-D	Delete all indent in the current line.  The indent is
197		restored in the next line.  This is useful when inserting a
198		label.
199
200						*i_CTRL-V*
201CTRL-V		Insert next non-digit literally.  It's also possible to enter
202		the decimal, octal or hexadecimal value of a character
203		|i_CTRL-V_digit|.
204		The characters typed right after CTRL-V are not considered for
205		mapping.
206		For special keys, the CTRL modifier may be included into the
207		key to produce a control character.  If there is no control
208		character for the key then its |key-notation| is inserted.
209		Note: When CTRL-V is mapped (e.g., to paste text) you can
210		often use CTRL-Q instead |i_CTRL-Q|.
211
212						*i_CTRL-Q*
213CTRL-Q		Same as CTRL-V.
214		Note: Some terminal connections may eat CTRL-Q, it doesn't
215		work then.  It does work in the GUI.
216
217CTRL-SHIFT-V				*i_CTRL-SHIFT-V* *i_CTRL-SHIFT-Q*
218CTRL-SHIFT-Q	Works just like CTRL-V, but do not try to include the CTRL
219		modifier into the key.
220		Note: When CTRL-SHIFT-V is intercepted by your system (e.g.,
221		to paste text) you can often use CTRL-SHIFT-Q instead.
222		However, in some terminals (e.g. GNOME Terminal), CTRL-SHIFT-Q
223		quits the terminal without confirmation.
224
225CTRL-X		Enter CTRL-X mode.  This is a sub-mode where commands can
226		be given to complete words or scroll the window.  See
227		|i_CTRL-X| and |ins-completion|.
228
229						*i_CTRL-E*
230CTRL-E		Insert the character which is below the cursor.
231						*i_CTRL-Y*
232CTRL-Y		Insert the character which is above the cursor.
233		Note that for CTRL-E and CTRL-Y 'textwidth' is not used, to be
234		able to copy characters from a long line.
235
236						*i_CTRL-_*
237CTRL-_		Switch between insert direction, by toggling 'revins'.
238
239		CTRL-_ moves the cursor to the end of the typed text.
240
241		This command is only available when the 'allowrevins' option
242		is set.
243		Please refer to |rileft.txt| for more information about
244		right-to-left mode.
245
246						*i_CTRL-^*
247CTRL-^		Toggle the use of typing language characters.
248		When language |:lmap| mappings are defined:
249		- If 'iminsert' is 1 (langmap mappings used) it becomes 0 (no
250		  langmap mappings used).
251		- If 'iminsert' has another value it becomes 1, thus langmap
252		  mappings are enabled.
253		When no language mappings are defined:
254		- If 'iminsert' is 2 (Input Method used) it becomes 0 (no
255		  Input Method used).
256		- If 'iminsert' has another value it becomes 2, thus the Input
257		  Method is enabled.
258		When set to 1, the value of the "b:keymap_name" variable, the
259		'keymap' option or "<lang>" appears in the status line.
260		The language mappings are normally used to type characters
261		that are different from what the keyboard produces.  The
262		'keymap' option can be used to install a whole number of them.
263
264						*i_CTRL-]*
265CTRL-]		Trigger abbreviation, without inserting a character.
266
267						*i_<Insert>*
268<Insert>	Toggle between Insert and Replace mode.
269
270-----------------------------------------------------------------------
271						*i_backspacing*
272The effect of the <BS>, CTRL-W, and CTRL-U depend on the 'backspace' option
273(unless 'revins' is set).  This is a comma-separated list of items:
274
275item	    action ~
276indent	    allow backspacing over autoindent
277eol	    allow backspacing over line breaks (join lines)
278start	    allow backspacing over the start of insert; CTRL-W and CTRL-U stop
279	    once at the start of insert.
280nostop	    like start, except CTRL-W and CTRL-U do not stop at the start of
281	    insert.
282
283When 'backspace' is empty, Vi compatible backspacing is used.  You cannot
284backspace over autoindent, before column 1 or before where insert started.
285
286If the 'backspace' option does contain "eol" and the cursor is in column 1
287when one of the three keys is used, the current line is joined with the
288previous line.  This effectively deletes the <EOL> in front of the cursor.
289
290						*i_CTRL-V_digit*
291With CTRL-V the decimal, octal or hexadecimal value of a character can be
292entered directly.  This way you can enter any character, except a line break
293(<NL>, value 10).  There are five ways to enter the character value:
294
295first char	mode	     max nr of chars   max value ~
296(none)		decimal		   3		255
297o or O		octal		   3		377	 (255)
298x or X		hexadecimal	   2		ff	 (255)
299u		hexadecimal	   4		ffff	 (65535)
300U		hexadecimal	   8		7fffffff (2147483647)
301
302Normally you would type the maximum number of characters.  Thus to enter a
303space (value 32) you would type <C-V>032.  You can omit the leading zero, in
304which case the character typed after the number must be a non-digit.  This
305happens for the other modes as well: As soon as you type a character that is
306invalid for the mode, the value before it will be used and the "invalid"
307character is dealt with in the normal way.
308
309If you enter a value of 10, it will end up in the file as a 0.  The 10 is a
310<NL>, which is used internally to represent the <Nul> character.  When writing
311the buffer to a file, the <NL> character is translated into <Nul>.  The <NL>
312character is written at the end of each line.  Thus if you want to insert a
313<NL> character in a file you will have to make a line break.
314Also see 'fileformat'.
315
316						*i_CTRL-X* *insert_expand*
317CTRL-X enters a sub-mode where several commands can be used.  Most of these
318commands do keyword completion; see |ins-completion|.
319
320Two commands can be used to scroll the window up or down, without exiting
321insert mode:
322
323						*i_CTRL-X_CTRL-E*
324CTRL-X CTRL-E		scroll window one line up.
325			When doing completion look here: |complete_CTRL-E|
326
327						*i_CTRL-X_CTRL-Y*
328CTRL-X CTRL-Y		scroll window one line down.
329			When doing completion look here: |complete_CTRL-Y|
330
331After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
332one line unless that would cause the cursor to move from its current position
333in the file.  As soon as another key is pressed, CTRL-X mode is exited and
334that key is interpreted as in Insert mode.
335
336
337==============================================================================
3382. Special special keys				*ins-special-special*
339
340The following keys are special.  They stop the current insert, do something,
341and then restart insertion.  This means you can do something without getting
342out of Insert mode.  This is very handy if you prefer to use the Insert mode
343all the time, just like editors that don't have a separate Normal mode. You
344can use CTRL-O if you want to map a function key to a command.
345
346							*ins-repeat*
347The changes (inserted or deleted characters) before and after these keys can
348be undone separately.  Relative cursor-moves (the cursor keys, <S-Left>,
349<Home>, CTRL-G j, …) are part of the insert: |.| repeats the whole insert,
350including cursor-moves.  After a jump (mouse, scroll, <PageUp>, …) only the
351last change can be redone, and it behaves like an "i" command.  The |quote.|
352register always holds just the text typed after the last cursor-move.
353
354char		action	~
355-----------------------------------------------------------------------
356<Up>		cursor one line up			     *i_<Up>*
357<Down>		cursor one line down			     *i_<Down>*
358CTRL-G <Up>	cursor one line up, insert start column	     *i_CTRL-G_<Up>*
359CTRL-G k	cursor one line up, insert start column	     *i_CTRL-G_k*
360CTRL-G CTRL-K	cursor one line up, insert start column	     *i_CTRL-G_CTRL-K*
361CTRL-G <Down>	cursor one line down, insert start column    *i_CTRL-G_<Down>*
362CTRL-G j	cursor one line down, insert start column    *i_CTRL-G_j*
363CTRL-G CTRL-J	cursor one line down, insert start column    *i_CTRL-G_CTRL-J*
364<Left>		cursor one character left		     *i_<Left>*
365<Right>		cursor one character right		     *i_<Right>*
366<S-Left>	cursor one word back (like "b" command)	     *i_<S-Left>*
367<C-Left>	cursor one word back (like "b" command)	     *i_<C-Left>*
368<S-Right>	cursor one word forward (like "w" command)   *i_<S-Right>*
369<C-Right>	cursor one word forward (like "w" command)   *i_<C-Right>*
370<Home>		cursor to first char in the line	     *i_<Home>*
371<End>		cursor to after last char in the line	     *i_<End>*
372<C-Home>	cursor to first char in the file	     *i_<C-Home>*
373<C-End>		cursor to after last char in the file	     *i_<C-End>*
374<LeftMouse>	cursor to position of mouse click	     *i_<LeftMouse>*
375<S-Up>		move window one page up			     *i_<S-Up>*
376<PageUp>	move window one page up			     *i_<PageUp>*
377<S-Down>	move window one page down		     *i_<S-Down>*
378<PageDown>	move window one page down		     *i_<PageDown>*
379<ScrollWheelDown>    move window three lines down	*i_<ScrollWheelDown>*
380<S-ScrollWheelDown>  move window one page down		*i_<S-ScrollWheelDown>*
381<ScrollWheelUp>      move window three lines up		*i_<ScrollWheelUp>*
382<S-ScrollWheelUp>    move window one page up		*i_<S-ScrollWheelUp>*
383<ScrollWheelLeft>    move window six columns left	*i_<ScrollWheelLeft>*
384<S-ScrollWheelLeft>  move window one page left		*i_<S-ScrollWheelLeft>*
385<ScrollWheelRight>   move window six columns right	*i_<ScrollWheelRight>*
386<S-ScrollWheelRight> move window one page right		*i_<S-ScrollWheelRight>*
387CTRL-O		execute one command, return to Insert mode   *i_CTRL-O*
388CTRL-\ CTRL-O	like CTRL-O but don't move the cursor	     *i_CTRL-\_CTRL-O*
389CTRL-G u	close undo sequence, start new change	     *i_CTRL-G_u*
390CTRL-G U	don't start a new undo block with the next   *i_CTRL-G_U*
391		left/right cursor movement, if the cursor
392		stays within the same line
393
394-----------------------------------------------------------------------
395
396The CTRL-O command sometimes has a side effect: If the cursor was beyond the
397end of the line, it will be put on the last character in the line.  In
398mappings it's often better to use <Esc> (first put an "x" in the text, <Esc>
399will then always put the cursor on it).  Or use CTRL-\ CTRL-O, but then
400beware of the cursor possibly being beyond the end of the line.  Note that the
401command following CTRL-\ CTRL-O can still move the cursor, it is not restored
402to its original position.
403
404The CTRL-O command takes you to Normal mode.  If you then use a command enter
405Insert mode again it normally doesn't nest.  Thus when typing "a<C-O>a" and
406then <Esc> takes you back to Normal mode, you do not need to type <Esc> twice.
407An exception is when not typing the command, e.g. when executing a mapping or
408sourcing a script.  This makes mappings work that briefly switch to Insert
409mode.
410
411The shifted cursor keys are not available on all terminals.
412
413Another side effect is that a count specified before the "i" or "a" command is
414ignored.  That is because repeating the effect of the command after CTRL-O is
415too complicated.
416
417An example for using CTRL-G u: >
418
419	:inoremap <C-H> <C-G>u<C-H>
420
421This redefines the backspace key to start a new undo sequence.  You can now
422undo the effect of the backspace key, without changing what you typed before
423that, with CTRL-O u.  Another example: >
424
425	:inoremap <CR> <C-]><C-G>u<CR>
426
427This starts a new undo block at each line break.  It also expands
428abbreviations before this.
429
430An example for using CTRL-G U: >
431
432	inoremap <Left>  <C-G>U<Left>
433	inoremap <Right> <C-G>U<Right>
434	inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ?
435	 \ repeat('<C-G>U<Left>', col('.') - 1) :
436	 \ (col('.') < match(getline('.'), '\S') ?
437	 \     repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :
438	 \     repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))
439	inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.'))
440	inoremap ( ()<C-G>U<Left>
441
442This makes it possible to use the cursor keys in Insert mode, without starting
443a new undo block and therefore using |.| (redo) will work as expected.  Also
444entering a text like (with the "(" mapping from above):
445
446   Lorem ipsum (dolor
447
448will be repeatable by using |.| to the expected
449
450   Lorem ipsum (dolor)
451
452Cursor keys are captured by |.| (|ins-repeat|), so these mappings are only
453needed to keep the cursor-move from starting a new undo block.
454
455Using CTRL-O splits undo: the text typed before and after it is undone
456separately.  If you want to avoid this (e.g., in a mapping) you might be able
457to use CTRL-R = |i_CTRL-R|.  E.g., to call a function: >
458	:imap <F2> <C-R>=MyFunc()<CR>
459
460When the 'whichwrap' option is set appropriately, the <Left> and <Right>
461keys on the first/last character in the line make the cursor wrap to the
462previous/next line.
463
464The CTRL-G j and CTRL-G k commands can be used to insert text in front of a
465column.  Example: >
466   int i;
467   int j;
468Position the cursor on the first "int", type "istatic <C-G>j       ".  The
469result is: >
470   static int i;
471	  int j;
472When inserting the same text in front of the column in every line, use the
473Visual blockwise command "I" |v_b_I|.
474
475==============================================================================
4763. 'textwidth' and 'wrapmargin' options			*ins-textwidth*
477
478The 'textwidth' option can be used to automatically break a line before it
479gets too long.  Set the 'textwidth' option to the desired maximum line
480length.  If you then type more characters (not spaces or tabs), the
481last word will be put on a new line (unless it is the only word on the
482line).  If you set 'textwidth' to 0, this feature is disabled.
483
484The 'wrapmargin' option does almost the same.  The difference is that
485'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
486screen.  When using 'wrapmargin' this is equal to using 'textwidth' with a
487value equal to (columns - 'wrapmargin'), where columns is the width of the
488screen.
489
490When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
491
492If you don't really want to break the line, but view the line wrapped at a
493convenient place, see the 'linebreak' option.
494
495The line is only broken automatically when using Insert mode, or when
496appending to a line.  When in replace mode and the line length is not
497changed, the line will not be broken.
498
499Long lines are broken if you enter a non-white character after the margin.
500The situations where a line will be broken can be restricted by adding
501characters to the 'formatoptions' option:
502"l"  Only break a line if it was not longer than 'textwidth' when the insert
503     started.
504"v"  Only break at a white character that has been entered during the
505     current insert command.  This is mostly Vi-compatible.
506"lv" Only break if the line was not longer than 'textwidth' when the insert
507     started and only at a white character that has been entered during the
508     current insert command.  Only differs from "l" when entering non-white
509     characters while crossing the 'textwidth' boundary.
510
511Normally an internal function will be used to decide where to break the line.
512If you want to do it in a different way set the 'formatexpr' option to an
513expression that will take care of the line break.
514
515If you want to format a block of text, you can use the "gq" operator.  Type
516"gq" and a movement command to move the cursor to the end of the block.  In
517many cases, the command "gq}" will do what you want (format until the end of
518paragraph).  Alternatively, you can use "gqap", which will format the whole
519paragraph, no matter where the cursor currently is.  Or you can use Visual
520mode: hit "v", move to the end of the block, and type "gq".  See also |gq|.
521
522==============================================================================
5234. 'expandtab', 'softtabstop' and 'smarttab' options	*ins-expandtab*
524
525If the 'expandtab' option is on, spaces will be used to fill the amount of
526whitespace of the tab.  If you want to enter a real <Tab>, type CTRL-V first
527(use CTRL-Q when CTRL-V is mapped |i_CTRL-Q|).
528The 'expandtab' option is off by default.  Note that in Replace mode, a single
529character is replaced with several spaces.  The result of this is that the
530number of characters in the line increases.  Backspacing will delete one
531space at a time.  The original character will be put back for only one space
532that you backspace over (the last one).
533
534							*ins-softtabstop*
535When the 'softtabstop' option is non-zero, a <Tab> inserts 'softtabstop'
536positions, and a <BS> used to delete white space, will delete 'softtabstop'
537positions.  This feels like 'tabstop' was set to 'softtabstop', but a real
538<Tab> character still takes 'tabstop' positions, so your file will still look
539correct when used by other applications.
540
541If 'softtabstop' is non-zero, a <BS> will try to delete as much white space to
542move to the previous 'softtabstop' position, except when the previously
543inserted character is a space, then it will only delete the character before
544the cursor.  Otherwise you cannot always delete a single character before the
545cursor.  You will have to delete 'softtabstop' characters first, and then type
546extra spaces to get where you want to be.
547
548							*ins-smarttab*
549When the 'smarttab' option is on, the <Tab> key indents by 'shiftwidth' if the
550cursor is in leading whitespace.  The <BS> key has the opposite effect.  This
551behaves as if 'softtabstop' were set to the value of 'shiftwidth'.  This
552option allows the user to set 'softtabstop' to a value other than 'shiftwidth'
553and still use the <Tab> key for indentation.
554
555==============================================================================
5565. Replace mode				*Replace* *Replace-mode* *mode-replace*
557
558Enter Replace mode with the "R" command in normal mode.
559
560In Replace mode, one character in the line is deleted for every character you
561type.  If there is no character to delete (at the end of the line), the
562typed character is appended (as in Insert mode).  Thus the number of
563characters in a line stays the same until you get to the end of the line.
564If a <NL> is typed, a line break is inserted and no character is deleted.
565
566Be careful with <Tab> characters.  If you type a normal printing character in
567its place, the number of characters is still the same, but the number of
568columns will become smaller.
569
570If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), what
571happens is that you delete the changes.  The characters that were replaced
572are restored.  If you had typed past the existing text, the characters you
573added are deleted.  This is effectively a character-at-a-time undo.
574
575If the 'expandtab' option is on, a <Tab> will replace one character with
576several spaces.  The result of this is that the number of characters in the
577line increases.  Backspacing will delete one space at a time.  The original
578character will be put back for only one space that you backspace over (the
579last one).
580
581==============================================================================
5826. Virtual Replace mode		*vreplace-mode* *Virtual-Replace-mode*
583
584Enter Virtual Replace mode with the "gR" command in normal mode.
585
586Virtual Replace mode is similar to Replace mode, but instead of replacing
587actual characters in the file, you are replacing screen real estate, so that
588characters further on in the file never appear to move.
589
590So if you type a <Tab> it may replace several normal characters, and if you
591type a letter on top of a <Tab> it may not replace anything at all, since the
592<Tab> will still line up to the same place as before.
593
594Typing a <NL> still doesn't cause characters later in the file to appear to
595move.  The rest of the current line will be replaced by the <NL> (that is,
596they are deleted), and replacing continues on the next line.  A new line is
597NOT inserted unless you go past the end of the file.
598
599Interesting effects are seen when using CTRL-T and CTRL-D.  The characters
600before the cursor are shifted sideways as normal, but characters later in the
601line still remain still.  CTRL-T will hide some of the old line under the
602shifted characters, but CTRL-D will reveal them again.
603
604As with Replace mode, using <BS> etc will bring back the characters that were
605replaced.  This still works in conjunction with 'smartindent', CTRL-T and
606CTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.
607
608In 'list' mode, Virtual Replace mode acts as if it was not in 'list' mode,
609unless "L" is in 'cpoptions'.
610
611Note that the only situations for which characters beyond the cursor should
612appear to move are in List mode 'list', and occasionally when 'wrap' is set
613(and the line changes length to become shorter or wider than the width of the
614screen).  In other cases spaces may be inserted to avoid following characters
615to move.
616
617This mode is very useful for editing <Tab> separated columns in tables, for
618entering new data while keeping all the columns aligned.
619
620==============================================================================
6217. Insert mode completion				*ins-completion*
622
623In Insert and Replace mode, there are several commands to complete part of a
624keyword or line that has been typed.  This is useful if you are using
625complicated keywords (e.g., function names with capitals and underscores).
626
627Completion can be done for:
628
6291. Whole lines						|i_CTRL-X_CTRL-L|
6302. keywords in the current file				|i_CTRL-X_CTRL-N|
6313. keywords in 'dictionary'				|i_CTRL-X_CTRL-K|
6324. keywords in 'thesaurus', thesaurus-style		|i_CTRL-X_CTRL-T|
6335. keywords in the current and included files		|i_CTRL-X_CTRL-I|
6346. tags							|i_CTRL-X_CTRL-]|
6357. file names						|i_CTRL-X_CTRL-F|
6368. definitions or macros				|i_CTRL-X_CTRL-D|
6379. Vim command-line					|i_CTRL-X_CTRL-V|
63810. User defined completion				|i_CTRL-X_CTRL-U|
63911. omni completion					|i_CTRL-X_CTRL-O|
64012. Spelling suggestions				|i_CTRL-X_s|
64113. completions from 'complete'				|i_CTRL-N| |i_CTRL-P|
64214. contents from registers				|i_CTRL-X_CTRL-R|
643
644Additionally, |i_CTRL-X_CTRL-Z| stops completion without changing the text.
645
646All these, except CTRL-N and CTRL-P, are done in CTRL-X mode.  This is a
647sub-mode of Insert and Replace modes.  You enter CTRL-X mode by typing CTRL-X
648and one of the CTRL-X commands.  You exit CTRL-X mode by typing a key that is
649not a valid CTRL-X mode command.  Valid keys are the CTRL-X command itself,
650CTRL-N (next), and CTRL-P (previous).
651
652By default, the possible completions are showed in a menu and the first
653completion is inserted into the text.  This can be adjusted with
654'completeopt'.
655
656To get the current completion information, |complete_info()| can be used.
657Also see the 'infercase' option if you want to adjust the case of the match.
658
659When inserting a selected candidate word from the |popup-menu|, the part of
660the candidate word that does not match the query is highlighted using
661|hl-ComplMatchIns|.  If fuzzy is enabled in 'completeopt', highlighting will
662not be applied.
663
664							*complete_CTRL-E*
665When completion is active you can use CTRL-E to stop it and go back to the
666originally typed text.  The CTRL-E will not be inserted.
667
668							*complete_CTRL-Y*
669When the popup menu is displayed, CTRL-Y stops completion and accepts the
670currently selected entry.  Typing a space, Enter, or some other unprintable
671character will leave completion mode and insert that typed character. If you
672want to use <Enter> to accept a completion item, use this mapping: >vim
673    inoremap <expr> <cr> pumvisible() ? '<c-y>' : '<cr>'
674
675When the popup menu is displayed there are a few more special keys, see
676|popupmenu-keys|.
677
678Note: The keys that are valid in CTRL-X mode are not mapped.  This allows for
679`:map <C-F> <C-X><C-F>` to work.  The key that ends CTRL-X mode (any key that
680is not a valid CTRL-X mode command) is mapped. Also, when doing completion
681with 'complete' or when completion was started with |complete()| mappings
682apply as usual.
683
684								*E565*
685Note: While completion is active Insert mode can't be used recursively and
686buffer text cannot be changed.  Mappings that somehow invoke ":normal i.."
687will generate an E565 error.
688
689The following mappings are suggested to make typing the completion commands
690a bit easier (although they will hide other commands): >
691    :inoremap <C-]> <C-X><C-]>
692    :inoremap <C-F> <C-X><C-F>
693    :inoremap <C-D> <C-X><C-D>
694    :inoremap <C-L> <C-X><C-L>
695
696As a special case, typing CTRL-R to perform register insertion (see
697|i_CTRL-R|) will not exit CTRL-X mode.  This is primarily to allow the use of
698the '=' register to call some function to determine the next operation.  If
699the contents of the register (or result of the '=' register evaluation) are
700not valid CTRL-X mode keys, then CTRL-X mode will be exited as if those keys
701had been typed.
702
703For example, the following will map <Tab> to either actually insert a <Tab> if
704the current line is currently only whitespace, or start/continue a CTRL-N
705completion operation: >lua
706
707    function _G.clever_tab()
708      if vim.fn.getline('.'):sub(1, vim.fn.col('.') - 1):match('^%s*$') then
709        return vim.keycode('<Tab>')
710      else
711        return vim.keycode('<C-N>')
712      end
713    end
714    vim.keymap.set('i', '<Tab>', '<C-R>=v:lua.clever_tab()<CR>')
715
716
717
718Completing whole lines					*compl-whole-line*
719
720							*i_CTRL-X_CTRL-L*
721CTRL-X CTRL-L		Search backwards for a line that starts with the
722			same characters as those in the current line before
723			the cursor.  Indent is ignored.  The matching line is
724			inserted in front of the cursor.
725			The 'complete' option is used to decide which buffers
726			are searched for a match.  Both loaded and unloaded
727			buffers are used.
728	CTRL-L	or
729	CTRL-P		Search backwards for next matching line.  This line
730			replaces the previous matching line.
731
732	CTRL-N		Search forward for next matching line.  This line
733			replaces the previous matching line.
734
735	CTRL-X CTRL-L	After expanding a line you can additionally get the
736			line next to it by typing CTRL-X CTRL-L again, unless
737			a double CTRL-X is used.  Only works for loaded
738			buffers.
739
740Completing keywords in current file			*compl-current*
741
742							*i_CTRL-X_CTRL-P*
743							*i_CTRL-X_CTRL-N*
744CTRL-X CTRL-N		Search forwards for words that start with the keyword
745			in front of the cursor.  The found keyword is inserted
746			in front of the cursor.
747
748CTRL-X CTRL-P		Search backwards for words that start with the keyword
749			in front of the cursor.  The found keyword is inserted
750			in front of the cursor.
751
752	CTRL-N		Search forward for next matching keyword.  This
753			keyword replaces the previous matching keyword.
754
755	CTRL-P		Search backwards for next matching keyword.  This
756			keyword replaces the previous matching keyword.
757
758	CTRL-X CTRL-N or
759	CTRL-X CTRL-P	Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
760			copy the words following the previous expansion in
761			other contexts unless a double CTRL-X is used.
762
763If there is a keyword in front of the cursor (a name made out of alphabetic
764characters and characters in 'iskeyword'), it is used as the search pattern,
765with "\<" prepended (meaning: start of a word).  Otherwise "\<\k\k" is used
766as search pattern (start of any keyword of at least two characters).
767
768In Replace mode, the number of characters that are replaced depends on the
769length of the matched string.  This works like typing the characters of the
770matched string in Replace mode.
771
772If there is not a valid keyword character before the cursor, any keyword of
773at least two characters is matched.
774	e.g., to get:
775	    printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
776	just type:
777	    printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
778
779The search wraps around the end of the file, the value of 'wrapscan' is not
780used here.
781
782Multiple repeats of the same completion are skipped; thus a different match
783will be inserted at each CTRL-N and CTRL-P (unless there is only one
784matching keyword).
785
786Single character matches are never included, as they usually just get in
787the way of what you were really after.
788	e.g., to get:
789		printf("name = %s\n", name);
790	just type:
791		printf("name = %s\n", n^P);
792	or even:
793		printf("name = %s\n", ^P);
794The 'n' in '\n' is skipped.
795
796After expanding a word, you can use CTRL-X CTRL-P or CTRL-X CTRL-N to get the
797word following the expansion in other contexts.  These sequences search for
798the text just expanded and further expand by getting an extra word.  This is
799useful if you need to repeat a sequence of complicated words.  Although CTRL-P
800and CTRL-N look just for strings of at least two characters, CTRL-X CTRL-P and
801CTRL-X CTRL-N can be used to expand words of just one character.
802	e.g., to get:
803		M&eacute;xico
804	you can type:
805		M^N^P^X^P^X^P
806CTRL-N starts the expansion and then CTRL-P takes back the single character
807"M", the next two CTRL-X CTRL-P's get the words "&eacute" and ";xico".
808
809If the previous expansion was split, because it got longer than 'textwidth',
810then just the text in the current line will be used.
811
812If the match found is at the end of a line, then the first word in the next
813line will be inserted and the message "Word from other line" displayed, if
814this word is accepted the next CTRL-X CTRL-P or CTRL-X CTRL-N will search
815for those lines starting with this word.
816
817
818Completing keywords in 'dictionary'			*compl-dictionary*
819
820							*i_CTRL-X_CTRL-K*
821CTRL-X CTRL-K		Search the files given with the 'dictionary' option
822			for words that start with the keyword in front of the
823			cursor.  This is like CTRL-N, but only the dictionary
824			files are searched, not the current file.  The found
825			keyword is inserted in front of the cursor.  This
826			could potentially be pretty slow, since all matches
827			are found before the first match is used.  By default,
828			the 'dictionary' option is empty.
829			For suggestions where to find a list of words, see the
830			'dictionary' option.
831			'ignorecase', 'smartcase' and 'infercase' apply.
832
833	CTRL-K	or
834	CTRL-N		Search forward for next matching keyword.  This
835			keyword replaces the previous matching keyword.
836
837	CTRL-P		Search backwards for next matching keyword.  This
838			keyword replaces the previous matching keyword.
839
840
841Completing words in 'thesaurus'				*compl-thesaurus*
842
843							*i_CTRL-X_CTRL-T*
844CTRL-X CTRL-T		Works as CTRL-X CTRL-K, but in a special way.  It uses
845			the 'thesaurus' option instead of 'dictionary'.  If a
846			match is found in the thesaurus file, all the
847			remaining words on the same line are included as
848			matches, even though they don't complete the word.
849			Thus a word can be completely replaced.
850
851	CTRL-T	or
852	CTRL-N		Search forward for next matching keyword.  This
853			keyword replaces the previous matching keyword.
854
855	CTRL-P		Search backwards for next matching keyword.  This
856			keyword replaces the previous matching keyword.
857
858In the file used by the 'thesaurus' option each line in the file should
859contain words with similar meaning, separated by non-keyword characters (white
860space is preferred).  Maximum line length is 510 bytes.
861
862For an example, imagine the 'thesaurus' file has a line like this: >
863	angry furious mad enraged
864Placing the cursor after the letters "ang" and typing CTRL-X CTRL-T would
865complete the word "angry"; subsequent presses would change the word to
866"furious", "mad" etc.
867
868Other uses include translation between two languages, or grouping API
869functions by keyword.
870
871An English word list was added to this github issue:
872https://github.com/vim/vim/issues/629#issuecomment-443293282
873Unpack thesaurus_pkg.zip, put the thesaurus.txt file somewhere, e.g.
874~/.vim/thesaurus/english.txt, and the 'thesaurus' option to this file name.
875
876
877Completing keywords with 'thesaurusfunc'		*compl-thesaurusfunc*
878
879If the 'thesaurusfunc' option is set, then the user specified function is
880invoked to get the list of completion matches and the 'thesaurus' option is
881not used.  See |complete-functions| for an explanation of how the function is
882invoked and what it should return.
883
884Here is an example that uses the "aiksaurus" command (provided by Magnus
885Groß): >lua
886
887    vim.o.thesaurusfunc = function(findstart, base)
888      if findstart == 1 then
889	return vim.fn.searchpos('\\<', 'bnW', vim.fn.line('.'))[2] - 1
890      end
891      local res = {}
892      local h = ''
893      for _, l in ipairs(vim.fn.systemlist('aiksaurus '
894					   .. vim.fn.shellescape(base))) do
895	if l:sub(1, 4) == '=== ' then
896	  h = ('(%s)'):format((l:sub(5):gsub(' =*$', '')))
897	elseif l == 'Alphabetically similar known words are: ' then
898	  h = '🔮'
899	elseif l:match('^%a') or (h == '🔮' and l:sub(1, 1) == '\t') then
900	  local words = (l:gsub('^\t', ''))
901	  for _, val in ipairs(vim.split(words, ', ', { plain = true })) do
902	    table.insert(res, { word = val, menu = h })
903	  end
904	end
905      end
906      return res
907    end
908
909
910Completing keywords in the current and included files	*compl-keyword*
911
912The 'include' option is used to specify a line that contains an include file
913name.  The 'path' option is used to search for include files.
914
915							*i_CTRL-X_CTRL-I*
916CTRL-X CTRL-I		Search for the first keyword in the current and
917			included files that starts with the same characters
918			as those before the cursor.  The matched keyword is
919			inserted in front of the cursor.
920
921	CTRL-N		Search forwards for next matching keyword.  This
922			keyword replaces the previous matching keyword.
923			Note: CTRL-I is the same as <Tab>, which is likely to
924			be typed after a successful completion, therefore
925			CTRL-I is not used for searching for the next match.
926
927	CTRL-P		Search backward for previous matching keyword.  This
928			keyword replaces the previous matching keyword.
929
930	CTRL-X CTRL-I	Further use of CTRL-X CTRL-I will copy the words
931			following the previous expansion in other contexts
932			unless a double CTRL-X is used.
933
934Completing tags						*compl-tag*
935							*i_CTRL-X_CTRL-]*
936CTRL-X CTRL-]		Search for the first tag that starts with the same
937			characters as before the cursor.  The matching tag is
938			inserted in front of the cursor.  Alphabetic
939			characters and characters in 'iskeyword' are used
940			to decide which characters are included in the tag
941			name (same as for a keyword).  See also |CTRL-]|.
942			The 'showfulltag' option can be used to add context
943			from around the tag definition.
944	CTRL-]	or
945	CTRL-N		Search forwards for next matching tag.  This tag
946			replaces the previous matching tag.
947
948	CTRL-P		Search backward for previous matching tag.  This tag
949			replaces the previous matching tag.
950
951
952Completing file names					*compl-filename*
953							*i_CTRL-X_CTRL-F*
954CTRL-X CTRL-F		Search for the first file name that starts with the
955			same characters as before the cursor.  The matching
956			file name is inserted in front of the cursor.
957			Alphabetic characters and characters in 'isfname'
958			are used to decide which characters are included in
959			the file name.  Note: the 'path' option is not used
960			here (yet).
961	CTRL-F	or
962	CTRL-N		Search forwards for next matching file name.  This
963			file name replaces the previous matching file name.
964
965	CTRL-P		Search backward for previous matching file name.
966			This file name replaces the previous matching file
967			name.
968
969
970Completing definitions or macros			*compl-define*
971
972The 'define' option is used to specify a line that contains a definition.
973The 'include' option is used to specify a line that contains an include file
974name.  The 'path' option is used to search for include files.
975
976							*i_CTRL-X_CTRL-D*
977CTRL-X CTRL-D		Search in the current and included files for the
978			first definition (or macro) name that starts with
979			the same characters as before the cursor.  The found
980			definition name is inserted in front of the cursor.
981	CTRL-D	or
982	CTRL-N		Search forwards for next matching macro name.  This
983			macro name replaces the previous matching macro
984			name.
985
986	CTRL-P		Search backward for previous matching macro name.
987			This macro name replaces the previous matching macro
988			name.
989
990	CTRL-X CTRL-D	Further use of CTRL-X CTRL-D will copy the words
991			following the previous expansion in other contexts
992			unless a double CTRL-X is used.
993
994
995Completing Vim commands					*compl-vim*
996
997Completion is context-sensitive.  It works like on the Command-line.  It
998completes an Ex command as well as its arguments.  This is useful when writing
999a Vim script.
1000
1001							*i_CTRL-X_CTRL-V*
1002CTRL-X CTRL-V		Guess what kind of item is in front of the cursor and
1003			find the first match for it.
1004			Note: When CTRL-V is mapped you can often use CTRL-Q
1005			instead of |i_CTRL-Q|.
1006	CTRL-V	or
1007	CTRL-N		Search forwards for next match.  This match replaces
1008			the previous one.
1009
1010	CTRL-P		Search backwards for previous match.  This match
1011			replaces the previous one.
1012
1013	CTRL-X CTRL-V	Further use of CTRL-X CTRL-V will do the same as
1014			CTRL-V.  This allows mapping a key to do Vim command
1015			completion, for example: >
1016				:imap <Tab> <C-X><C-V>
1017
1018Completing contents from registers			*compl-register-words*
1019							*i_CTRL-X_CTRL-R*
1020CTRL-X CTRL-R		Guess what kind of item is in front of the cursor from
1021			all registers and find the first match for it.
1022			Further use of CTRL-R (without CTRL-X) will insert the
1023			register content, see |i_CTRL-R|.
1024			'ignorecase' applies to the matching.
1025
1026	CTRL-N		Search forwards for next match.  This match replaces
1027			the previous one.
1028
1029	CTRL-P		Search backwards for previous match.  This match
1030			replaces the previous one.
1031
1032	CTRL-X CTRL-R	Further use of CTRL-X CTRL-R will copy the line
1033			following the previous expansion in other contexts
1034			unless a double CTRL-X is used (e.g. this switches
1035			from completing register words to register contents).
1036
1037User defined completion					*compl-function*
1038
1039Completion is done by a function that can be defined by the user with the
1040'completefunc' option.  See below for how the function is called and an
1041example |complete-functions|.
1042
1043							*i_CTRL-X_CTRL-U*
1044CTRL-X CTRL-U		Guess what kind of item is in front of the cursor and
1045			find the first match for it.
1046	CTRL-U	or
1047	CTRL-N		Use the next match.  This match replaces the previous
1048			one.
1049
1050	CTRL-P		Use the previous match.  This match replaces the
1051			previous one.
1052
1053
1054Omni completion					*omnicompletion* *compl-omni*
1055
1056Completion is done by a function that can be defined by the user with the
1057'omnifunc' option.  This is to be used for filetype-specific completion.
1058
1059See below for how the function is called and an example |complete-functions|.
1060For remarks about specific filetypes see |compl-omni-filetypes|.
1061More completion scripts will appear, check www.vim.org.  Currently there is a
1062first version for C++.
1063
1064							*i_CTRL-X_CTRL-O*
1065CTRL-X CTRL-O		Guess what kind of item is in front of the cursor and
1066			find the first match for it.
1067	CTRL-O	or
1068	CTRL-N		Use the next match.  This match replaces the previous
1069			one.
1070
1071	CTRL-P		Use the previous match.  This match replaces the
1072			previous one.
1073
1074
1075Spelling suggestions					*compl-spelling*
1076
1077A word before or at the cursor is located and correctly spelled words are
1078suggested to replace it.  If there is a badly spelled word in the line, before
1079or under the cursor, the cursor is moved to after it.  Otherwise the word just
1080before the cursor is used for suggestions, even though it isn't badly spelled.
1081
1082NOTE: CTRL-S suspends display in many Unix terminals.  Use 's' instead.  Type
1083CTRL-Q to resume displaying.
1084
1085						*i_CTRL-X_CTRL-S* *i_CTRL-X_s*
1086CTRL-X CTRL-S   or
1087CTRL-X s		Locate the word in front of the cursor and find the
1088			first spell suggestion for it.
1089	CTRL-S	or
1090	CTRL-N		Use the next suggestion.  This replaces the previous
1091			one.  Note that you can't use 's' here.
1092
1093	CTRL-P		Use the previous suggestion.  This replaces the
1094			previous one.
1095
1096
1097Completing from different sources			*compl-generic*
1098
1099							*i_CTRL-N*
1100CTRL-N			Find the next match for a word ending at the cursor,
1101			using the sources specified in the 'complete' option.
1102			All sources complete from keywords, except functions,
1103			which may complete from non-keyword.  The matched
1104			text is inserted before the cursor.
1105
1106							*i_CTRL-P*
1107CTRL-P			Same as CTRL-N, but find the previous match.
1108
1109	CTRL-N		Search forward through the matches and insert the
1110			next one.
1111
1112	CTRL-P		Search backward through the matches and insert the
1113			previous one.
1114
1115	CTRL-X CTRL-N or
1116	CTRL-X CTRL-P	Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will
1117			copy the words following the previous expansion in
1118			other contexts unless a double CTRL-X is used.
1119
1120
1121Stop completion						*compl-stop*
1122
1123							*i_CTRL-X_CTRL-Z*
1124CTRL-X CTRL-Z		Stop completion without changing the text.
1125
1126
1127AUTOCOMPLETION						*ins-autocompletion*
1128
1129Vim can display a completion menu as you type, similar to using |i_CTRL-N|,
1130but triggered automatically.  See 'autocomplete'.  The menu items are
1131collected from the sources listed in the 'complete' option, in order.
1132
1133A decaying timeout keeps Vim responsive.  Sources earlier in the 'complete'
1134list get more time (higher priority), but all sources receive at least a small
1135time slice.
1136
1137This mode is fully compatible with other completion modes.  You can invoke
1138any of them at any time by typing |CTRL-X|, which temporarily suspends
1139autocompletion.  To use |i_CTRL-N| or |i_CTRL-X_CTRL-N| specifically, press
1140|CTRL-E| first to dismiss the popup menu (see |complete_CTRL-E|).
1141
1142						*ins-autocompletion-example*
1143Example setup ~
1144A typical configuration for automatic completion with a popup menu: >
1145	set autocomplete
1146	set complete=.^5,w^5,b^5,u^5
1147	set completeopt=popup
1148
1149	inoremap <silent><expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
1150	inoremap <silent><expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
1151<
1152This enables automatic completion with suggestions from the current buffer,
1153other windows, and listed buffers, displayed in a popup menu.  Each source is
1154limited to 5 candidates.  <Tab> and <S-Tab> move through the items when the
1155menu is visible.  Optionally, add "preinsert" to 'completeopt' to insert the
1156longest common prefix automatically.  You can also add other completion
1157sources to 'complete' as needed.
1158
1159See also 'autocomplete', 'autocompletedelay' and 'autocompletetimeout'.
1160
1161For command-line autocompletion, see |cmdline-autocompletion|.
1162
1163To get LSP-driven auto-completion, see |lsp-completion|.
1164
1165
1166FUNCTIONS FOR FINDING COMPLETIONS			*complete-functions*
1167
1168This applies to 'completefunc', 'thesaurusfunc' and 'omnifunc'.
1169
1170The function is called in two different ways:
1171- First the function is called to find the start of the text to be completed.
1172- Later the function is called to actually find the matches.
1173
1174On the first invocation the arguments are:
1175   a:findstart  1
1176   a:base	empty
1177
1178The function must return the column where the completion starts.  It must be a
1179number between zero and the cursor column "col('.')".  This involves looking
1180at the characters just before the cursor and including those characters that
1181could be part of the completed item.  The text between this column and the
1182cursor column will be replaced with the matches.  If the returned value is
1183larger than the cursor column, the cursor column is used.
1184
1185Negative return values:
1186   -2	To cancel silently and stay in completion mode.
1187   -3	To cancel silently and leave completion mode.
1188   Another negative value: completion starts at the cursor column
1189
1190On the second invocation the arguments are:
1191   a:findstart  0
1192   a:base	the text with which matches should match; the text that was
1193		located in the first call (can be empty)
1194
1195The function must return a List with the matching words.  These matches
1196usually include the "a:base" text.  When there are no matches return an empty
1197List.  Note that the cursor may have moved since the first invocation, the
1198text may have been changed.
1199
1200In order to return more information than the matching words, return a Dict
1201that contains the List.  The Dict can have these items:
1202	words		The List of matching words (mandatory).
1203	refresh		A string to control re-invocation of the function
1204			(optional).
1205			The only value currently recognized is "always", the
1206			effect is that the function is called whenever the
1207			leading text is changed.
1208Other items are ignored.
1209
1210For acting upon end of completion, see the |CompleteDonePre| and
1211|CompleteDone| autocommand event.
1212
1213For example, the function can contain this: >
1214	let matches = ... list of words ...
1215	return {'words': matches, 'refresh': 'always'}
1216<
1217If looking for matches is time-consuming, |complete_check()| may be used to
1218maintain responsiveness.
1219
1220						*complete-items*
1221Each list item can either be a string or a Dictionary.  When it is a string it
1222is used as the completion.  When it is a Dictionary it can contain these
1223items:
1224	word		the text that will be inserted, mandatory
1225	abbr		abbreviation of "word"; when not empty it is used in
1226			the menu instead of "word"
1227	menu		extra text for the popup menu, displayed after "word"
1228			or "abbr"
1229	info		more information about the item, can be displayed in a
1230			preview window
1231	kind		single letter indicating the type of completion
1232	icase		when non-zero case is to be ignored when comparing
1233			items to be equal; when omitted zero is used, thus
1234			items that only differ in case are added
1235	equal		when non-zero, always treat this item to be equal when
1236			comparing.  Which means, "equal=1" disables filtering
1237			of this item.
1238	dup		when non-zero this match will be added even when an
1239			item with the same word is already present.
1240	empty		when non-zero this match will be added even when it is
1241			an empty string
1242	user_data	custom data which is associated with the item and
1243			available in |v:completed_item|; it can be any type;
1244			defaults to an empty string
1245	abbr_hlgroup	an additional highlight group whose attributes are
1246			combined with |hl-PmenuSel| and |hl-Pmenu| or
1247			|hl-PmenuMatchSel| and |hl-PmenuMatch| highlight
1248			attributes in the popup menu to apply cterm and gui
1249			properties (with higher priority) like strikethrough
1250			to the completion items abbreviation.
1251			The group can be defined later.
1252	kind_hlgroup	an additional highlight group specifically for setting
1253			the highlight attributes of the completion kind.  When
1254			this field is present, it will override the
1255			|hl-PmenuKind| highlight group, allowing for the
1256			customization of ctermfg and guifg properties for the
1257			completion kind.
1258			The group can be defined later.
1259	match		See "matches" in |complete_info()|.
1260	preselect	when non-zero this item is selected by default in the
1261			popup menu. Only if 'completeopt' has "preselect". If
1262			multiple items have "preselect" set, the first one is
1263			used.
1264	commit_chars	Characters that accept the completion when typed while
1265			the item is selected: the match is accepted as with
1266			|complete_CTRL-Y|, then the character is inserted as
1267			usual.  Takes precedence over extending the leader.
1268			Only while the popup menu is displayed.  Control
1269			characters (below 0x20) are ignored.
1270
1271All of these except "icase", "equal", "dup" and "empty" must be a string.  If
1272an item does not meet these requirements then an error message is given and
1273further items in the list are not used.  You can mix string and Dictionary
1274items in the returned list.
1275
1276The "menu" item is used in the popup menu and may be truncated, thus it should
1277be relatively short.  The "info" item can be longer, it will  be displayed in
1278the preview window when "preview" appears in 'completeopt'.  The "info" item
1279will also remain displayed after the popup menu has been removed.  This is
1280useful for function arguments.  Use a single space for "info" to remove
1281existing text in the preview window.  The size of the preview window is three
1282lines, but 'previewheight' is used when it has a value of 1 or 2.
1283
1284The "kind" item uses a single letter to indicate the kind of completion.  This
1285may be used to show the completion differently (different color or icon).
1286Currently these types can be used:
1287	v	variable
1288	f	function or method
1289	m	member of a struct or class
1290	t	typedef
1291	d	#define or macro
1292
1293When searching for matches takes some time call |complete_add()| to add each
1294match to the total list.  These matches should then not appear in the returned
1295list!  Call |complete_check()| now and then to allow the user to press a key
1296while still searching for matches.  Stop searching when it returns non-zero.
1297
1298							*E840*
1299The function is allowed to move the cursor, it is restored afterwards.
1300The function is not allowed to move to another window or delete text.
1301
1302An example that completes the names of the months: >lua
1303    vim.o.completefunc = function(findstart, base)
1304      if findstart == 1 then -- Locate the start of the word.
1305        local line = vim.fn.getline('.')
1306        local start = vim.fn.col('.') - 1
1307        while start > 0 and line:sub(start, start):match('%a') do
1308          start = start - 1
1309        end
1310        return start
1311      else -- Find months matching with "base".
1312        local res = {}
1313        local months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'
1314        for m in months:gmatch('%a+') do
1315          if vim.startswith(m, base) then
1316            table.insert(res, m)
1317          end
1318        end
1319        return res
1320      end
1321    end
1322<
1323The same, but now pretending searching for matches is slow: >lua
1324    vim.o.completefunc = function(findstart, base)
1325      if findstart == 1 then -- Locate the start of the word.
1326        local line = vim.fn.getline('.')
1327        local start = vim.fn.col('.') - 1
1328        while start > 0 and line:sub(start, start):match('%a') do
1329          start = start - 1
1330        end
1331        return start
1332      else -- Find months matching with "base".
1333        local months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'
1334        for m in months:gmatch('%a+') do
1335          if vim.startswith(m, base) then
1336            vim.fn.complete_add(m)
1337          end
1338          vim.uv.sleep(300) -- Simulate searching for next match.
1339          if vim.fn.complete_check() ~= 0 then
1340            break
1341          end
1342        end
1343        return {}
1344      end
1345    end
1346<
1347
1348INSERT COMPLETION POPUP MENU				*ins-completion-menu*
1349							*popupmenu-completion*
1350Vim can display the matches in a popup menu.
1351
1352The menu is used when:
1353- The 'completeopt' option contains "menu" or "menuone".
1354- There are at least two matches.  One if "menuone" is used.
1355
1356The 'pumheight' option can be used to set a maximum height.  The default is to
1357use all space available.
1358The 'pumwidth' option can be used to set a minimum width.  The default is 15
1359characters.
1360
1361							*compl-states*
1362There are three states:
13631. A complete match has been inserted, e.g., after using CTRL-N or CTRL-P.
13642. A cursor key has been used to select another match.  The match was not
1365   inserted then, only the entry in the popup menu is highlighted.
13663. Only part of a match has been inserted and characters were typed or the
1367   backspace key was used.  The list of matches was then adjusted for what is
1368   in front of the cursor.
1369
1370You normally start in the first state, with the first match being inserted.
1371When "longest" is in 'completeopt' and there is more than one match you start
1372in the third state.
1373
1374If you select another match, e.g., with CTRL-N or CTRL-P, you go to the first
1375state.  This doesn't change the list of matches.
1376
1377When you are back at the original text then you are in the third state.  To
1378get there right away you can use a mapping that uses CTRL-P right after
1379starting the completion: >
1380	:imap <F7> <C-N><C-P>
1381<
1382						*popupmenu-keys*
1383In the first state these keys have a special meaning:
1384<BS> and CTRL-H   Delete one character, find the matches for the word before
1385		  the cursor.  This reduces the list of matches, often to one
1386		  entry, and switches to the second state.
1387		  When 'autocomplete' is active, clears the selected item in
1388		  the menu.
1389Any non-special character:
1390		  Stop completion without changing the match and insert the
1391		  typed character.
1392
1393In the second and third state these keys have a special meaning:
1394<BS> and CTRL-H   Delete one character, find the matches for the shorter word
1395		  before the cursor.  This may find more matches.
1396		  When 'autocomplete' is active, clears the selected item in
1397		  the menu.
1398CTRL-L		  Add one character from the current match, may reduce the
1399		  number of matches.
1400any printable, non-white character:
1401		  Add this character and reduce the number of matches.
1402
1403In all three states these can be used:
1404CTRL-Y		  Yes: Accept the currently selected match and stop
1405		  completion.
1406CTRL-E		  End completion, go back to what was there before selecting a
1407		  match (what was typed or longest common string).
1408<PageUp>	  Select a match several entries back, but don't insert it.
1409<PageDown>	  Select a match several entries further, but don't insert it.
1410<Up>		  Select the previous match, as if CTRL-P was used, but don't
1411		  insert it.
1412<Down>		  Select the next match, as if CTRL-N was used, but don't
1413		  insert it.
1414<Space> or <Tab>  Stop completion without changing the match and insert the
1415		  typed character.
1416
1417The behavior of the <Enter> key depends on the state you are in:
1418first state:	  Use the text as it is and insert a line break.
1419second state:	  Insert the currently selected match.
1420third state:	  Use the text as it is and insert a line break.
1421
1422In other words: If you used the cursor keys to select another entry in the
1423list of matches then the <Enter> key inserts that match.  If you typed
1424something else then <Enter> inserts a line break.
1425
1426
1427The colors of the menu can be changed with these highlight groups:
1428Pmenu		normal item  |hl-Pmenu|
1429PmenuSel	selected item  |hl-PmenuSel|
1430PmenuSbar	scrollbar  |hl-PmenuSbar|
1431PmenuThumb	thumb of the scrollbar  |hl-PmenuThumb|
1432
1433There are no special mappings for when the popup menu is visible.  However,
1434you can use an Insert mode mapping that checks the |pumvisible()| function to
1435do something different.  Example: >
1436	:inoremap <Down> <C-R>=pumvisible() ? "\<lt>C-N>" : "\<lt>Down>"<CR>
1437
1438You can use of <expr> in mapping to have the popup menu used when typing a
1439character and some condition is met.  For example, for typing a dot: >
1440	inoremap <expr> . MayComplete()
1441	func MayComplete()
1442	    if (can complete)
1443	      return ".\<C-X>\<C-O>"
1444	    endif
1445	    return '.'
1446	endfunc
1447
1448See |:map-<expr>| for more info.
1449
1450
1451FILETYPE-SPECIFIC REMARKS FOR OMNI COMPLETION	    *compl-omni-filetypes*
1452
1453The file used for {filetype} should be autoload/{filetype}complete.vim
1454in 'runtimepath'.  Thus for "java" it is autoload/javacomplete.vim.
1455
1456
1457C							*ft-c-omni*
1458
1459Completion of C code requires a tags file.  You should use Universal/
1460Exuberant ctags, because it adds extra information that is needed for
1461completion.  You can find it here:
1462	Universal Ctags: https://ctags.io
1463
1464Universal Ctags is preferred, Exuberant Ctags is no longer maintained.
1465
1466If you want to complete system functions you can do something like this.  Use
1467ctags to generate a tags file for all the system header files: >
1468	% ctags -R -f ~/.config/nvim/systags /usr/include /usr/local/include
1469In your vimrc file add this tags file to the 'tags' option: >
1470	set tags+=~/.config/nvim/systags
1471
1472When using CTRL-X CTRL-O after a name without any "." or "->" it is completed
1473from the tags file directly.  This works for any identifier, also function
1474names.  If you want to complete a local variable name, which does not appear
1475in the tags file, use CTRL-P instead.
1476
1477When using CTRL-X CTRL-O after something that has "." or "->" Vim will attempt
1478to recognize the type of the variable and figure out what members it has.
1479This means only members valid for the variable will be listed.
1480
1481When a member name already was complete, CTRL-X CTRL-O will add a "." or
1482"->" for composite types.
1483
1484Vim doesn't include a C compiler, only the most obviously formatted
1485declarations are recognized.  Preprocessor stuff may cause confusion.
1486When the same structure name appears in multiple places all possible members
1487are included.
1488
1489
1490CSS							*ft-css-omni*
1491
1492Complete properties and their appropriate values according to CSS 2.1
1493specification.
1494
1495
1496HTML							*ft-html-omni*
1497XHTML							*ft-xhtml-omni*
1498
1499CTRL-X CTRL-O provides completion of various elements of (X)HTML files.  It is
1500designed to support writing of XHTML 1.0 Strict files but will also work for
1501other versions of HTML.  Features:
1502
1503- after "<" complete tag name depending on context (no div suggestion inside
1504  of an a tag); '/>' indicates empty tags
1505- inside of tag complete proper attributes (no width attribute for an a tag);
1506  show also type of attribute; "*" indicates required attributes
1507- when attribute has limited number of possible values help to complete them
1508- complete names of entities
1509- complete values of "class" and "id" attributes with data obtained from
1510  <style> tag and included CSS files
1511- when completing value of "style" attribute or working inside of "style" tag
1512  switch to |ft-css-omni| completion
1513- when completing values of events attributes or working inside of "script"
1514  tag switch to |ft-javascript-omni| completion
1515- when used after "</" CTRL-X CTRL-O will close the last opened tag
1516
1517Note: When used first time completion menu will be shown with little delay
1518- this is time needed for loading of data file.
1519Note: Completion may fail in badly formatted documents.  In such case try to
1520run |:make| command to detect formatting problems.
1521
1522
1523HTML flavor						*html-flavor*
1524
1525The default HTML completion depends on the filetype.  For HTML files it is
1526HTML 4.01 Transitional ('filetype' is "html"), for XHTML it is XHTML 1.0
1527Strict ('filetype' is "xhtml").
1528
1529When doing completion outside of any other tag you will have possibility to
1530choose DOCTYPE and the appropriate data file will be loaded and used for all
1531next completions.
1532
1533More about format of data file in |xml-omni-datafile|.  Some of the data files
1534may be found on the Vim website (|www|).
1535
1536Note that b:html_omni_flavor may point to a file with any XML data.  This
1537makes possible to mix PHP (|ft-php-omni|) completion with any XML dialect
1538(assuming you have data file for it).  Without setting that variable XHTML 1.0
1539Strict will be used.
1540
1541
1542JAVASCRIPT					       *ft-javascript-omni*
1543
1544Completion of most elements of JavaScript language and DOM elements.
1545
1546Complete:
1547
1548- variables
1549- function name; show function arguments
1550- function arguments
1551- properties of variables trying to detect type of variable
1552- complete DOM objects and properties depending on context
1553- keywords of language
1554
1555Completion works in separate JavaScript files (&ft==javascript), inside of
1556<script> tag of (X)HTML and in values of event attributes (including scanning
1557of external files).
1558
1559DOM compatibility
1560
1561At the moment (beginning of 2006) there are two main browsers - MS Internet
1562Explorer and Mozilla Firefox.  These two applications are covering over 90% of
1563market.  Theoretically standards are created by W3C organisation
1564(https://www.w3.org/) but they are not always followed/implemented.
1565>
1566		IE	FF	W3C  Omni completion ~
1567		+/-	+/-	+    +		     ~
1568		+	+	-    +		     ~
1569		+	-	-    -		     ~
1570		-	+	-    -		     ~
1571<
1572Regardless from state of implementation in browsers but if element is defined
1573in standards, completion plugin will place element in suggestion list.  When
1574both major engines implemented element, even if this is not in standards it
1575will be suggested.  All other elements are not placed in suggestion list.
1576
1577
1578LUA                                                     *ft-lua-omni*
1579
1580Lua |ftplugin| sets 'omnifunc' to |vim.lua_omnifunc()|.
1581
1582
1583PHP							*ft-php-omni*
1584
1585Completion of PHP code requires a tags file for completion of data from
1586external files and for class aware completion.  You should use Universal/
1587Exuberant ctags version 5.5.4 or newer.  You can find it here:
1588
1589	Universal Ctags: https://ctags.io
1590
1591Script completes:
1592
1593- after $ variables name
1594  - if variable was declared as object add "->", if tags file is available
1595    show name of class
1596  - after "->" complete only function and variable names specific for given
1597    class.  To find class location and contents tags file is required.
1598    Because PHP isn't strongly typed language user can use @var tag to declare
1599    class: >
1600
1601	/* @var $myVar myClass */
1602	$myVar->
1603<
1604    Still, to find myClass contents tags file is required.
1605
1606- function names with additional info:
1607  - in case of built-in functions list of possible arguments and after | type
1608    data returned by function
1609  - in case of user function arguments and name of file where function was
1610    defined (if it is not current file)
1611
1612- constants names
1613- class names after "new" declaration
1614
1615
1616Note: when doing completion first time Vim will load all necessary data into
1617memory.  It may take several seconds.  After next use of completion delay
1618should not be noticeable.
1619
1620Script detects if cursor is inside <?php ?> tags.  If it is outside it will
1621automatically switch to HTML/CSS/JavaScript completion.  Note: contrary to
1622original HTML files completion of tags (and only tags) isn't context aware.
1623
1624
1625RUBY						 *ft-ruby-omni*
1626
1627NOTE: |compl-omni| for Ruby code requires |provider-ruby| to be installed.
1628
1629Ruby completion will parse your buffer on demand in order to provide a list of
1630completions.  These completions will be drawn from modules loaded by "require"
1631and modules defined in the current buffer.
1632
1633The completions provided by CTRL-X CTRL-O are sensitive to the context:
1634
1635	  CONTEXT			   COMPLETIONS PROVIDED ~
1636
1637 1. Not inside a class definition:   Classes, constants and globals
1638 2. Inside a class definition:	     Methods or constants defined in the class
1639 3. After '.', '::' or ':':	     Methods applicable to the object being
1640				     dereferenced
1641 4. After ':' or ':foo':	     Symbol name (beginning with "foo")
1642
1643Notes:
1644- Vim will load/evaluate code in order to provide completions.  This may
1645  cause some code execution, which may be a concern.  This is no longer
1646  enabled by default, to enable this feature add >
1647     let g:rubycomplete_buffer_loading = 1
1648- In context 1 above, Vim can parse the entire buffer to add a list of
1649  classes to the completion results.  This feature is turned off by default,
1650  to enable it add >
1651     let g:rubycomplete_classes_in_global = 1
1652<  to your vimrc
1653- In context 2 above, anonymous classes are not supported.
1654- In context 3 above, Vim will attempt to determine the methods supported by
1655  the object.
1656- Vim can detect and load the Rails environment for files within a rails
1657  project.  The feature is disabled by default, to enable it add >
1658     let g:rubycomplete_rails = 1
1659<  to your vimrc
1660
1661
1662SYNTAX							*ft-syntax-omni*
1663
1664Vim has the ability to color syntax highlight nearly 500 languages.  Part of
1665this highlighting includes knowing what keywords are part of a language.  Many
1666filetypes already have custom completion scripts written for them, the
1667syntaxcomplete plugin provides basic completion for all other filetypes.  It
1668does this by populating the omni completion list with the text Vim already
1669knows how to color highlight.  It can be used for any filetype and provides a
1670minimal language-sensitive completion.
1671
1672To enable syntax code completion you can run: >
1673    setlocal omnifunc=syntaxcomplete#Complete
1674
1675You can automate this by placing the following in your |init.vim| (after any
1676":filetype" command): >
1677    if has("autocmd") && exists("+omnifunc")
1678	autocmd Filetype *
1679		    \	if &omnifunc == "" |
1680		    \		setlocal omnifunc=syntaxcomplete#Complete |
1681		    \	endif
1682    endif
1683
1684The above will set completion to this script only if a specific plugin does
1685not already exist for that filetype.
1686
1687Each filetype can have a wide range of syntax items.  The plugin allows you to
1688customize which syntax groups to include or exclude from the list.  Let's have
1689a look at the PHP filetype to see how this works.
1690
1691If you edit a file called, index.php, run the following command: >
1692    syntax list
1693
1694The first thing you will notice is that there are many different syntax
1695groups.  The PHP language can include elements from different languages like
1696HTML, JavaScript and many more.  The syntax plugin will only include syntax
1697groups that begin with the filetype, "php", in this case.  For example these
1698syntax groups are included by default with the PHP: phpEnvVar, phpIntVar,
1699phpFunctions.
1700
1701If you wish non-filetype syntax items to also be included, you can use a
1702regular expression syntax (added in version 13.0 of
1703autoload/syntaxcomplete.vim) to add items.  Looking at the output from
1704":syntax list" while editing a PHP file I can see some of these entries: >
1705    htmlArg,htmlTag,htmlTagName,javaScriptStatement,javaScriptGlobalObjects
1706
1707To pick up any JavaScript and HTML keyword syntax groups while editing a PHP
1708file, you can use 3 different regexs, one for each language.  Or you can
1709simply restrict the include groups to a particular value, without using
1710a regex string: >
1711    let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+'
1712    let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'
1713<
1714The basic form of this variable is: >
1715    let g:omni_syntax_group_include_{filetype} = 'regex,comma,separated'
1716
1717The PHP language has an enormous number of items which it knows how to syntax
1718highlight.  These items will be available within the omni completion list.
1719
1720Some people may find this list unwieldy or are only interested in certain
1721items.  There are two ways to prune this list (if necessary).  If you find
1722certain syntax groups you do not wish displayed you can use two different
1723methods to identify these groups.  The first specifically lists the syntax
1724groups by name.  The second uses a regular expression to identify both
1725syntax groups.  Simply add one the following to your vimrc: >
1726    let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant'
1727    let g:omni_syntax_group_exclude_php = 'php\w*Constant'
1728
1729Add as many syntax groups to this list by comma separating them.  The basic
1730form of this variable is: >
1731    let g:omni_syntax_group_exclude_{filetype} = 'regex,comma,separated'
1732
1733You can create as many of these variables as you need, varying only the
1734filetype at the end of the variable name.
1735
1736The plugin uses the isKeyword option to determine where word boundaries are
1737for the syntax items.  For example, in the Scheme language completion should
1738include the "-", call-with-output-file.  Depending on your filetype, this may
1739not provide the words you are expecting.  Setting the
1740g:omni_syntax_use_iskeyword option to 0 will force the syntax plugin to break
1741on word characters.  This can be controlled adding the following to your
1742vimrc: >
1743    let g:omni_syntax_use_iskeyword = 0
1744
1745For plugin developers, the plugin exposes a public function
1746syntaxcomplete#OmniSyntaxList.  This function can be used to request a List of
1747syntax items.  When editing a SQL file (:e syntax.sql) you can use the
1748":syntax list" command to see the various groups and syntax items.  For
1749example: >
1750    syntax list
1751
1752Yields data similar to this: >
1753    sqlOperator    xxx some prior all like and any escape exists in is not
1754                       or intersect minus between distinct
1755                       links to Operator
1756    sqlType        xxx varbit varchar nvarchar bigint int uniqueidentifier
1757                       date money long tinyint unsigned xml text smalldate
1758                       double datetime nchar smallint numeric time bit char
1759                       varbinary binary smallmoney
1760                       image float integer timestamp real decimal
1761
1762There are two syntax groups listed here: sqlOperator and sqlType.  To retrieve
1763a List of syntax items you can call syntaxcomplete#OmniSyntaxList a number of
1764different ways.  To retrieve all syntax items regardless of syntax group:  >
1765    echo syntaxcomplete#OmniSyntaxList( [] )
1766
1767To retrieve only the syntax items for the sqlOperator syntax group: >
1768    echo syntaxcomplete#OmniSyntaxList( ['sqlOperator'] )
1769
1770To retrieve all syntax items for both the sqlOperator and sqlType groups: >
1771    echo syntaxcomplete#OmniSyntaxList( ['sqlOperator', 'sqlType'] )
1772
1773A regular expression can also be used: >
1774    echo syntaxcomplete#OmniSyntaxList( ['sql\w\+'] )
1775
1776From within a plugin, you would typically assign the output to a List: >
1777    let myKeywords = []
1778    let myKeywords = syntaxcomplete#OmniSyntaxList( ['sqlKeyword'] )
1779
1780
1781SQL							*ft-sql-omni*
1782
1783Completion for the SQL language includes statements, functions, keywords.
1784It will also dynamically complete tables, procedures, views and column lists
1785with data pulled directly from within a database.  For detailed instructions
1786and a tutorial see |omni-sql-completion|.
1787
1788The SQL completion plugin can be used in conjunction with other completion
1789plugins.  For example, the PHP filetype has its own completion plugin.
1790Since PHP is often used to generate dynamic website by accessing a database,
1791the SQL completion plugin can also be enabled.  This allows you to complete
1792PHP code and SQL code at the same time.
1793
1794
1795XML							*ft-xml-omni*
1796
1797Vim 7 provides a mechanism for context aware completion of XML files.  It
1798depends on a special |xml-omni-datafile| and two commands: |:XMLns| and
1799|:XMLent|.  Features are:
1800
1801- after "<" complete the tag name, depending on context
1802- inside of a tag complete proper attributes
1803- when an attribute has a limited number of possible values help to complete
1804  them
1805- complete names of entities (defined in |xml-omni-datafile| and in the
1806  current file with "<!ENTITY" declarations)
1807- when used after "</" CTRL-X CTRL-O will close the last opened tag
1808
1809Format of XML data file					*xml-omni-datafile*
1810
1811XML data files are stored in the "autoload/xml" directory in 'runtimepath'.
1812Vim distribution provides examples of data files in the
1813"$VIMRUNTIME/autoload/xml" directory.  They have a meaningful name which will
1814be used in commands.  It should be a unique name which will not create
1815conflicts.  For example, the name xhtml10s.vim means it is the data file for
1816XHTML 1.0 Strict.
1817
1818Each file contains a variable with a name like g:xmldata_xhtml10s .  It is
1819a compound from two parts:
1820
18211. "g:xmldata_"  general prefix, constant for all data files
18222. "xhtml10s"    the name of the file and the name of the described XML
1823		 dialect; it will be used as an argument for the |:XMLns|
1824		 command
1825
1826Part two must be exactly the same as name of file.
1827
1828The variable is a |Dictionary|.  Keys are tag names and each value is a two
1829element |List|.  The first element of the List is also a List with the names
1830of possible children.  The second element is a |Dictionary| with the names of
1831attributes as keys and the possible values of attributes as values.  Example: >
1832
1833    let g:xmldata_crippled = {
1834    \ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"],
1835    \ 'vimxmlroot': ['tag1'],
1836    \ 'tag1':
1837    \ [ ['childoftag1a', 'childoftag1b'], {'attroftag1a': [],
1838    \ 'attroftag1b': ['valueofattr1', 'valueofattr2']}],
1839    \ 'childoftag1a':
1840    \ [ [], {'attrofchild': ['attrofchild']}],
1841    \ 'childoftag1b':
1842    \ [ ['childoftag1a'], {'attrofchild': []}],
1843    \ "vimxmltaginfo": {
1844    \ 'tag1': ['Menu info', 'Long information visible in preview window']},
1845    \ 'vimxmlattrinfo': {
1846    \ 'attrofchild': ['Menu info', 'Long information visible in preview window']}}
1847
1848This example would be put in the "autoload/xml/crippled.vim" file and could
1849help to write this file: >
1850
1851    <tag1 attroftag1b="valueofattr1">
1852        <childoftag1a attrofchild>
1853                &amp; &lt;
1854        </childoftag1a>
1855        <childoftag1b attrofchild="5">
1856            <childoftag1a>
1857                &gt; &apos; &quot;
1858            </childoftag1a>
1859        </childoftag1b>
1860    </tag1>
1861
1862In the example four special elements are visible:
1863
18641. "vimxmlentities" - a special key with List containing entities of this XML
1865   dialect.
18662. If the list containing possible values of attributes has one element and
1867   this element is equal to the name of the attribute this attribute will be
1868   treated as boolean and inserted as "attrname" and not as 'attrname="'
18693. "vimxmltaginfo" - a special key with a Dictionary containing tag
1870   names as keys and two element List as values, for additional menu info and
1871   the long description.
18724. "vimxmlattrinfo" - special key with Dictionary containing attribute names
1873   as keys and two element List as values, for additional menu info and long
1874   description.
1875
1876Note: Tag names in the data file MUST not contain a namespace description.
1877Check xsl.vim for an example.
1878Note: All data and functions are publicly available as global
1879variables/functions and can be used for personal editing functions.
1880
1881
1882DTD -> Vim							*dtd2vim*
1883
1884On |www| is the script |dtd2vim| which parses DTD and creates an XML data file
1885for Vim XML omni completion.
1886
1887    dtd2vim: https://www.vim.org/scripts/script.php?script_id=1462
1888
1889Check the beginning of that file for usage details.
1890The script requires perl and:
1891
1892    perlSGML: https://savannah.nongnu.org/projects/perlsgml
1893
1894
1895Commands
1896
1897:XMLns {name} [{namespace}]					*:XMLns*
1898
1899Vim has to know which data file should be used and with which namespace.  For
1900loading of the data file and connecting data with the proper namespace use
1901|:XMLns| command.  The first (obligatory) argument is the name of the data
1902(xhtml10s, xsl).  The second argument is the code of namespace (h, xsl).  When
1903used without a second argument the dialect will be used as default - without
1904namespace declaration.  For example to use XML completion in .xsl files: >
1905
1906	:XMLns xhtml10s
1907	:XMLns xsl xsl
1908
1909
1910:XMLent {name}							*:XMLent*
1911
1912By default entities will be completed from the data file of the default
1913namespace.  The XMLent command should be used in case when there is no default
1914namespace: >
1915
1916	:XMLent xhtml10s
1917
1918Usage
1919
1920While used in this situation (after declarations from previous part, | is
1921cursor position): >
1922
1923	<|
1924
1925Will complete to an appropriate XHTML tag, and in this situation: >
1926
1927	<xsl:|
1928
1929Will complete to an appropriate XSL tag.
1930
1931
1932The script xmlcomplete.vim, provided through the |autoload| mechanism,
1933has the xmlcomplete#GetLastOpenTag() function which can be used in XML files
1934to get the name of the last open tag (b:unaryTagsStack has to be defined): >
1935
1936	:echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
1937
1938
1939
1940==============================================================================
19418. Insert mode commands					*inserting*
1942
1943The following commands can be used to insert new text into the buffer.  They
1944can all be undone and repeated with the "." command.
1945
1946							*a*
1947a			Append text after the cursor [count] times.  If the
1948			cursor is in the first column of an empty line Insert
1949			starts there.  But not when 'virtualedit' is set!
1950
1951							*A*
1952A			Append text at the end of the line [count] times.
1953			For using "A" in Visual block mode see |v_b_A|.
1954
1955<insert>	or				*i* *insert* *<Insert>*
1956i			Insert text before the cursor [count] times.
1957			When using CTRL-O in Insert mode |i_CTRL-O| the count
1958			is not supported.
1959
1960							*I*
1961I			Insert text before the first non-blank in the line
1962			[count] times.
1963			For using "I" in Visual block mode see |v_b_I|.
1964
1965							*gI*
1966gI			Insert text in column 1 [count] times.
1967
1968							*gi*
1969gi			Insert text in the same position as where Insert mode
1970			was stopped last time in the current buffer.
1971			This uses the |'^| mark.  It's different from "`^i"
1972			when the mark is past the end of the line.
1973			The position is corrected for inserted/deleted lines,
1974			but NOT for inserted/deleted characters.
1975			When the |:keepjumps| command modifier is used the |'^|
1976			mark won't be changed.
1977
1978							*o*
1979o			Begin a new line below the cursor and insert text,
1980			repeat [count] times.
1981
1982							*O*
1983O			Begin a new line above the cursor and insert text,
1984			repeat [count] times.
1985
1986These commands are used to start inserting text.  You can end insert mode with
1987<Esc>.  See |mode-ins-repl| for the other special characters in Insert mode.
1988The effect of [count] takes place after Insert mode is exited.
1989
1990The following |default-mappings| insert text, but stay in normal mode:
1991
1992							*]<Space>*
1993]<Space>		Insert an empty line below the cursor without leaving
1994			Normal mode, repeat [count] times.
1995
1996							*[<Space>*
1997[<Space>		Insert an empty line above the cursor without leaving
1998			Normal mode, repeat [count] times.
1999
2000When 'autoindent' is on, the indent for a new line is obtained from the
2001previous line.  When 'smartindent' or 'cindent' is on, the indent for a line
2002is automatically adjusted for C programs.
2003
2004'formatoptions' can be set to copy the comment leader when opening a new
2005line.
2006
2007'textwidth' can be set to the maximum width for a line.  When a line becomes
2008too long when appending characters a line break is automatically inserted.
2009
2010
2011==============================================================================
20129. Ex insert commands					*inserting-ex*
2013
2014							*:a* *:append*
2015:{range}a[ppend][!]	Insert several lines of text below the specified
2016			line.  If the {range} is missing, the text will be
2017			inserted after the current line.
2018			Adding [!] toggles 'autoindent' for the time this
2019			command is executed.
2020
2021							*:i* *:in* *:insert*
2022:{range}i[nsert][!]	Insert several lines of text above the specified
2023			line.  If the {range} is missing, the text will be
2024			inserted before the current line.
2025			Adding [!] toggles 'autoindent' for the time this
2026			command is executed.
2027
2028These two commands will keep on asking for lines, until you type a line
2029containing only a ".".  Watch out for lines starting with a backslash, see
2030|line-continuation|.
2031
2032Text typed after a "|" command separator is used first.  So the following
2033command in Ex mode: >
2034	:a|one
2035	two
2036	.
2037	:visual
2038appends the following text, after the cursor line: >
2039	one
2040	two
2041<
2042NOTE: These commands cannot be used with |:global| or |:vglobal|.
2043":append" and ":insert" don't work properly in between ":if" and
2044":endif", ":for" and ":endfor", ":while" and ":endwhile".
2045
2046							*:start* *:startinsert*
2047:star[tinsert][!]	Start Insert mode (or |Terminal-mode| in a |terminal|
2048			buffer) just after executing this command.
2049			Works like typing "i" in Normal mode.  When the ! is
2050			included it works like "A", append to the line.
2051			Otherwise insertion starts at the cursor position.
2052			Note that when using this command in a function or
2053			script, the insertion only starts after the function
2054			or script is finished.
2055			This command does not work from |:normal|.
2056
2057							*:stopi* *:stopinsert*
2058:stopi[nsert]		Stop Insert mode or |Terminal-mode| as soon as
2059			possible.  Works like typing <Esc> in Insert mode.
2060			Can be used in an autocommand, example: >
2061				:au BufEnter scratch stopinsert
2062<
2063					*replacing-ex* *:startreplace*
2064:startr[eplace][!]	Start Replace mode just after executing this command.
2065			Works just like typing "R" in Normal mode.  When the
2066			! is included it acts just like "$R" had been typed
2067			(ie. begin replace mode at the end-of-line).  Other-
2068			wise replacement begins at the cursor position.
2069			Note that when using this command in a function or
2070			script that the replacement will only start after
2071			the function or script is finished.
2072
2073							*:startgreplace*
2074:startg[replace][!]	Just like |:startreplace|, but use Virtual Replace
2075			mode, like with |gR|.
2076
2077==============================================================================
207810. Inserting a file					*inserting-file*
2079
2080							*:r* *:re* *:read*
2081:r[ead] [++opt] [name]
2082			Insert the file [name] (default: current file) below
2083			the cursor.
2084			See |++opt| for the possible values of [++opt].
2085
2086:{range}r[ead] [++opt] [name]
2087			Insert the file [name] (default: current file) below
2088			the specified line.
2089			See |++opt| for the possible values of [++opt].
2090
2091							*:r!* *:read!*
2092:[range]r[ead] [++opt] !{cmd}
2093			Execute {cmd} and insert its standard output below
2094			the cursor or the specified line.  A temporary file is
2095			used to store the output of the command which is then
2096			read into the buffer.  'shellredir' is used to save
2097			the output of the command, which can be set to include
2098			stderr or not.  {cmd} is executed like with ":!{cmd}",
2099			any '!' is replaced with the previous command |:!|.
2100			See |++opt| for the possible values of [++opt].
2101
2102These commands insert the contents of a file, or the output of a command,
2103into the buffer.  They can be undone.  They cannot be repeated with the "."
2104command.  They work on a line basis, insertion starts below the line in which
2105the cursor is, or below the specified line.  To insert text above the first
2106line use the command ":0r {name}".
2107
2108After the ":read" command, the cursor is left on the first non-blank in the
2109first new line.  If in Ex mode, then the cursor is left on the last new
2110line (sorry, this is Vi compatible).
2111
2112If a file name is given with ":r", it becomes the alternate file.  This can be
2113used, for example, when you want to edit that file instead: ":e! #".  This can
2114be switched off by removing the 'a' flag from the 'cpoptions' option.
2115
2116Of the [++opt] arguments one is specifically for ":read", the ++edit argument.
2117This is useful when the ":read" command is actually used to read a file into
2118the buffer as if editing that file.  Use this command in an empty buffer: >
2119	:read ++edit filename
2120The effect is that the 'fileformat', 'fileencoding', 'bomb', etc. options are
2121set to what has been detected for "filename".  Note that a single empty line
2122remains, you may want to delete it.
2123
2124							*file-read*
2125The 'fileformat' option sets the <EOL> style for a file:
2126'fileformat'    characters	   name				~
2127  "dos"		<CR><NL> or <NL>   DOS format
2128  "unix"	<NL>		   Unix format
2129  "mac"		<CR>		   Mac format
2130
2131If 'fileformat' is "dos", a <CR> in front of an <NL> is ignored and a CTRL-Z
2132at the end of the file is ignored.
2133
2134If 'fileformat' is "mac", a <NL> in the file is internally represented by a
2135<CR>.  This is to avoid confusion with a <NL> which is used to represent a
2136<NUL>.  See |CR-used-for-NL|.
2137
2138If the 'fileformats' option is not empty Vim tries to recognize the type of
2139<EOL> (see |file-formats|).  However, the 'fileformat' option will not be
2140changed, the detected format is only used while reading the file.
2141A similar thing happens with 'fileencodings'.
2142
2143On non-Win32 systems the message "[dos format]" is shown if a file is read in
2144DOS format, to remind you that something unusual is done.
2145On Macintosh and Win32 the message "[unix format]" is shown if a file is read
2146in Unix format.
2147On non-Macintosh systems, the message "[mac format]" is shown if a file is
2148read in Mac format.
2149
2150An example on how to use ":r !": >
2151	:r !uuencode binfile binfile
2152This command reads "binfile", uuencodes it and reads it into the current
2153buffer.  Useful when you are editing e-mail and want to include a binary
2154file.
2155
2156							*read-messages*
2157When reading a file Vim will display a message with information about the read
2158file.  In the table is an explanation for some of the items.  The others are
2159self explanatory.  Using the long or the short version depends on the
2160'shortmess' option.
2161
2162	long		short		meaning ~
2163	[readonly]	{RO}		the file is write protected
2164	[fifo/socket]			using a stream
2165	[fifo]				using a fifo stream
2166	[socket]			using a socket stream
2167	[CR missing]			reading with "dos" 'fileformat' and a
2168					NL without a preceding CR was found.
2169	[NL found]			reading with "mac" 'fileformat' and a
2170					NL was found (could be "unix" format)
2171	[long lines split]		at least one line was split in two
2172	[NOT converted]			conversion from 'fileencoding' to
2173					'encoding' was desired but not
2174					possible
2175	[converted]			conversion from 'fileencoding' to
2176					'encoding' done
2177	[READ ERRORS]			not all of the file could be read
2178
2179
2180 vim:tw=78:ts=8:noet:ft=help:norl: