代码拉取完成,页面将自动刷新
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>insert - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>
<body>
<header>
<div class="header">
<a href="http://vim-jp.org/">vim-jp</a>
/ <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
/ insert<br />
<a name="top"></a><h1>insert - Vim Documentation</h1>
<a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
</div>
</header>
<nav>
<dl>
<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>
<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>
<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>
<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>
<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>
<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>
<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>
<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>
<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>
<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>
<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>
<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>
<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>
<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>
<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>
<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>
<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>
</dl>
</nav>
<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="insert.html" name="insert.txt">insert.txt</a> For <span class="Identifier">Vim version 8.0.</span> Last change: 2017 May 30<br>
<br>
<br>
<span class="Identifier">VIM REFERENCE MANUAL by Bram Moolenaar</span><br>
<br>
<br>
<a class="Constant" href="insert.html#Insert" name="Insert">Insert</a> <a class="Constant" href="insert.html#Insert-mode" name="Insert-mode">Insert-mode</a><br>
Inserting and replacing text <a class="Constant" href="insert.html#mode-ins-repl" name="mode-ins-repl">mode-ins-repl</a><br>
<br>
Most of this file is about Insert and Replace mode. At the end are a few<br>
commands for inserting text in other ways.<br>
<br>
An overview of the most often used commands can be found in chapter 24 of the<br>
user manual <a class="Identifier" href="usr_24.html">usr_24.txt</a>.<br>
<br>
1. Special keys <a class="Identifier" href="insert.html#ins-special-keys">ins-special-keys</a><br>
2. Special special keys <a class="Identifier" href="insert.html#ins-special-special">ins-special-special</a><br>
3. <a class="Type" href="options.html#'textwidth'">'textwidth'</a> and <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> options <a class="Identifier" href="insert.html#ins-textwidth">ins-textwidth</a><br>
4. <a class="Type" href="options.html#'expandtab'">'expandtab'</a>, <a class="Type" href="options.html#'smarttab'">'smarttab'</a> and <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> options <a class="Identifier" href="insert.html#ins-expandtab">ins-expandtab</a><br>
5. Replace mode <a class="Identifier" href="insert.html#Replace-mode">Replace-mode</a><br>
6. Virtual Replace mode <a class="Identifier" href="insert.html#Virtual-Replace-mode">Virtual-Replace-mode</a><br>
7. Insert mode completion <a class="Identifier" href="insert.html#ins-completion">ins-completion</a><br>
8. Insert mode commands <a class="Identifier" href="insert.html#inserting">inserting</a><br>
9. Ex insert commands <a class="Identifier" href="insert.html#inserting-ex">inserting-ex</a><br>
10. Inserting a file <a class="Identifier" href="insert.html#inserting-file">inserting-file</a><br>
<br>
Also see <a class="Type" href="options.html#'virtualedit'">'virtualedit'</a>, for moving the cursor to positions where there is no<br>
character. Useful for editing a table.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
1. Special keys <a class="Constant" href="insert.html#ins-special-keys" name="ins-special-keys">ins-special-keys</a><br>
<br>
In Insert and Replace mode, the following characters have a special meaning;<br>
other characters are inserted directly. To insert one of these special<br>
characters into the buffer, precede it with <span class="Special">CTRL-V</span>. To insert a <span class="Special"><Nul></span><br>
character use "<span class="Special">CTRL-V</span> <span class="Special">CTRL-@</span>" or "<span class="Special">CTRL-V</span> 000". On some systems, you have to<br>
use "<span class="Special">CTRL-V</span> 003" to insert a <span class="Special">CTRL-C</span>. <span class="Todo">Note</span>: When <span class="Special">CTRL-V</span> is mapped you can<br>
often use <span class="Special">CTRL-Q</span> instead <a class="Identifier" href="insert.html#i_CTRL-Q">i_CTRL-Q</a>.<br>
<br>
If you are working in a special language mode when inserting text, see the<br>
<a class="Type" href="options.html#'langmap'">'langmap'</a> option, <a class="Identifier" href="options.html#'langmap'">'langmap'</a>, on how to avoid switching this mode on and off<br>
all the time.<br>
<br>
If you have <a class="Type" href="options.html#'insertmode'">'insertmode'</a> set, <span class="Special"><Esc></span> and a few other keys get another meaning.<br>
See <a class="Identifier" href="options.html#'insertmode'">'insertmode'</a>.<br>
<br>
<span class="PreProc">char action</span><br>
<span class="PreProc">-----------------------------------------------------------------------</span><br>
<a class="Constant" href="insert.html#i_CTRL-[" name="i_CTRL-[">i_CTRL-[</a> <a class="Constant" href="insert.html#i_<Esc>" name="i_<Esc>">i_<Esc></a><br>
<span class="Special"><Esc></span> or <span class="Special">CTRL-[</span> End insert or Replace mode, go back to Normal mode. Finish<br>
abbreviation.<br>
<span class="Todo">Note</span>: If your <span class="Special"><Esc></span> key is hard to hit on your keyboard, train<br>
yourself to use <span class="Special">CTRL-[</span>.<br>
If Esc doesn't work and you are using a Mac, try <span class="Special">CTRL-E</span>sc.<br>
Or disable Listening under Accessibility preferences.<br>
<a class="Constant" href="insert.html#i_CTRL-C" name="i_CTRL-C">i_CTRL-C</a><br>
<span class="Special">CTRL-C</span> Quit insert mode, go back to Normal mode. Do not check for<br>
abbreviations. Does not trigger the <a class="Identifier" href="autocmd.html#InsertLeave">InsertLeave</a> autocommand<br>
event.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-@" name="i_CTRL-@">i_CTRL-@</a><br>
<span class="Special">CTRL-@</span> Insert previously inserted text and stop insert. <span class="Special">{Vi: only</span><br>
<span class="Special">when typed as first char, only up to 128 chars}</span><br>
<a class="Constant" href="insert.html#i_CTRL-A" name="i_CTRL-A">i_CTRL-A</a><br>
<span class="Special">CTRL-A</span> Insert previously inserted text. <span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-H" name="i_CTRL-H">i_CTRL-H</a> <a class="Constant" href="insert.html#i_<BS>" name="i_<BS>">i_<BS></a> <a class="Constant" href="insert.html#i_BS" name="i_BS">i_BS</a><br>
<span class="Special"><BS></span> or <span class="Special">CTRL-H</span> Delete the character before the cursor (see <a class="Identifier" href="insert.html#i_backspacing">i_backspacing</a><br>
about joining lines).<br>
See <a class="Identifier" href="options.html#:fixdel">:fixdel</a> if your <span class="Special"><BS></span> key does not do what you want.<br>
<span class="Special">{Vi: does not delete autoindents}</span><br>
<a class="Constant" href="insert.html#i_<Del>" name="i_<Del>">i_<Del></a> <a class="Constant" href="insert.html#i_DEL" name="i_DEL">i_DEL</a><br>
<span class="Special"><Del></span> Delete the character under the cursor. If the cursor is at<br>
the end of the line, and the <a class="Type" href="options.html#'backspace'">'backspace'</a> option includes<br>
"eol", delete the <span class="Special"><EOL></span>; the next line is appended after the<br>
current one.<br>
See <a class="Identifier" href="options.html#:fixdel">:fixdel</a> if your <span class="Special"><Del></span> key does not do what you want.<br>
<span class="Special">{not in Vi}</span><br>
<a class="Constant" href="insert.html#i_CTRL-W" name="i_CTRL-W">i_CTRL-W</a><br>
<span class="Special">CTRL-W</span> Delete the word before the cursor (see <a class="Identifier" href="insert.html#i_backspacing">i_backspacing</a> about<br>
joining lines). See the section "word motions",<br>
<a class="Identifier" href="motion.html#word-motions">word-motions</a>, for the definition of a word.<br>
<a class="Constant" href="insert.html#i_CTRL-U" name="i_CTRL-U">i_CTRL-U</a><br>
<span class="Special">CTRL-U</span> Delete all entered characters before the cursor in the current<br>
line. If there are no newly entered characters and<br>
<a class="Type" href="options.html#'backspace'">'backspace'</a> is not empty, delete all characters before the<br>
cursor in the current line.<br>
See <a class="Identifier" href="insert.html#i_backspacing">i_backspacing</a> about joining lines.<br>
<a class="Constant" href="insert.html#i_CTRL-I" name="i_CTRL-I">i_CTRL-I</a> <a class="Constant" href="insert.html#i_<Tab>" name="i_<Tab>">i_<Tab></a> <a class="Constant" href="insert.html#i_Tab" name="i_Tab">i_Tab</a><br>
<span class="Special"><Tab></span> or <span class="Special">CTRL-I</span> Insert a tab. If the <a class="Type" href="options.html#'expandtab'">'expandtab'</a> option is on, the<br>
equivalent number of spaces is inserted (use <span class="Special">CTRL-V</span> <span class="Special"><Tab></span> to<br>
avoid the expansion; use <span class="Special">CTRL-Q</span> <span class="Special"><Tab></span> if <span class="Special">CTRL-V</span> is mapped<br>
<a class="Identifier" href="insert.html#i_CTRL-Q">i_CTRL-Q</a>). See also the <a class="Type" href="options.html#'smarttab'">'smarttab'</a> option and<br>
<a class="Identifier" href="insert.html#ins-expandtab">ins-expandtab</a>.<br>
<a class="Constant" href="insert.html#i_CTRL-J" name="i_CTRL-J">i_CTRL-J</a> <a class="Constant" href="insert.html#i_<NL>" name="i_<NL>">i_<NL></a><br>
<span class="Special"><NL></span> or <span class="Special">CTRL-J</span> Begin new line.<br>
<a class="Constant" href="insert.html#i_CTRL-M" name="i_CTRL-M">i_CTRL-M</a> <a class="Constant" href="insert.html#i_<CR>" name="i_<CR>">i_<CR></a><br>
<span class="Special"><CR></span> or <span class="Special">CTRL-M</span> Begin new line.<br>
<a class="Constant" href="insert.html#i_CTRL-K" name="i_CTRL-K">i_CTRL-K</a><br>
<span class="Special">CTRL-K</span> <span class="Special">{char1}</span> <span class="Special">[char2]</span><br>
Enter digraph (see <a class="Identifier" href="digraph.html#digraphs">digraphs</a>). When <span class="Special">{char1}</span> is a special<br>
key, the code for that key is inserted in <> form. For<br>
example, the string "<span class="Special"><S-Space></span>" can be entered by typing<br>
<span class="Special"><C-K><S-Space></span> (two keys). Neither char is considered for<br>
mapping. <span class="Special">{not in Vi}</span><br>
<br>
<span class="Special">CTRL-N</span> Find next keyword (see <a class="Identifier" href="insert.html#i_CTRL-N">i_CTRL-N</a>). <span class="Special">{not in Vi}</span><br>
<span class="Special">CTRL-P</span> Find previous keyword (see <a class="Identifier" href="insert.html#i_CTRL-P">i_CTRL-P</a>). <span class="Special">{not in Vi}</span><br>
<br>
<span class="Special">CTRL-R</span> <span class="Special">{0-9a-z"%#*+:.-=}</span> <a class="Constant" href="insert.html#i_CTRL-R" name="i_CTRL-R">i_CTRL-R</a><br>
Insert the contents of a register. Between typing <span class="Special">CTRL-R</span> and<br>
the second character, '"' will be displayed to indicate that<br>
you are expected to enter the name of a register.<br>
The text is inserted as if you typed it, but mappings and<br>
abbreviations are not used. If you have options like<br>
<a class="Type" href="options.html#'textwidth'">'textwidth'</a>, <a class="Type" href="options.html#'formatoptions'">'formatoptions'</a>, or <a class="Type" href="options.html#'autoindent'">'autoindent'</a> set, this will<br>
influence what will be inserted. This is different from what<br>
happens with the "p" command and pasting with the mouse.<br>
Special registers:<br>
'"' the unnamed register, containing the text of<br>
the last delete or yank<br>
'%' the current file name<br>
'#' the alternate file name<br>
'*' the clipboard contents (X11: primary selection)<br>
'+' the clipboard contents<br>
'/' the last search pattern<br>
':' the last command-line<br>
'.' the last inserted text<br>
'-' the last small (less than a line) delete<br>
<a class="Constant" href="insert.html#i_CTRL-R_=" name="i_CTRL-R_=">i_CTRL-R_=</a><br>
'=' the expression register: you are prompted to<br>
enter an expression (see <a class="Identifier" href="eval.html#expression">expression</a>)<br>
<span class="Todo">Note</span> that 0x80 (128 decimal) is used for<br>
special keys. E.g., you can use this to move<br>
the cursor up:<br>
<span class="Special">CTRL-R</span> ="\<span class="Special"><Up></span>"<br>
Use <span class="Special">CTRL-R</span> <span class="Special">CTRL-R</span> to insert text literally.<br>
When the result is a <a class="Identifier" href="eval.html#List">List</a> the items are used<br>
as lines. They can have line breaks inside<br>
too.<br>
When the result is a Float it's automatically<br>
converted to a String.<br>
When append() or setline() is invoked the undo<br>
sequence will be broken.<br>
See <a class="Identifier" href="change.html#registers">registers</a> about registers. <span class="Special">{not in Vi}</span><br>
<br>
<span class="Special">CTRL-R</span> <span class="Special">CTRL-R</span> <span class="Special">{0-9a-z"%#*+/:.-=}</span> <a class="Constant" href="insert.html#i_CTRL-R_CTRL-R" name="i_CTRL-R_CTRL-R">i_CTRL-R_CTRL-R</a><br>
Insert the contents of a register. Works like using a single<br>
<span class="Special">CTRL-R</span>, but the text is inserted literally, not as if typed.<br>
This differs when the register contains characters like <span class="Special"><BS></span>.<br>
Example, where register a contains "ab^Hc":<br>
<div class="helpExample"> CTRL-R a results in "ac".<br>
CTRL-R CTRL-R a results in "ab^Hc".</div>
Options <a class="Type" href="options.html#'textwidth'">'textwidth'</a>, <a class="Type" href="options.html#'formatoptions'">'formatoptions'</a>, etc. still apply. If<br>
you also want to avoid these, use <span class="Special">CTRL-R</span> <span class="Special">CTRL-O</span>, see below.<br>
The '.' register (last inserted text) is still inserted as<br>
typed. <span class="Special">{not in Vi}</span><br>
<br>
<span class="Special">CTRL-R</span> <span class="Special">CTRL-O</span> <span class="Special">{0-9a-z"%#*+/:.-=}</span> <a class="Constant" href="insert.html#i_CTRL-R_CTRL-O" name="i_CTRL-R_CTRL-O">i_CTRL-R_CTRL-O</a><br>
Insert the contents of a register literally and don't<br>
auto-indent. Does the same as pasting with the mouse<br>
<a class="Identifier" href="change.html#<MiddleMouse>"><MiddleMouse></a>. When the register is linewise this will<br>
insert the text above the current line, like with <a class="Comment" href="change.html#P">P</a>.<br>
Does not replace characters!<br>
The '.' register (last inserted text) is still inserted as<br>
typed. <span class="Special">{not in Vi}</span><br>
<br>
<span class="Special">CTRL-R</span> <span class="Special">CTRL-P</span> <span class="Special">{0-9a-z"%#*+/:.-=}</span> <a class="Constant" href="insert.html#i_CTRL-R_CTRL-P" name="i_CTRL-R_CTRL-P">i_CTRL-R_CTRL-P</a><br>
Insert the contents of a register literally and fix the<br>
indent, like <a class="Identifier" href="change.html#[<MiddleMouse>">[<MiddleMouse></a>.<br>
Does not replace characters!<br>
The '.' register (last inserted text) is still inserted as<br>
typed. <span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-T" name="i_CTRL-T">i_CTRL-T</a><br>
<span class="Special">CTRL-T</span> Insert one shiftwidth of indent at the start of the current<br>
line. The indent is always rounded to a <a class="Type" href="options.html#'shiftwidth'">'shiftwidth'</a> (this is<br>
vi compatible). <span class="Special">{Vi: only when in indent}</span><br>
<a class="Constant" href="insert.html#i_CTRL-D" name="i_CTRL-D">i_CTRL-D</a><br>
<span class="Special">CTRL-D</span> Delete one shiftwidth of indent at the start of the current<br>
line. The indent is always rounded to a <a class="Type" href="options.html#'shiftwidth'">'shiftwidth'</a> (this is<br>
vi compatible). <span class="Special">{Vi: CTRL-D works only when used after</span><br>
<span class="Special">autoindent}</span><br>
<a class="Constant" href="insert.html#i_0_CTRL-D" name="i_0_CTRL-D">i_0_CTRL-D</a><br>
0 <span class="Special">CTRL-D</span> Delete all indent in the current line. <span class="Special">{Vi: CTRL-D works</span><br>
<span class="Special">only when used after autoindent}</span><br>
<a class="Constant" href="insert.html#i_^_CTRL-D" name="i_^_CTRL-D">i_^_CTRL-D</a><br>
^ <span class="Special">CTRL-D</span> Delete all indent in the current line. The indent is<br>
restored in the next line. This is useful when inserting a<br>
label. <span class="Special">{Vi: CTRL-D works only when used after autoindent}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-V" name="i_CTRL-V">i_CTRL-V</a><br>
<span class="Special">CTRL-V</span> Insert next non-digit literally. For special keys, the<br>
terminal code is inserted. It's also possible to enter the<br>
decimal, octal or hexadecimal value of a character<br>
<a class="Identifier" href="insert.html#i_CTRL-V_digit">i_CTRL-V_digit</a>.<br>
The characters typed right after <span class="Special">CTRL-V</span> are not considered for<br>
mapping. <span class="Special">{Vi: no decimal byte entry}</span><br>
<span class="Todo">Note</span>: When <span class="Special">CTRL-V</span> is mapped (e.g., to paste text) you can<br>
often use <span class="Special">CTRL-Q</span> instead <a class="Identifier" href="insert.html#i_CTRL-Q">i_CTRL-Q</a>.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-Q" name="i_CTRL-Q">i_CTRL-Q</a><br>
<span class="Special">CTRL-Q</span> Same as <span class="Special">CTRL-V</span>.<br>
<span class="Todo">Note</span>: Some terminal connections may eat <span class="Special">CTRL-Q</span>, it doesn't<br>
work then. It does work in the GUI.<br>
<br>
<span class="Special">CTRL-X</span> Enter <span class="Special">CTRL-X</span> mode. This is a sub-mode where commands can<br>
be given to complete words or scroll the window. See<br>
<a class="Identifier" href="insert.html#i_CTRL-X">i_CTRL-X</a> and <a class="Identifier" href="insert.html#ins-completion">ins-completion</a>. <span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-E" name="i_CTRL-E">i_CTRL-E</a><br>
<span class="Special">CTRL-E</span> Insert the character which is below the cursor. <span class="Special">{not in Vi}</span><br>
<a class="Constant" href="insert.html#i_CTRL-Y" name="i_CTRL-Y">i_CTRL-Y</a><br>
<span class="Special">CTRL-Y</span> Insert the character which is above the cursor. <span class="Special">{not in Vi}</span><br>
<span class="Todo">Note</span> that for <span class="Special">CTRL-E</span> and <span class="Special">CTRL-Y</span> <a class="Type" href="options.html#'textwidth'">'textwidth'</a> is not used, to be<br>
able to copy characters from a long line.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-_" name="i_CTRL-_">i_CTRL-_</a><br>
<span class="Special">CTRL-_</span> Switch between languages, as follows:<br>
- When in a rightleft window, revins and nohkmap are toggled,<br>
since English will likely be inserted in this case.<br>
- When in a norightleft window, revins and hkmap are toggled,<br>
since Hebrew will likely be inserted in this case.<br>
<br>
<span class="Special">CTRL-_</span> moves the cursor to the end of the typed text.<br>
<br>
This command is only available when the <a class="Type" href="options.html#'allowrevins'">'allowrevins'</a> option<br>
is set.<br>
Please refer to <a class="Identifier" href="rileft.html">rileft.txt</a> for more information about<br>
right-to-left mode.<br>
<span class="Special">{not in Vi}</span><br>
Only if compiled with the <a class="Identifier" href="various.html#+rightleft">+rightleft</a> feature.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-^" name="i_CTRL-^">i_CTRL-^</a><br>
<span class="Special">CTRL-^</span> Toggle the use of typing language characters.<br>
When language <a class="Identifier" href="map.html#:lmap">:lmap</a> mappings are defined:<br>
- If <a class="Type" href="options.html#'iminsert'">'iminsert'</a> is 1 (langmap mappings used) it becomes 0 (no<br>
langmap mappings used).<br>
- If <a class="Type" href="options.html#'iminsert'">'iminsert'</a> has another value it becomes 1, thus langmap<br>
mappings are enabled.<br>
When no language mappings are defined:<br>
- If <a class="Type" href="options.html#'iminsert'">'iminsert'</a> is 2 (Input Method used) it becomes 0 (no<br>
Input Method used).<br>
- If <a class="Type" href="options.html#'iminsert'">'iminsert'</a> has another value it becomes 2, thus the Input<br>
Method is enabled.<br>
When set to 1, the value of the "b:keymap_name" variable, the<br>
<a class="Type" href="options.html#'keymap'">'keymap'</a> option or "<span class="Special"><lang></span>" appears in the status line.<br>
The language mappings are normally used to type characters<br>
that are different from what the keyboard produces. The<br>
<a class="Type" href="options.html#'keymap'">'keymap'</a> option can be used to install a whole number of them.<br>
<span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-]" name="i_CTRL-]">i_CTRL-]</a><br>
<span class="Special">CTRL-]</span> Trigger abbreviation, without inserting a character. <span class="Special">{not in</span><br>
<span class="Special">Vi}</span><br>
<br>
<a class="Constant" href="insert.html#i_<Insert>" name="i_<Insert>">i_<Insert></a><br>
<span class="Special"><Insert></span> Toggle between Insert and Replace mode. <span class="Special">{not in Vi}</span><br>
<span class="PreProc">-----------------------------------------------------------------------</span><br>
<br>
<a class="Constant" href="insert.html#i_backspacing" name="i_backspacing">i_backspacing</a><br>
The effect of the <span class="Special"><BS></span>, <span class="Special">CTRL-W</span>, and <span class="Special">CTRL-U</span> depend on the <a class="Type" href="options.html#'backspace'">'backspace'</a> option<br>
(unless <a class="Type" href="options.html#'revins'">'revins'</a> is set). This is a comma separated list of items:<br>
<br>
<span class="PreProc">item action</span><br>
indent allow backspacing over autoindent<br>
eol allow backspacing over end-of-line (join lines)<br>
start allow backspacing over the start position of insert; <span class="Special">CTRL-W</span> and<br>
<span class="Special">CTRL-U</span> stop once at the start position<br>
<br>
When <a class="Type" href="options.html#'backspace'">'backspace'</a> is empty, Vi compatible backspacing is used. You cannot<br>
backspace over autoindent, before column 1 or before where insert started.<br>
<br>
For backwards compatibility the values "0", "1" and "2" are also allowed, see<br>
<a class="Identifier" href="options.html#'backspace'">'backspace'</a>.<br>
<br>
If the <a class="Type" href="options.html#'backspace'">'backspace'</a> option does contain "eol" and the cursor is in column 1<br>
when one of the three keys is used, the current line is joined with the<br>
previous line. This effectively deletes the <span class="Special"><EOL></span> in front of the cursor.<br>
<span class="Special">{Vi: does not cross lines, does not delete past start position of insert}</span><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-V_digit" name="i_CTRL-V_digit">i_CTRL-V_digit</a><br>
With <span class="Special">CTRL-V</span> the decimal, octal or hexadecimal value of a character can be<br>
entered directly. This way you can enter any character, except a line break<br>
(<span class="Special"><NL></span>, value 10). There are five ways to enter the character value:<br>
<br>
<span class="PreProc">first char mode max nr of chars max value</span><br>
(none) decimal 3 255<br>
o or O octal 3 377 (255)<br>
x or X hexadecimal 2 ff (255)<br>
u hexadecimal 4 ffff (65535)<br>
U hexadecimal 8 7fffffff (2147483647)<br>
<br>
Normally you would type the maximum number of characters. Thus to enter a<br>
space (value 32) you would type <span class="Special"><C-V></span>032. You can omit the leading zero, in<br>
which case the character typed after the number must be a non-digit. This<br>
happens for the other modes as well: As soon as you type a character that is<br>
invalid for the mode, the value before it will be used and the "invalid"<br>
character is dealt with in the normal way.<br>
<br>
If you enter a value of 10, it will end up in the file as a 0. The 10 is a<br>
<span class="Special"><NL></span>, which is used internally to represent the <span class="Special"><Nul></span> character. When writing<br>
the buffer to a file, the <span class="Special"><NL></span> character is translated into <span class="Special"><Nul></span>. The <span class="Special"><NL></span><br>
character is written at the end of each line. Thus if you want to insert a<br>
<span class="Special"><NL></span> character in a file you will have to make a line break.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X" name="i_CTRL-X">i_CTRL-X</a> <a class="Constant" href="insert.html#insert_expand" name="insert_expand">insert_expand</a><br>
<span class="Special">CTRL-X</span> enters a sub-mode where several commands can be used. Most of these<br>
commands do keyword completion; see <a class="Identifier" href="insert.html#ins-completion">ins-completion</a>. These are not available<br>
when Vim was compiled without the <a class="Identifier" href="various.html#+insert_expand">+insert_expand</a> feature.<br>
<br>
Two commands can be used to scroll the window up or down, without exiting<br>
insert mode:<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-E" name="i_CTRL-X_CTRL-E">i_CTRL-X_CTRL-E</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-E</span> scroll window one line up.<br>
When doing completion look here: <a class="Identifier" href="insert.html#complete_CTRL-E">complete_CTRL-E</a><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-Y" name="i_CTRL-X_CTRL-Y">i_CTRL-X_CTRL-Y</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-Y</span> scroll window one line down.<br>
When doing completion look here: <a class="Identifier" href="insert.html#complete_CTRL-Y">complete_CTRL-Y</a><br>
<br>
After <span class="Special">CTRL-X</span> is pressed, each <span class="Special">CTRL-E</span> (<span class="Special">CTRL-Y</span>) scrolls the window up (down) by<br>
one line unless that would cause the cursor to move from its current position<br>
in the file. As soon as another key is pressed, <span class="Special">CTRL-X</span> mode is exited and<br>
that key is interpreted as in Insert mode.<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
2. Special special keys <a class="Constant" href="insert.html#ins-special-special" name="ins-special-special">ins-special-special</a><br>
<br>
The following keys are special. They stop the current insert, do something,<br>
and then restart insertion. This means you can do something without getting<br>
out of Insert mode. This is very handy if you prefer to use the Insert mode<br>
all the time, just like editors that don't have a separate Normal mode. You<br>
may also want to set the <a class="Type" href="options.html#'backspace'">'backspace'</a> option to "indent,eol,start" and set the<br>
<a class="Type" href="options.html#'insertmode'">'insertmode'</a> option. You can use <span class="Special">CTRL-O</span> if you want to map a function key to<br>
a command.<br>
<br>
The changes (inserted or deleted characters) before and after these keys can<br>
be undone separately. Only the last change can be redone and always behaves<br>
like an "i" command.<br>
<br>
<span class="PreProc">char action</span><br>
<span class="PreProc">-----------------------------------------------------------------------</span><br>
<span class="Special"><Up></span> cursor one line up <a class="Constant" href="insert.html#i_<Up>" name="i_<Up>">i_<Up></a><br>
<span class="Special"><Down></span> cursor one line down <a class="Constant" href="insert.html#i_<Down>" name="i_<Down>">i_<Down></a><br>
<span class="Special">CTRL-G</span> <span class="Special"><Up></span> cursor one line up, insert start column <a class="Constant" href="insert.html#i_CTRL-G_<Up>" name="i_CTRL-G_<Up>">i_CTRL-G_<Up></a><br>
<span class="Special">CTRL-G</span> k cursor one line up, insert start column <a class="Constant" href="insert.html#i_CTRL-G_k" name="i_CTRL-G_k">i_CTRL-G_k</a><br>
<span class="Special">CTRL-G</span> <span class="Special">CTRL-K</span> cursor one line up, insert start column <a class="Constant" href="insert.html#i_CTRL-G_CTRL-K" name="i_CTRL-G_CTRL-K">i_CTRL-G_CTRL-K</a><br>
<span class="Special">CTRL-G</span> <span class="Special"><Down></span> cursor one line down, insert start column <a class="Constant" href="insert.html#i_CTRL-G_<Down>" name="i_CTRL-G_<Down>">i_CTRL-G_<Down></a><br>
<span class="Special">CTRL-G</span> j cursor one line down, insert start column <a class="Constant" href="insert.html#i_CTRL-G_j" name="i_CTRL-G_j">i_CTRL-G_j</a><br>
<span class="Special">CTRL-G</span> <span class="Special">CTRL-J</span> cursor one line down, insert start column <a class="Constant" href="insert.html#i_CTRL-G_CTRL-J" name="i_CTRL-G_CTRL-J">i_CTRL-G_CTRL-J</a><br>
<span class="Special"><Left></span> cursor one character left <a class="Constant" href="insert.html#i_<Left>" name="i_<Left>">i_<Left></a><br>
<span class="Special"><Right></span> cursor one character right <a class="Constant" href="insert.html#i_<Right>" name="i_<Right>">i_<Right></a><br>
<span class="Special"><S-Left></span> cursor one word back (like "b" command) <a class="Constant" href="insert.html#i_<S-Left>" name="i_<S-Left>">i_<S-Left></a><br>
<span class="Special"><C-Left></span> cursor one word back (like "b" command) <a class="Constant" href="insert.html#i_<C-Left>" name="i_<C-Left>">i_<C-Left></a><br>
<span class="Special"><S-Right></span> cursor one word forward (like "w" command) <a class="Constant" href="insert.html#i_<S-Right>" name="i_<S-Right>">i_<S-Right></a><br>
<span class="Special"><C-Right></span> cursor one word forward (like "w" command) <a class="Constant" href="insert.html#i_<C-Right>" name="i_<C-Right>">i_<C-Right></a><br>
<span class="Special"><Home></span> cursor to first char in the line <a class="Constant" href="insert.html#i_<Home>" name="i_<Home>">i_<Home></a><br>
<span class="Special"><End></span> cursor to after last char in the line <a class="Constant" href="insert.html#i_<End>" name="i_<End>">i_<End></a><br>
<span class="Special"><C-Home></span> cursor to first char in the file <a class="Constant" href="insert.html#i_<C-Home>" name="i_<C-Home>">i_<C-Home></a><br>
<span class="Special"><C-End></span> cursor to after last char in the file <a class="Constant" href="insert.html#i_<C-End>" name="i_<C-End>">i_<C-End></a><br>
<span class="Special"><LeftMouse></span> cursor to position of mouse click <a class="Constant" href="insert.html#i_<LeftMouse>" name="i_<LeftMouse>">i_<LeftMouse></a><br>
<span class="Special"><S-Up></span> move window one page up <a class="Constant" href="insert.html#i_<S-Up>" name="i_<S-Up>">i_<S-Up></a><br>
<span class="Special"><PageUp></span> move window one page up <a class="Constant" href="insert.html#i_<PageUp>" name="i_<PageUp>">i_<PageUp></a><br>
<span class="Special"><S-Down></span> move window one page down <a class="Constant" href="insert.html#i_<S-Down>" name="i_<S-Down>">i_<S-Down></a><br>
<span class="Special"><PageDown></span> move window one page down <a class="Constant" href="insert.html#i_<PageDown>" name="i_<PageDown>">i_<PageDown></a><br>
<span class="Special"><ScrollWheelDown></span> move window three lines down <a class="Constant" href="insert.html#i_<ScrollWheelDown>" name="i_<ScrollWheelDown>">i_<ScrollWheelDown></a><br>
<span class="Special"><S-ScrollWheelDown></span> move window one page down <a class="Constant" href="insert.html#i_<S-ScrollWheelDown>" name="i_<S-ScrollWheelDown>">i_<S-ScrollWheelDown></a><br>
<span class="Special"><ScrollWheelUp></span> move window three lines up <a class="Constant" href="insert.html#i_<ScrollWheelUp>" name="i_<ScrollWheelUp>">i_<ScrollWheelUp></a><br>
<span class="Special"><S-ScrollWheelUp></span> move window one page up <a class="Constant" href="insert.html#i_<S-ScrollWheelUp>" name="i_<S-ScrollWheelUp>">i_<S-ScrollWheelUp></a><br>
<span class="Special"><ScrollWheelLeft></span> move window six columns left <a class="Constant" href="insert.html#i_<ScrollWheelLeft>" name="i_<ScrollWheelLeft>">i_<ScrollWheelLeft></a><br>
<span class="Special"><S-ScrollWheelLeft></span> move window one page left <a class="Constant" href="insert.html#i_<S-ScrollWheelLeft>" name="i_<S-ScrollWheelLeft>">i_<S-ScrollWheelLeft></a><br>
<span class="Special"><ScrollWheelRight></span> move window six columns right <a class="Constant" href="insert.html#i_<ScrollWheelRight>" name="i_<ScrollWheelRight>">i_<ScrollWheelRight></a><br>
<span class="Special"><S-ScrollWheelRight></span> move window one page right <a class="Constant" href="insert.html#i_<S-ScrollWheelRight>" name="i_<S-ScrollWheelRight>">i_<S-ScrollWheelRight></a><br>
<span class="Special">CTRL-O</span> execute one command, return to Insert mode <a class="Constant" href="insert.html#i_CTRL-O" name="i_CTRL-O">i_CTRL-O</a><br>
<span class="Special">CTRL-\</span> <span class="Special">CTRL-O</span> like <span class="Special">CTRL-O</span> but don't move the cursor <a class="Constant" href="insert.html#i_CTRL-\_CTRL-O" name="i_CTRL-\_CTRL-O">i_CTRL-\_CTRL-O</a><br>
<span class="Special">CTRL-L</span> when <a class="Type" href="options.html#'insertmode'">'insertmode'</a> is set: go to Normal mode <a class="Constant" href="insert.html#i_CTRL-L" name="i_CTRL-L">i_CTRL-L</a><br>
<span class="Special">CTRL-G</span> u break undo sequence, start new change <a class="Constant" href="insert.html#i_CTRL-G_u" name="i_CTRL-G_u">i_CTRL-G_u</a><br>
<span class="Special">CTRL-G</span> U don't break undo with next left/right cursor <a class="Constant" href="insert.html#i_CTRL-G_U" name="i_CTRL-G_U">i_CTRL-G_U</a><br>
movement (but only if the cursor stays<br>
within same the line)<br>
<span class="PreProc">-----------------------------------------------------------------------</span><br>
<br>
<span class="Todo">Note</span>: If the cursor keys take you out of Insert mode, check the <a class="Type" href="options.html#'noesckeys'">'noesckeys'</a><br>
option.<br>
<br>
The <span class="Special">CTRL-O</span> command sometimes has a side effect: If the cursor was beyond the<br>
end of the line, it will be put on the last character in the line. In<br>
mappings it's often better to use <span class="Special"><Esc></span> (first put an "x" in the text, <span class="Special"><Esc></span><br>
will then always put the cursor on it). Or use <span class="Special">CTRL-\</span> <span class="Special">CTRL-O</span>, but then<br>
beware of the cursor possibly being beyond the end of the line. <span class="Todo">Note</span> that the<br>
command following <span class="Special">CTRL-\</span> <span class="Special">CTRL-O</span> can still move the cursor, it is not restored<br>
to its original position.<br>
<br>
The <span class="Special">CTRL-O</span> command takes you to Normal mode. If you then use a command enter<br>
Insert mode again it normally doesn't nest. Thus when typing "a<span class="Special"><C-O></span>a" and<br>
then <span class="Special"><Esc></span> takes you back to Normal mode, you do not need to type <span class="Special"><Esc></span> twice.<br>
An exception is when not typing the command, e.g. when executing a mapping or<br>
sourcing a script. This makes mappings work that briefly switch to Insert<br>
mode.<br>
<br>
The shifted cursor keys are not available on all terminals.<br>
<br>
Another side effect is that a count specified before the "i" or "a" command is<br>
ignored. That is because repeating the effect of the command after <span class="Special">CTRL-O</span> is<br>
too complicated.<br>
<br>
An example for using <span class="Special">CTRL-G</span> u:<br>
<br>
<div class="helpExample"> :inoremap <C-H> <C-G>u<C-H></div>
<br>
This redefines the backspace key to start a new undo sequence. You can now<br>
undo the effect of the backspace key, without changing what you typed before<br>
that, with <span class="Special">CTRL-O</span> u. Another example:<br>
<br>
<div class="helpExample"> :inoremap <CR> <C-]><C-G>u<CR></div>
<br>
This breaks undo at each line break. It also expands abbreviations before<br>
this.<br>
<br>
An example for using <span class="Special">CTRL-G</span> U:<br>
<br>
<div class="helpExample"> inoremap <Left> <C-G>U<Left><br>
inoremap <Right> <C-G>U<Right><br>
inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ?<br>
\ repeat('<C-G>U<Left>', col('.') - 1) :<br>
\ (col('.') < match(getline('.'), '\S') ?<br>
\ repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :<br>
\ repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))<br>
inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.'))<br>
inoremap ( ()<C-G>U<Left></div>
<br>
This makes it possible to use the cursor keys in Insert mode, without breaking<br>
the undo sequence and therefore using <a class="Identifier" href="repeat.html#.">.</a> (redo) will work as expected. <br>
Also entering a text like (with the "(" mapping from above):<br>
<br>
<div class="helpExample"> Lorem ipsum (dolor</div>
<br>
will be repeatable by the <a class="Identifier" href="repeat.html#.">.</a>to the expected<br>
<br>
Lorem ipsum (dolor)<br>
<br>
Using <span class="Special">CTRL-O</span> splits undo: the text typed before and after it is undone<br>
separately. If you want to avoid this (e.g., in a mapping) you might be able<br>
to use <span class="Special">CTRL-R</span> = <a class="Identifier" href="insert.html#i_CTRL-R">i_CTRL-R</a>. E.g., to call a function:<br>
<div class="helpExample"> :imap <F2> <C-R>=MyFunc()<CR></div>
<br>
When the <a class="Type" href="options.html#'whichwrap'">'whichwrap'</a> option is set appropriately, the <span class="Special"><Left></span> and <span class="Special"><Right></span><br>
keys on the first/last character in the line make the cursor wrap to the<br>
previous/next line.<br>
<br>
The <span class="Special">CTRL-G</span> j and <span class="Special">CTRL-G</span> k commands can be used to insert text in front of a<br>
column. Example:<br>
<div class="helpExample"> int i;<br>
int j;</div>
Position the cursor on the first "int", type "istatic <span class="Special"><C-G></span>j ". The<br>
result is:<br>
<div class="helpExample"> static int i;<br>
int j;</div>
When inserting the same text in front of the column in every line, use the<br>
Visual blockwise command "I" <a class="Identifier" href="visual.html#v_b_I">v_b_I</a>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
3. <a class="Type" href="options.html#'textwidth'">'textwidth'</a> and <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> options <a class="Constant" href="insert.html#ins-textwidth" name="ins-textwidth">ins-textwidth</a><br>
<br>
The <a class="Type" href="options.html#'textwidth'">'textwidth'</a> option can be used to automatically break a line before it<br>
gets too long. Set the <a class="Type" href="options.html#'textwidth'">'textwidth'</a> option to the desired maximum line<br>
length. If you then type more characters (not spaces or tabs), the<br>
last word will be put on a new line (unless it is the only word on the<br>
line). If you set <a class="Type" href="options.html#'textwidth'">'textwidth'</a> to 0, this feature is disabled.<br>
<br>
The <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> option does almost the same. The difference is that<br>
<a class="Type" href="options.html#'textwidth'">'textwidth'</a> has a fixed width while <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> depends on the width of the<br>
screen. When using <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> this is equal to using <a class="Type" href="options.html#'textwidth'">'textwidth'</a> with a<br>
value equal to (columns - <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a>), where columns is the width of the<br>
screen.<br>
<br>
When <a class="Type" href="options.html#'textwidth'">'textwidth'</a> and <a class="Type" href="options.html#'wrapmargin'">'wrapmargin'</a> are both set, <a class="Type" href="options.html#'textwidth'">'textwidth'</a> is used.<br>
<br>
If you don't really want to break the line, but view the line wrapped at a<br>
convenient place, see the <a class="Type" href="options.html#'linebreak'">'linebreak'</a> option.<br>
<br>
The line is only broken automatically when using Insert mode, or when<br>
appending to a line. When in replace mode and the line length is not<br>
changed, the line will not be broken.<br>
<br>
Long lines are broken if you enter a non-white character after the margin.<br>
The situations where a line will be broken can be restricted by adding<br>
characters to the <a class="Type" href="options.html#'formatoptions'">'formatoptions'</a> option:<br>
"l" Only break a line if it was not longer than <a class="Type" href="options.html#'textwidth'">'textwidth'</a> when the insert<br>
started.<br>
"v" Only break at a white character that has been entered during the<br>
current insert command. This is mostly Vi-compatible.<br>
"lv" Only break if the line was not longer than <a class="Type" href="options.html#'textwidth'">'textwidth'</a> when the insert<br>
started and only at a white character that has been entered during the<br>
current insert command. Only differs from "l" when entering non-white<br>
characters while crossing the <a class="Type" href="options.html#'textwidth'">'textwidth'</a> boundary.<br>
<br>
Normally an internal function will be used to decide where to break the line.<br>
If you want to do it in a different way set the <a class="Type" href="options.html#'formatexpr'">'formatexpr'</a> option to an<br>
expression that will take care of the line break.<br>
<br>
If you want to format a block of text, you can use the "gq" operator. Type<br>
"gq" and a movement command to move the cursor to the end of the block. In<br>
many cases, the command "gq}" will do what you want (format until the end of<br>
paragraph). Alternatively, you can use "gqap", which will format the whole<br>
paragraph, no matter where the cursor currently is. Or you can use Visual<br>
mode: hit "v", move to the end of the block, and type "gq". See also <a class="Identifier" href="change.html#gq">gq</a>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
4. <a class="Type" href="options.html#'expandtab'">'expandtab'</a>, <a class="Type" href="options.html#'smarttab'">'smarttab'</a> and <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> options <a class="Constant" href="insert.html#ins-expandtab" name="ins-expandtab">ins-expandtab</a><br>
<br>
If the <a class="Type" href="options.html#'expandtab'">'expandtab'</a> option is on, spaces will be used to fill the amount of<br>
whitespace of the tab. If you want to enter a real <span class="Special"><Tab></span>, type <span class="Special">CTRL-V</span> first<br>
(use <span class="Special">CTRL-Q</span> when <span class="Special">CTRL-V</span> is mapped <a class="Identifier" href="insert.html#i_CTRL-Q">i_CTRL-Q</a>).<br>
The <a class="Type" href="options.html#'expandtab'">'expandtab'</a> option is off by default. <span class="Todo">Note</span> that in Replace mode, a single<br>
character is replaced with several spaces. The result of this is that the<br>
number of characters in the line increases. Backspacing will delete one<br>
space at a time. The original character will be put back for only one space<br>
that you backspace over (the last one). <span class="Special">{Vi does not have the 'expandtab'</span><br>
<span class="Special">option}</span><br>
<br>
<a class="Constant" href="insert.html#ins-smarttab" name="ins-smarttab">ins-smarttab</a><br>
When the <a class="Type" href="options.html#'smarttab'">'smarttab'</a> option is on, a <span class="Special"><Tab></span> inserts <a class="Type" href="options.html#'shiftwidth'">'shiftwidth'</a> positions at<br>
the beginning of a line and <a class="Type" href="options.html#'tabstop'">'tabstop'</a> positions in other places. This means<br>
that often spaces instead of a <span class="Special"><Tab></span> character are inserted. When <a class="Type" href="options.html#'smarttab'">'smarttab'</a><br>
is off, a <span class="Special"><Tab></span> always inserts <a class="Type" href="options.html#'tabstop'">'tabstop'</a> positions, and <a class="Type" href="options.html#'shiftwidth'">'shiftwidth'</a> is only<br>
used for ">>" and the like. <span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#ins-softtabstop" name="ins-softtabstop">ins-softtabstop</a><br>
When the <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> option is non-zero, a <span class="Special"><Tab></span> inserts <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a><br>
positions, and a <span class="Special"><BS></span> used to delete white space, will delete <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a><br>
positions. This feels like <a class="Type" href="options.html#'tabstop'">'tabstop'</a> was set to <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a>, but a real<br>
<span class="Special"><Tab></span> character still takes <a class="Type" href="options.html#'tabstop'">'tabstop'</a> positions, so your file will still look<br>
correct when used by other applications.<br>
<br>
If <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> is non-zero, a <span class="Special"><BS></span> will try to delete as much white space to<br>
move to the previous <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> position, except when the previously<br>
inserted character is a space, then it will only delete the character before<br>
the cursor. Otherwise you cannot always delete a single character before the<br>
cursor. You will have to delete <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a> characters first, and then type<br>
extra spaces to get where you want to be.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
5. Replace mode <a class="Constant" href="insert.html#Replace" name="Replace">Replace</a> <a class="Constant" href="insert.html#Replace-mode" name="Replace-mode">Replace-mode</a> <a class="Constant" href="insert.html#mode-replace" name="mode-replace">mode-replace</a><br>
<br>
Enter Replace mode with the "R" command in normal mode.<br>
<br>
In Replace mode, one character in the line is deleted for every character you<br>
type. If there is no character to delete (at the end of the line), the<br>
typed character is appended (as in Insert mode). Thus the number of<br>
characters in a line stays the same until you get to the end of the line.<br>
If a <span class="Special"><NL></span> is typed, a line break is inserted and no character is deleted.<br>
<br>
Be careful with <span class="Special"><Tab></span> characters. If you type a normal printing character in<br>
its place, the number of characters is still the same, but the number of<br>
columns will become smaller.<br>
<br>
If you delete characters in Replace mode (with <span class="Special"><BS></span>, <span class="Special">CTRL-W</span>, or <span class="Special">CTRL-U</span>), what<br>
happens is that you delete the changes. The characters that were replaced<br>
are restored. If you had typed past the existing text, the characters you<br>
added are deleted. This is effectively a character-at-a-time undo.<br>
<br>
If the <a class="Type" href="options.html#'expandtab'">'expandtab'</a> option is on, a <span class="Special"><Tab></span> will replace one character with<br>
several spaces. The result of this is that the number of characters in the<br>
line increases. Backspacing will delete one space at a time. The original<br>
character will be put back for only one space that you backspace over (the<br>
last one). <span class="Special">{Vi does not have the 'expandtab' option}</span><br>
<br>
<span class="PreProc">==============================================================================</span><br>
6. Virtual Replace mode <a class="Constant" href="insert.html#vreplace-mode" name="vreplace-mode">vreplace-mode</a> <a class="Constant" href="insert.html#Virtual-Replace-mode" name="Virtual-Replace-mode">Virtual-Replace-mode</a><br>
<br>
Enter Virtual Replace mode with the "gR" command in normal mode.<br>
<span class="Special">{not available when compiled without the </span><a class="Identifier" href="various.html#+vreplace">+vreplace</a><span class="Special"> feature}</span><br>
<span class="Special">{Vi does not have Virtual Replace mode}</span><br>
<br>
Virtual Replace mode is similar to Replace mode, but instead of replacing<br>
actual characters in the file, you are replacing screen real estate, so that<br>
characters further on in the file never appear to move.<br>
<br>
So if you type a <span class="Special"><Tab></span> it may replace several normal characters, and if you<br>
type a letter on top of a <span class="Special"><Tab></span> it may not replace anything at all, since the<br>
<span class="Special"><Tab></span> will still line up to the same place as before.<br>
<br>
Typing a <span class="Special"><NL></span> still doesn't cause characters later in the file to appear to<br>
move. The rest of the current line will be replaced by the <span class="Special"><NL></span> (that is,<br>
they are deleted), and replacing continues on the next line. A new line is<br>
NOT inserted unless you go past the end of the file.<br>
<br>
Interesting effects are seen when using <span class="Special">CTRL-T</span> and <span class="Special">CTRL-D</span>. The characters<br>
before the cursor are shifted sideways as normal, but characters later in the<br>
line still remain still. <span class="Special">CTRL-T</span> will hide some of the old line under the<br>
shifted characters, but <span class="Special">CTRL-D</span> will reveal them again.<br>
<br>
As with Replace mode, using <span class="Special"><BS></span> etc will bring back the characters that were<br>
replaced. This still works in conjunction with <a class="Type" href="options.html#'smartindent'">'smartindent'</a>, <span class="Special">CTRL-T</span> and<br>
<span class="Special">CTRL-D</span>, <a class="Type" href="options.html#'expandtab'">'expandtab'</a>, <a class="Type" href="options.html#'smarttab'">'smarttab'</a>, <a class="Type" href="options.html#'softtabstop'">'softtabstop'</a>, etc.<br>
<br>
In <a class="Type" href="options.html#'list'">'list'</a> mode, Virtual Replace mode acts as if it was not in <a class="Type" href="options.html#'list'">'list'</a> mode,<br>
unless "L" is in <a class="Type" href="options.html#'cpoptions'">'cpoptions'</a>.<br>
<br>
<span class="Todo">Note</span> that the only situations for which characters beyond the cursor should<br>
appear to move are in List mode <a class="Identifier" href="options.html#'list'">'list'</a>, and occasionally when <a class="Type" href="options.html#'wrap'">'wrap'</a> is set<br>
(and the line changes length to become shorter or wider than the width of the<br>
screen). In other cases spaces may be inserted to avoid following characters<br>
to move.<br>
<br>
This mode is very useful for editing <span class="Special"><Tab></span> separated columns in tables, for<br>
entering new data while keeping all the columns aligned.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
7. Insert mode completion <a class="Constant" href="insert.html#ins-completion" name="ins-completion">ins-completion</a><br>
<br>
In Insert and Replace mode, there are several commands to complete part of a<br>
keyword or line that has been typed. This is useful if you are using<br>
complicated keywords (e.g., function names with capitals and underscores).<br>
<br>
These commands are not available when the <a class="Identifier" href="various.html#+insert_expand">+insert_expand</a> feature was<br>
disabled at compile time.<br>
<br>
Completion can be done for:<br>
<br>
1. Whole lines <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-L">i_CTRL-X_CTRL-L</a><br>
2. keywords in the current file <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-N">i_CTRL-X_CTRL-N</a><br>
3. keywords in <a class="Type" href="options.html#'dictionary'">'dictionary'</a> <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-K">i_CTRL-X_CTRL-K</a><br>
4. keywords in <a class="Type" href="options.html#'thesaurus'">'thesaurus'</a>, thesaurus-style <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-T">i_CTRL-X_CTRL-T</a><br>
5. keywords in the current and included files <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-I">i_CTRL-X_CTRL-I</a><br>
6. tags <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-]">i_CTRL-X_CTRL-]</a><br>
7. file names <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-F">i_CTRL-X_CTRL-F</a><br>
8. definitions or macros <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-D">i_CTRL-X_CTRL-D</a><br>
9. Vim command-line <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-V">i_CTRL-X_CTRL-V</a><br>
10. User defined completion <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-U">i_CTRL-X_CTRL-U</a><br>
11. omni completion <a class="Identifier" href="insert.html#i_CTRL-X_CTRL-O">i_CTRL-X_CTRL-O</a><br>
12. Spelling suggestions <a class="Identifier" href="insert.html#i_CTRL-X_s">i_CTRL-X_s</a><br>
13. keywords in <a class="Type" href="options.html#'complete'">'complete'</a> <a class="Identifier" href="insert.html#i_CTRL-N">i_CTRL-N</a> <a class="Identifier" href="insert.html#i_CTRL-P">i_CTRL-P</a><br>
<br>
All these, except <span class="Special">CTRL-N</span> and <span class="Special">CTRL-P</span>, are done in <span class="Special">CTRL-X</span> mode. This is a<br>
sub-mode of Insert and Replace modes. You enter <span class="Special">CTRL-X</span> mode by typing <span class="Special">CTRL-X</span><br>
and one of the <span class="Special">CTRL-X</span> commands. You exit <span class="Special">CTRL-X</span> mode by typing a key that is<br>
not a valid <span class="Special">CTRL-X</span> mode command. Valid keys are the <span class="Special">CTRL-X</span> command itself,<br>
<span class="Special">CTRL-N</span> (next), and <span class="Special">CTRL-P</span> (previous).<br>
<br>
Also see the <a class="Type" href="options.html#'infercase'">'infercase'</a> option if you want to adjust the case of the match.<br>
<br>
<a class="Constant" href="insert.html#complete_CTRL-E" name="complete_CTRL-E">complete_CTRL-E</a><br>
When completion is active you can use <span class="Special">CTRL-E</span> to stop it and go back to the<br>
originally typed text. The <span class="Special">CTRL-E</span> will not be inserted.<br>
<br>
<a class="Constant" href="insert.html#complete_CTRL-Y" name="complete_CTRL-Y">complete_CTRL-Y</a><br>
When the popup menu is displayed you can use <span class="Special">CTRL-Y</span> to stop completion and<br>
accept the currently selected entry. The <span class="Special">CTRL-Y</span> is not inserted. Typing a<br>
space, Enter, or some other unprintable character will leave completion mode<br>
and insert that typed character.<br>
<br>
When the popup menu is displayed there are a few more special keys, see<br>
<a class="Identifier" href="insert.html#popupmenu-keys">popupmenu-keys</a>.<br>
<br>
<span class="Todo">Note</span>: The keys that are valid in <span class="Special">CTRL-X</span> mode are not mapped. This allows for<br>
":map ^F ^X^F" to work (where ^F is <span class="Special">CTRL-F</span> and ^X is <span class="Special">CTRL-X</span>). The key that<br>
ends <span class="Special">CTRL-X</span> mode (any key that is not a valid <span class="Special">CTRL-X</span> mode command) is mapped.<br>
Also, when doing completion with <a class="Type" href="options.html#'complete'">'complete'</a> mappings apply as usual.<br>
<br>
<span class="Todo">Note</span>: While completion is active Insert mode can't be used recursively.<br>
Mappings that somehow invoke ":normal i.." will generate an E523 error.<br>
<br>
The following mappings are suggested to make typing the completion commands<br>
a bit easier (although they will hide other commands):<br>
<div class="helpExample"> :inoremap ^] ^X^]<br>
:inoremap ^F ^X^F<br>
:inoremap ^D ^X^D<br>
:inoremap ^L ^X^L</div>
<br>
As a special case, typing <span class="Special">CTRL-R</span> to perform register insertion (see<br>
<a class="Identifier" href="insert.html#i_CTRL-R">i_CTRL-R</a>) will not exit <span class="Special">CTRL-X</span> mode. This is primarily to allow the use of<br>
the '=' register to call some function to determine the next operation. If<br>
the contents of the register (or result of the '=' register evaluation) are<br>
not valid <span class="Special">CTRL-X</span> mode keys, then <span class="Special">CTRL-X</span> mode will be exited as if those keys<br>
had been typed.<br>
<br>
For example, the following will map <span class="Special"><Tab></span> to either actually insert a <span class="Special"><Tab></span> if<br>
the current line is currently only whitespace, or start/continue a <span class="Special">CTRL-N</span><br>
completion operation:<br>
<br>
<div class="helpExample"> function! CleverTab()<br>
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'<br>
return "\<Tab>"<br>
else<br>
return "\<C-N>"<br>
endif<br>
endfunction<br>
inoremap <Tab> <C-R>=CleverTab()<CR></div>
<br>
<br>
<br>
Completing whole lines <a class="Constant" href="insert.html#compl-whole-line" name="compl-whole-line">compl-whole-line</a><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-L" name="i_CTRL-X_CTRL-L">i_CTRL-X_CTRL-L</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-L</span> Search backwards for a line that starts with the<br>
same characters as those in the current line before<br>
the cursor. Indent is ignored. The matching line is<br>
inserted in front of the cursor.<br>
The <a class="Type" href="options.html#'complete'">'complete'</a> option is used to decide which buffers<br>
are searched for a match. Both loaded and unloaded<br>
buffers are used.<br>
<span class="Special">CTRL-L</span> or<br>
<span class="Special">CTRL-P</span> Search backwards for next matching line. This line<br>
replaces the previous matching line.<br>
<br>
<span class="Special">CTRL-N</span> Search forward for next matching line. This line<br>
replaces the previous matching line.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-L</span> After expanding a line you can additionally get the<br>
line next to it by typing <span class="Special">CTRL-X</span> <span class="Special">CTRL-L</span> again, unless<br>
a double <span class="Special">CTRL-X</span> is used. Only works for loaded<br>
buffers.<br>
<br>
Completing keywords in current file <a class="Constant" href="insert.html#compl-current" name="compl-current">compl-current</a><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-P" name="i_CTRL-X_CTRL-P">i_CTRL-X_CTRL-P</a><br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-N" name="i_CTRL-X_CTRL-N">i_CTRL-X_CTRL-N</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> Search forwards for words that start with the keyword<br>
in front of the cursor. The found keyword is inserted<br>
in front of the cursor.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> Search backwards for words that start with the keyword<br>
in front of the cursor. The found keyword is inserted<br>
in front of the cursor.<br>
<br>
<span class="Special">CTRL-N</span> Search forward for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-P</span> Search backwards for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> or<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> Further use of <span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> or <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> will<br>
copy the words following the previous expansion in<br>
other contexts unless a double <span class="Special">CTRL-X</span> is used.<br>
<br>
If there is a keyword in front of the cursor (a name made out of alphabetic<br>
characters and characters in <a class="Type" href="options.html#'iskeyword'">'iskeyword'</a>), it is used as the search pattern,<br>
with "\<" prepended (meaning: start of a word). Otherwise "\<\k\k" is used<br>
as search pattern (start of any keyword of at least two characters).<br>
<br>
In Replace mode, the number of characters that are replaced depends on the<br>
length of the matched string. This works like typing the characters of the<br>
matched string in Replace mode.<br>
<br>
If there is not a valid keyword character before the cursor, any keyword of<br>
at least two characters is matched.<br>
e.g., to get:<br>
printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);<br>
just type:<br>
printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);<br>
<br>
The search wraps around the end of the file, the value of <a class="Type" href="options.html#'wrapscan'">'wrapscan'</a> is not<br>
used here.<br>
<br>
Multiple repeats of the same completion are skipped; thus a different match<br>
will be inserted at each <span class="Special">CTRL-N</span> and <span class="Special">CTRL-P</span> (unless there is only one<br>
matching keyword).<br>
<br>
Single character matches are never included, as they usually just get in<br>
the way of what you were really after.<br>
e.g., to get:<br>
printf("name = %s\n", name);<br>
just type:<br>
printf("name = %s\n", n^P);<br>
or even:<br>
printf("name = %s\n", ^P);<br>
The 'n' in '\n' is skipped.<br>
<br>
After expanding a word, you can use <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> or <span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> to get the<br>
word following the expansion in other contexts. These sequences search for<br>
the text just expanded and further expand by getting an extra word. This is<br>
useful if you need to repeat a sequence of complicated words. Although <span class="Special">CTRL-P</span><br>
and <span class="Special">CTRL-N</span> look just for strings of at least two characters, <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> and<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> can be used to expand words of just one character.<br>
e.g., to get:<br>
M&eacute;xico<br>
you can type:<br>
M^<span class="Special">N</span>^P^X^P^X^P<br>
<span class="Special">CTRL-N</span> starts the expansion and then <span class="Special">CTRL-P</span> takes back the single character<br>
"M", the next two <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span>'s get the words "&eacute" and ";xico".<br>
<br>
If the previous expansion was split, because it got longer than <a class="Type" href="options.html#'textwidth'">'textwidth'</a>,<br>
then just the text in the current line will be used.<br>
<br>
If the match found is at the end of a line, then the first word in the next<br>
line will be inserted and the message "word from next line" displayed, if<br>
this word is accepted the next <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> or <span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> will search<br>
for those lines starting with this word.<br>
<br>
<br>
Completing keywords in <a class="Type" href="options.html#'dictionary'">'dictionary'</a> <a class="Constant" href="insert.html#compl-dictionary" name="compl-dictionary">compl-dictionary</a><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-K" name="i_CTRL-X_CTRL-K">i_CTRL-X_CTRL-K</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-K</span> Search the files given with the <a class="Type" href="options.html#'dictionary'">'dictionary'</a> option<br>
for words that start with the keyword in front of the<br>
cursor. This is like <span class="Special">CTRL-N</span>, but only the dictionary<br>
files are searched, not the current file. The found<br>
keyword is inserted in front of the cursor. This<br>
could potentially be pretty slow, since all matches<br>
are found before the first match is used. By default,<br>
the <a class="Type" href="options.html#'dictionary'">'dictionary'</a> option is empty.<br>
For suggestions where to find a list of words, see the<br>
<a class="Type" href="options.html#'dictionary'">'dictionary'</a> option.<br>
<br>
<span class="Special">CTRL-K</span> or<br>
<span class="Special">CTRL-N</span> Search forward for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-P</span> Search backwards for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-T" name="i_CTRL-X_CTRL-T">i_CTRL-X_CTRL-T</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-T</span> Works as <span class="Special">CTRL-X</span> <span class="Special">CTRL-K</span>, but in a special way. It uses<br>
the <a class="Type" href="options.html#'thesaurus'">'thesaurus'</a> option instead of <a class="Type" href="options.html#'dictionary'">'dictionary'</a>. If a<br>
match is found in the thesaurus file, all the<br>
remaining words on the same line are included as<br>
matches, even though they don't complete the word.<br>
Thus a word can be completely replaced.<br>
<br>
For an example, imagine the <a class="Type" href="options.html#'thesaurus'">'thesaurus'</a> file has a<br>
line like this:<br>
<div class="helpExample"> angry furious mad enraged</div>
Placing the cursor after the letters "ang" and typing<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-T</span> would complete the word "angry";<br>
subsequent presses would change the word to "furious",<br>
"mad" etc.<br>
Other uses include translation between two languages,<br>
or grouping API functions by keyword.<br>
<br>
<span class="Special">CTRL-T</span> or<br>
<span class="Special">CTRL-N</span> Search forward for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-P</span> Search backwards for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<br>
Completing keywords in the current and included files <a class="Constant" href="insert.html#compl-keyword" name="compl-keyword">compl-keyword</a><br>
<br>
The <a class="Type" href="options.html#'include'">'include'</a> option is used to specify a line that contains an include file<br>
name. The <a class="Type" href="options.html#'path'">'path'</a> option is used to search for include files.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-I" name="i_CTRL-X_CTRL-I">i_CTRL-X_CTRL-I</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-I</span> Search for the first keyword in the current and<br>
included files that starts with the same characters<br>
as those before the cursor. The matched keyword is<br>
inserted in front of the cursor.<br>
<br>
<span class="Special">CTRL-N</span> Search forwards for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<span class="Todo">Note</span>: <span class="Special">CTRL-I</span> is the same as <span class="Special"><Tab></span>, which is likely to<br>
be typed after a successful completion, therefore<br>
<span class="Special">CTRL-I</span> is not used for searching for the next match.<br>
<br>
<span class="Special">CTRL-P</span> Search backward for previous matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-I</span> Further use of <span class="Special">CTRL-X</span> <span class="Special">CTRL-I</span> will copy the words<br>
following the previous expansion in other contexts<br>
unless a double <span class="Special">CTRL-X</span> is used.<br>
<br>
Completing tags <a class="Constant" href="insert.html#compl-tag" name="compl-tag">compl-tag</a><br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-]" name="i_CTRL-X_CTRL-]">i_CTRL-X_CTRL-]</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-]</span> Search for the first tag that starts with the same<br>
characters as before the cursor. The matching tag is<br>
inserted in front of the cursor. Alphabetic<br>
characters and characters in <a class="Type" href="options.html#'iskeyword'">'iskeyword'</a> are used<br>
to decide which characters are included in the tag<br>
name (same as for a keyword). See also <a class="Identifier" href="tagsrch.html#CTRL-]">CTRL-]</a>.<br>
The <a class="Type" href="options.html#'showfulltag'">'showfulltag'</a> option can be used to add context<br>
from around the tag definition.<br>
<span class="Special">CTRL-]</span> or<br>
<span class="Special">CTRL-N</span> Search forwards for next matching tag. This tag<br>
replaces the previous matching tag.<br>
<br>
<span class="Special">CTRL-P</span> Search backward for previous matching tag. This tag<br>
replaces the previous matching tag.<br>
<br>
<br>
Completing file names <a class="Constant" href="insert.html#compl-filename" name="compl-filename">compl-filename</a><br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-F" name="i_CTRL-X_CTRL-F">i_CTRL-X_CTRL-F</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-F</span> Search for the first file name that starts with the<br>
same characters as before the cursor. The matching<br>
file name is inserted in front of the cursor.<br>
Alphabetic characters and characters in <a class="Type" href="options.html#'isfname'">'isfname'</a><br>
are used to decide which characters are included in<br>
the file name. <span class="Todo">Note</span>: the <a class="Type" href="options.html#'path'">'path'</a> option is not used<br>
here (yet).<br>
<span class="Special">CTRL-F</span> or<br>
<span class="Special">CTRL-N</span> Search forwards for next matching file name. This<br>
file name replaces the previous matching file name.<br>
<br>
<span class="Special">CTRL-P</span> Search backward for previous matching file name.<br>
This file name replaces the previous matching file<br>
name.<br>
<br>
<br>
Completing definitions or macros <a class="Constant" href="insert.html#compl-define" name="compl-define">compl-define</a><br>
<br>
The <a class="Type" href="options.html#'define'">'define'</a> option is used to specify a line that contains a definition.<br>
The <a class="Type" href="options.html#'include'">'include'</a> option is used to specify a line that contains an include file<br>
name. The <a class="Type" href="options.html#'path'">'path'</a> option is used to search for include files.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-D" name="i_CTRL-X_CTRL-D">i_CTRL-X_CTRL-D</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-D</span> Search in the current and included files for the<br>
first definition (or macro) name that starts with<br>
the same characters as before the cursor. The found<br>
definition name is inserted in front of the cursor.<br>
<span class="Special">CTRL-D</span> or<br>
<span class="Special">CTRL-N</span> Search forwards for next matching macro name. This<br>
macro name replaces the previous matching macro<br>
name.<br>
<br>
<span class="Special">CTRL-P</span> Search backward for previous matching macro name.<br>
This macro name replaces the previous matching macro<br>
name.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-D</span> Further use of <span class="Special">CTRL-X</span> <span class="Special">CTRL-D</span> will copy the words<br>
following the previous expansion in other contexts<br>
unless a double <span class="Special">CTRL-X</span> is used.<br>
<br>
<br>
Completing Vim commands <a class="Constant" href="insert.html#compl-vim" name="compl-vim">compl-vim</a><br>
<br>
Completion is context-sensitive. It works like on the Command-line. It<br>
completes an Ex command as well as its arguments. This is useful when writing<br>
a Vim script.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-V" name="i_CTRL-X_CTRL-V">i_CTRL-X_CTRL-V</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-V</span> Guess what kind of item is in front of the cursor and<br>
find the first match for it.<br>
<span class="Todo">Note</span>: When <span class="Special">CTRL-V</span> is mapped you can often use <span class="Special">CTRL-Q</span><br>
instead of <a class="Identifier" href="insert.html#i_CTRL-Q">i_CTRL-Q</a>.<br>
<span class="Special">CTRL-V</span> or<br>
<span class="Special">CTRL-N</span> Search forwards for next match. This match replaces<br>
the previous one.<br>
<br>
<span class="Special">CTRL-P</span> Search backwards for previous match. This match<br>
replaces the previous one.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-V</span> Further use of <span class="Special">CTRL-X</span> <span class="Special">CTRL-V</span> will do the same as<br>
<span class="Special">CTRL-V</span>. This allows mapping a key to do Vim command<br>
completion, for example:<br>
<div class="helpExample"> :imap <Tab> <C-X><C-V></div>
<br>
User defined completion <a class="Constant" href="insert.html#compl-function" name="compl-function">compl-function</a><br>
<br>
Completion is done by a function that can be defined by the user with the<br>
<a class="Type" href="options.html#'completefunc'">'completefunc'</a> option. See below for how the function is called and an<br>
example <a class="Identifier" href="insert.html#complete-functions">complete-functions</a>.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-U" name="i_CTRL-X_CTRL-U">i_CTRL-X_CTRL-U</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-U</span> Guess what kind of item is in front of the cursor and<br>
find the first match for it.<br>
<span class="Special">CTRL-U</span> or<br>
<span class="Special">CTRL-N</span> Use the next match. This match replaces the previous<br>
one.<br>
<br>
<span class="Special">CTRL-P</span> Use the previous match. This match replaces the<br>
previous one.<br>
<br>
<br>
Omni completion <a class="Constant" href="insert.html#compl-omni" name="compl-omni">compl-omni</a><br>
<br>
Completion is done by a function that can be defined by the user with the<br>
<a class="Type" href="options.html#'omnifunc'">'omnifunc'</a> option. This is to be used for filetype-specific completion.<br>
<br>
See below for how the function is called and an example <a class="Identifier" href="insert.html#complete-functions">complete-functions</a>.<br>
For remarks about specific filetypes see <a class="Identifier" href="insert.html#compl-omni-filetypes">compl-omni-filetypes</a>.<br>
More completion scripts will appear, check <span class="Constant">www.vim.org</span>. Currently there is a<br>
first version for C++.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-O" name="i_CTRL-X_CTRL-O">i_CTRL-X_CTRL-O</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> Guess what kind of item is in front of the cursor and<br>
find the first match for it.<br>
<span class="Special">CTRL-O</span> or<br>
<span class="Special">CTRL-N</span> Use the next match. This match replaces the previous<br>
one.<br>
<br>
<span class="Special">CTRL-P</span> Use the previous match. This match replaces the<br>
previous one.<br>
<br>
<br>
Spelling suggestions <a class="Constant" href="insert.html#compl-spelling" name="compl-spelling">compl-spelling</a><br>
<br>
A word before or at the cursor is located and correctly spelled words are<br>
suggested to replace it. If there is a badly spelled word in the line, before<br>
or under the cursor, the cursor is moved to after it. Otherwise the word just<br>
before the cursor is used for suggestions, even though it isn't badly spelled.<br>
<br>
<span class="Todo">NOTE</span>: <span class="Special">CTRL-S</span> suspends display in many Unix terminals. Use 's' instead. Type<br>
<span class="Special">CTRL-Q</span> to resume displaying.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-X_CTRL-S" name="i_CTRL-X_CTRL-S">i_CTRL-X_CTRL-S</a> <a class="Constant" href="insert.html#i_CTRL-X_s" name="i_CTRL-X_s">i_CTRL-X_s</a><br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-S</span> or<br>
<span class="Special">CTRL-X</span> s Locate the word in front of the cursor and find the<br>
first spell suggestion for it.<br>
<span class="Special">CTRL-S</span> or<br>
<span class="Special">CTRL-N</span> Use the next suggestion. This replaces the previous<br>
one. <span class="Todo">Note</span> that you can't use 's' here.<br>
<br>
<span class="Special">CTRL-P</span> Use the previous suggestion. This replaces the<br>
previous one.<br>
<br>
<br>
Completing keywords from different sources <a class="Constant" href="insert.html#compl-generic" name="compl-generic">compl-generic</a><br>
<br>
<a class="Constant" href="insert.html#i_CTRL-N" name="i_CTRL-N">i_CTRL-N</a><br>
<span class="Special">CTRL-N</span> Find next match for words that start with the<br>
keyword in front of the cursor, looking in places<br>
specified with the <a class="Type" href="options.html#'complete'">'complete'</a> option. The found<br>
keyword is inserted in front of the cursor.<br>
<br>
<a class="Constant" href="insert.html#i_CTRL-P" name="i_CTRL-P">i_CTRL-P</a><br>
<span class="Special">CTRL-P</span> Find previous match for words that start with the<br>
keyword in front of the cursor, looking in places<br>
specified with the <a class="Type" href="options.html#'complete'">'complete'</a> option. The found<br>
keyword is inserted in front of the cursor.<br>
<br>
<span class="Special">CTRL-N</span> Search forward for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-P</span> Search backwards for next matching keyword. This<br>
keyword replaces the previous matching keyword.<br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> or<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> Further use of <span class="Special">CTRL-X</span> <span class="Special">CTRL-N</span> or <span class="Special">CTRL-X</span> <span class="Special">CTRL-P</span> will<br>
copy the words following the previous expansion in<br>
other contexts unless a double <span class="Special">CTRL-X</span> is used.<br>
<br>
<br>
<span class="Statement">FUNCTIONS FOR FINDING COMPLETIONS </span><a class="Constant" href="insert.html#complete-functions" name="complete-functions">complete-functions</a><br>
<br>
This applies to <a class="Type" href="options.html#'completefunc'">'completefunc'</a> and <a class="Type" href="options.html#'omnifunc'">'omnifunc'</a>.<br>
<br>
The function is called in two different ways:<br>
- First the function is called to find the start of the text to be completed.<br>
- Later the function is called to actually find the matches.<br>
<br>
On the first invocation the arguments are:<br>
a:findstart 1<br>
a:base empty<br>
<br>
The function must return the column where the completion starts. It must be a<br>
number between zero and the cursor column "col('.')". This involves looking<br>
at the characters just before the cursor and including those characters that<br>
could be part of the completed item. The text between this column and the<br>
cursor column will be replaced with the matches.<br>
<br>
Special return values:<br>
-1 If no completion can be done, the completion will be cancelled with an<br>
error message.<br>
-2 To cancel silently and stay in completion mode.<br>
-3 To cancel silently and leave completion mode.<br>
<br>
On the second invocation the arguments are:<br>
a:findstart 0<br>
a:base the text with which matches should match; the text that was<br>
located in the first call (can be empty)<br>
<br>
The function must return a List with the matching words. These matches<br>
usually include the "a:base" text. When there are no matches return an empty<br>
List.<br>
<br>
In order to return more information than the matching words, return a Dict<br>
that contains the List. The Dict can have these items:<br>
words The List of matching words (mandatory).<br>
refresh A string to control re-invocation of the function<br>
(optional).<br>
The only value currently recognized is "always", the<br>
effect is that the function is called whenever the<br>
leading text is changed.<br>
Other items are ignored.<br>
<br>
For acting upon end of completion, see the <a class="Identifier" href="autocmd.html#CompleteDone">CompleteDone</a> autocommand event.<br>
<br>
For example, the function can contain this:<br>
<div class="helpExample"> let matches = ... list of words ...<br>
return {'words': matches, 'refresh': 'always'}</div>
<br>
<a class="Constant" href="insert.html#complete-items" name="complete-items">complete-items</a><br>
Each list item can either be a string or a Dictionary. When it is a string it<br>
is used as the completion. When it is a Dictionary it can contain these<br>
items:<br>
word the text that will be inserted, mandatory<br>
abbr abbreviation of "word"; when not empty it is used in<br>
the menu instead of "word"<br>
menu extra text for the popup menu, displayed after "word"<br>
or "abbr"<br>
info more information about the item, can be displayed in a<br>
preview window<br>
kind single letter indicating the type of completion<br>
icase when non-zero case is to be ignored when comparing<br>
items to be equal; when omitted zero is used, thus<br>
items that only differ in case are added<br>
dup when non-zero this match will be added even when an<br>
item with the same word is already present.<br>
empty when non-zero this match will be added even when it is<br>
an empty string<br>
<br>
All of these except "icase", "dup" and "empty" must be a string. If an item<br>
does not meet these requirements then an error message is given and further<br>
items in the list are not used. You can mix string and Dictionary items in<br>
the returned list.<br>
<br>
The "menu" item is used in the popup menu and may be truncated, thus it should<br>
be relatively short. The "info" item can be longer, it will be displayed in<br>
the preview window when "preview" appears in <a class="Type" href="options.html#'completeopt'">'completeopt'</a>. The "info" item<br>
will also remain displayed after the popup menu has been removed. This is<br>
useful for function arguments. Use a single space for "info" to remove<br>
existing text in the preview window. The size of the preview window is three<br>
lines, but <a class="Type" href="options.html#'previewheight'">'previewheight'</a> is used when it has a value of 1 or 2.<br>
<br>
The "kind" item uses a single letter to indicate the kind of completion. This<br>
may be used to show the completion differently (different color or icon).<br>
Currently these types can be used:<br>
v variable<br>
f function or method<br>
m member of a struct or class<br>
t typedef<br>
d #define or macro<br>
<br>
When searching for matches takes some time call <a class="Identifier" href="eval.html#complete_add()">complete_add()</a> to add each<br>
match to the total list. These matches should then not appear in the returned<br>
list! Call <a class="Identifier" href="eval.html#complete_check()">complete_check()</a> now and then to allow the user to press a key<br>
while still searching for matches. Stop searching when it returns non-zero.<br>
<br>
<a class="Constant" href="insert.html#E839" name="E839">E839</a> <a class="Constant" href="insert.html#E840" name="E840">E840</a><br>
The function is allowed to move the cursor, it is restored afterwards.<br>
The function is not allowed to move to another window or delete text.<br>
<br>
An example that completes the names of the months:<br>
<div class="helpExample"> fun! CompleteMonths(findstart, base)<br>
if a:findstart<br>
" locate the start of the word<br>
let line = getline('.')<br>
let start = col('.') - 1<br>
while start > 0 && line[start - 1] =~ '\a'<br>
let start -= 1<br>
endwhile<br>
return start<br>
else<br>
" find months matching with "a:base"<br>
let res = []<br>
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")<br>
if m =~ '^' . a:base<br>
call add(res, m)<br>
endif<br>
endfor<br>
return res<br>
endif<br>
endfun<br>
set completefunc=CompleteMonths</div>
<br>
The same, but now pretending searching for matches is slow:<br>
<div class="helpExample"> fun! CompleteMonths(findstart, base)<br>
if a:findstart<br>
" locate the start of the word<br>
let line = getline('.')<br>
let start = col('.') - 1<br>
while start > 0 && line[start - 1] =~ '\a'<br>
let start -= 1<br>
endwhile<br>
return start<br>
else<br>
" find months matching with "a:base"<br>
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")<br>
if m =~ '^' . a:base<br>
call complete_add(m)<br>
endif<br>
sleep 300m " simulate searching for next match<br>
if complete_check()<br>
break<br>
endif<br>
endfor<br>
return []<br>
endif<br>
endfun<br>
set completefunc=CompleteMonths</div>
<br>
<br>
<span class="Statement">INSERT COMPLETION POPUP MENU </span><a class="Constant" href="insert.html#ins-completion-menu" name="ins-completion-menu">ins-completion-menu</a><br>
<a class="Constant" href="insert.html#popupmenu-completion" name="popupmenu-completion">popupmenu-completion</a><br>
Vim can display the matches in a simplistic popup menu.<br>
<br>
The menu is used when:<br>
- The <a class="Type" href="options.html#'completeopt'">'completeopt'</a> option contains "menu" or "menuone".<br>
- The terminal supports at least 8 colors.<br>
- There are at least two matches. One if "menuone" is used.<br>
<br>
The <a class="Type" href="options.html#'pumheight'">'pumheight'</a> option can be used to set a maximum height. The default is to<br>
use all space available.<br>
<br>
There are three states:<br>
1. A complete match has been inserted, e.g., after using <span class="Special">CTRL-N</span> or <span class="Special">CTRL-P</span>.<br>
2. A cursor key has been used to select another match. The match was not<br>
inserted then, only the entry in the popup menu is highlighted.<br>
3. Only part of a match has been inserted and characters were typed or the<br>
backspace key was used. The list of matches was then adjusted for what is<br>
in front of the cursor.<br>
<br>
You normally start in the first state, with the first match being inserted.<br>
When "longest" is in <a class="Type" href="options.html#'completeopt'">'completeopt'</a> and there is more than one match you start<br>
in the third state.<br>
<br>
If you select another match, e.g., with <span class="Special">CTRL-N</span> or <span class="Special">CTRL-P</span>, you go to the first<br>
state. This doesn't change the list of matches.<br>
<br>
When you are back at the original text then you are in the third state. To<br>
get there right away you can use a mapping that uses <span class="Special">CTRL-P</span> right after<br>
starting the completion:<br>
<div class="helpExample"> :imap <F7> <C-N><C-P></div>
<br>
<a class="Constant" href="insert.html#popupmenu-keys" name="popupmenu-keys">popupmenu-keys</a><br>
In the first state these keys have a special meaning:<br>
<span class="Special"><BS></span> and <span class="Special">CTRL-H</span> Delete one character, find the matches for the word before<br>
the cursor. This reduces the list of matches, often to one<br>
entry, and switches to the second state.<br>
Any non-special character:<br>
Stop completion without changing the match and insert the<br>
typed character.<br>
<br>
In the second and third state these keys have a special meaning:<br>
<span class="Special"><BS></span> and <span class="Special">CTRL-H</span> Delete one character, find the matches for the shorter word<br>
before the cursor. This may find more matches.<br>
<span class="Special">CTRL-L</span> Add one character from the current match, may reduce the<br>
number of matches.<br>
any printable, non-white character:<br>
Add this character and reduce the number of matches.<br>
<br>
In all three states these can be used:<br>
<span class="Special">CTRL-Y</span> Yes: Accept the currently selected match and stop completion.<br>
<span class="Special">CTRL-E</span> End completion, go back to what was there before selecting a<br>
match (what was typed or longest common string).<br>
<span class="Special"><PageUp></span> Select a match several entries back, but don't insert it.<br>
<span class="Special"><PageDown></span> Select a match several entries further, but don't insert it.<br>
<span class="Special"><Up></span> Select the previous match, as if <span class="Special">CTRL-P</span> was used, but don't<br>
insert it.<br>
<span class="Special"><Down></span> Select the next match, as if <span class="Special">CTRL-N</span> was used, but don't<br>
insert it.<br>
<span class="Special"><Space></span> or <span class="Special"><Tab></span> Stop completion without changing the match and insert the<br>
typed character.<br>
<br>
The behavior of the <span class="Special"><Enter></span> key depends on the state you are in:<br>
first state: Use the text as it is and insert a line break.<br>
second state: Insert the currently selected match.<br>
third state: Use the text as it is and insert a line break.<br>
<br>
In other words: If you used the cursor keys to select another entry in the<br>
list of matches then the <span class="Special"><Enter></span> key inserts that match. If you typed<br>
something else then <span class="Special"><Enter></span> inserts a line break.<br>
<br>
<br>
The colors of the menu can be changed with these highlight groups:<br>
Pmenu normal item <a class="Identifier" href="syntax.html#hl-Pmenu">hl-Pmenu</a><br>
PmenuSel selected item <a class="Identifier" href="syntax.html#hl-PmenuSel">hl-PmenuSel</a><br>
PmenuSbar scrollbar <a class="Identifier" href="syntax.html#hl-PmenuSbar">hl-PmenuSbar</a><br>
PmenuThumb thumb of the scrollbar <a class="Identifier" href="syntax.html#hl-PmenuThumb">hl-PmenuThumb</a><br>
<br>
There are no special mappings for when the popup menu is visible. However,<br>
you can use an Insert mode mapping that checks the <a class="Identifier" href="eval.html#pumvisible()">pumvisible()</a> function to<br>
do something different. Example:<br>
<div class="helpExample"> :inoremap <Down> <C-R>=pumvisible() ? "\<lt>C-N>" : "\<lt>Down>"<CR></div>
<br>
You can use of <span class="Special"><expr></span> in mapping to have the popup menu used when typing a<br>
character and some condition is met. For example, for typing a dot:<br>
<div class="helpExample"> inoremap <expr> . MayComplete()<br>
func MayComplete()<br>
if (can complete)<br>
return ".\<C-X>\<C-O>"<br>
endif<br>
return '.'<br>
endfunc</div>
<br>
See <a class="Identifier" href="map.html#:map-<expr>">:map-<expr></a> for more info.<br>
<br>
<br>
<span class="Statement">FILETYPE-SPECIFIC REMARKS FOR OMNI COMPLETION </span><a class="Constant" href="insert.html#compl-omni-filetypes" name="compl-omni-filetypes">compl-omni-filetypes</a><br>
<br>
The file used for <span class="Special">{filetype}</span> should be autoload/<span class="Special">{filetype}</span>complete.vim<br>
in <a class="Type" href="options.html#'runtimepath'">'runtimepath'</a>. Thus for "java" it is autoload/javacomplete.vim.<br>
<br>
<br>
<span class="Statement">C </span><a class="Constant" href="insert.html#ft-c-omni" name="ft-c-omni">ft-c-omni</a><br>
<br>
Completion of C code requires a tags file. You should use Exuberant ctags,<br>
because it adds extra information that is needed for completion. You can find<br>
it here: <span class="Constant"><a href="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</a></span> Version 5.6 or later is recommended.<br>
<br>
For version 5.5.4 you should add a patch that adds the "typename:" field:<br>
<span class="Constant">ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch</span><br>
A compiled .exe for MS-Windows can be found at:<br>
<span class="Constant"><a href="http://georgevreilly.com/vim/ctags.html">http://georgevreilly.com/vim/ctags.html</a></span><br>
<br>
If you want to complete system functions you can do something like this. Use<br>
ctags to generate a tags file for all the system header files:<br>
<div class="helpExample"> % ctags -R -f ~/.vim/systags /usr/include /usr/local/include</div>
In your vimrc file add this tags file to the <a class="Type" href="options.html#'tags'">'tags'</a> option:<br>
<div class="helpExample"> set tags+=~/.vim/systags</div>
<br>
When using <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> after a name without any "." or "->" it is completed<br>
from the tags file directly. This works for any identifier, also function<br>
names. If you want to complete a local variable name, which does not appear<br>
in the tags file, use <span class="Special">CTRL-P</span> instead.<br>
<br>
When using <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> after something that has "." or "->" Vim will attempt<br>
to recognize the type of the variable and figure out what members it has.<br>
This means only members valid for the variable will be listed.<br>
<br>
When a member name already was complete, <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> will add a "." or<br>
"->" for composite types.<br>
<br>
Vim doesn't include a C compiler, only the most obviously formatted<br>
declarations are recognized. Preprocessor stuff may cause confusion.<br>
When the same structure name appears in multiple places all possible members<br>
are included.<br>
<br>
<br>
<span class="Statement">CSS </span><a class="Constant" href="insert.html#ft-css-omni" name="ft-css-omni">ft-css-omni</a><br>
<br>
Complete properties and their appropriate values according to CSS 2.1<br>
specification.<br>
<br>
<br>
<span class="Statement">HTML </span><a class="Constant" href="insert.html#ft-html-omni" name="ft-html-omni">ft-html-omni</a><br>
<span class="Statement">XHTML </span><a class="Constant" href="insert.html#ft-xhtml-omni" name="ft-xhtml-omni">ft-xhtml-omni</a><br>
<br>
<span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> provides completion of various elements of (X)HTML files. It is<br>
designed to support writing of XHTML 1.0 Strict files but will also work for<br>
other versions of HTML. Features:<br>
<br>
- after "<" complete tag name depending on context (no div suggestion inside<br>
of an a tag); '/>' indicates empty tags<br>
- inside of tag complete proper attributes (no width attribute for an a tag);<br>
show also type of attribute; '*' indicates required attributes<br>
- when attribute has limited number of possible values help to complete them<br>
- complete names of entities<br>
- complete values of "class" and "id" attributes with data obtained from<br>
<span class="Special"><style></span> tag and included CSS files<br>
- when completing value of "style" attribute or working inside of "style" tag<br>
switch to <a class="Identifier" href="insert.html#ft-css-omni">ft-css-omni</a> completion<br>
- when completing values of events attributes or working inside of "script"<br>
tag switch to <a class="Identifier" href="insert.html#ft-javascript-omni">ft-javascript-omni</a> completion<br>
- when used after "</" <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> will close the last opened tag<br>
<br>
<span class="Todo">Note</span>: When used first time completion menu will be shown with little delay<br>
- this is time needed for loading of data file.<br>
<span class="Todo">Note</span>: Completion may fail in badly formatted documents. In such case try to<br>
run <a class="Identifier" href="quickfix.html#:make">:make</a> command to detect formatting problems.<br>
<br>
<br>
HTML flavor <a class="Constant" href="insert.html#html-flavor" name="html-flavor">html-flavor</a><br>
<br>
The default HTML completion depends on the filetype. For HTML files it is<br>
HTML 4.01 Transitional (<a class="Type" href="options.html#'filetype'">'filetype'</a> is "html"), for XHTML it is XHTML 1.0<br>
Strict (<a class="Type" href="options.html#'filetype'">'filetype'</a> is "xhtml").<br>
<br>
When doing completion outside of any other tag you will have possibility to<br>
choose DOCTYPE and the appropriate data file will be loaded and used for all<br>
next completions.<br>
<br>
More about format of data file in <a class="Identifier" href="insert.html#xml-omni-datafile">xml-omni-datafile</a>. Some of the data files<br>
may be found on the Vim website (<a class="Identifier" href="intro.html#www">www</a>).<br>
<br>
<span class="Todo">Note</span> that b:html_omni_flavor may point to a file with any XML data. This<br>
makes possible to mix PHP (<a class="Identifier" href="insert.html#ft-php-omni">ft-php-omni</a>) completion with any XML dialect<br>
(assuming you have data file for it). Without setting that variable XHTML 1.0<br>
Strict will be used.<br>
<br>
<br>
<span class="Statement">JAVASCRIPT </span><a class="Constant" href="insert.html#ft-javascript-omni" name="ft-javascript-omni">ft-javascript-omni</a><br>
<br>
Completion of most elements of JavaScript language and DOM elements.<br>
<br>
Complete:<br>
<br>
- variables<br>
- function name; show function arguments<br>
- function arguments<br>
- properties of variables trying to detect type of variable<br>
- complete DOM objects and properties depending on context<br>
- keywords of language<br>
<br>
Completion works in separate JavaScript files (&ft==javascript), inside of<br>
<span class="Special"><script></span> tag of (X)HTML and in values of event attributes (including scanning<br>
of external files).<br>
<br>
DOM compatibility<br>
<br>
At the moment (beginning of 2006) there are two main browsers - MS Internet<br>
Explorer and Mozilla Firefox. These two applications are covering over 90% of<br>
market. Theoretically standards are created by W3C organisation<br>
(<span class="Constant"><a href="http://www.w3c.org">http://www.w3c.org</a></span>) but they are not always followed/implemented.<br>
<br>
<span class="PreProc">IE FF W3C Omni completion</span><br>
<span class="PreProc">+/- +/- + + </span><br>
<span class="PreProc">+ + - + </span><br>
<span class="PreProc">+ - - - </span><br>
<span class="PreProc">- + - - </span><br>
<br>
Regardless from state of implementation in browsers but if element is defined<br>
in standards, completion plugin will place element in suggestion list. When<br>
both major engines implemented element, even if this is not in standards it<br>
will be suggested. All other elements are not placed in suggestion list.<br>
<br>
<br>
<span class="Statement">PHP </span><a class="Constant" href="insert.html#ft-php-omni" name="ft-php-omni">ft-php-omni</a><br>
<br>
Completion of PHP code requires a tags file for completion of data from<br>
external files and for class aware completion. You should use Exuberant ctags<br>
version 5.5.4 or newer. You can find it here: <span class="Constant"><a href="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</a></span><br>
<br>
Script completes:<br>
<br>
- after $ variables name<br>
- if variable was declared as object add "->", if tags file is available show<br>
name of class<br>
- after "->" complete only function and variable names specific for given<br>
class. To find class location and contents tags file is required. Because<br>
PHP isn't strongly typed language user can use @var tag to declare class:<br>
<br>
<div class="helpExample"> /* @var $myVar myClass */<br>
$myVar-></div>
<br>
Still, to find myClass contents tags file is required.<br>
<br>
- function names with additional info:<br>
- in case of built-in functions list of possible arguments and after | type<br>
data returned by function<br>
- in case of user function arguments and name of file where function was<br>
defined (if it is not current file)<br>
<br>
- constants names<br>
- class names after "new" declaration<br>
<br>
<br>
<span class="Todo">Note</span>: when doing completion first time Vim will load all necessary data into<br>
memory. It may take several seconds. After next use of completion delay<br>
should not be noticeable.<br>
<br>
Script detects if cursor is inside <?php ?> tags. If it is outside it will<br>
automatically switch to HTML/CSS/JavaScript completion. <span class="Todo">Note</span>: contrary to<br>
original HTML files completion of tags (and only tags) isn't context aware.<br>
<br>
<br>
<span class="Statement">RUBY </span><a class="Constant" href="insert.html#ft-ruby-omni" name="ft-ruby-omni">ft-ruby-omni</a><br>
<br>
Completion of Ruby code requires that vim be built with <a class="Identifier" href="various.html#+ruby">+ruby</a>.<br>
<br>
Ruby completion will parse your buffer on demand in order to provide a list of<br>
completions. These completions will be drawn from modules loaded by <span class="MissingTag">'require'</span><br>
and modules defined in the current buffer.<br>
<br>
The completions provided by <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> are sensitive to the context:<br>
<br>
<span class="PreProc">CONTEXT COMPLETIONS PROVIDED</span><br>
<br>
1. Not inside a class definition Classes, constants and globals<br>
<br>
2. Inside a class definition Methods or constants defined in the class<br>
<br>
3. After '.', '::' or ':' Methods applicable to the object being<br>
dereferenced<br>
<br>
4. After ':' or ':foo' Symbol name (beginning with <span class="MissingTag">'foo'</span>)<br>
<br>
<span class="Todo">Notes</span>:<br>
- Vim will load/evaluate code in order to provide completions. This may<br>
cause some code execution, which may be a concern. This is no longer <br>
enabled by default, to enable this feature add<br>
<div class="helpExample"> let g:rubycomplete_buffer_loading = 1</div>
- In context 1 above, Vim can parse the entire buffer to add a list of<br>
classes to the completion results. This feature is turned off by default,<br>
to enable it add<br>
<div class="helpExample"> let g:rubycomplete_classes_in_global = 1</div>
to your vimrc<br>
- In context 2 above, anonymous classes are not supported.<br>
- In context 3 above, Vim will attempt to determine the methods supported by<br>
the object.<br>
- Vim can detect and load the Rails environment for files within a rails<br>
project. The feature is disabled by default, to enable it add<br>
<div class="helpExample"> let g:rubycomplete_rails = 1</div>
to your vimrc<br>
<br>
<br>
<span class="Statement">SYNTAX </span><a class="Constant" href="insert.html#ft-syntax-omni" name="ft-syntax-omni">ft-syntax-omni</a><br>
<br>
Vim has the ability to color syntax highlight nearly 500 languages. Part of<br>
this highlighting includes knowing what keywords are part of a language. Many<br>
filetypes already have custom completion scripts written for them, the<br>
syntaxcomplete plugin provides basic completion for all other filetypes. It<br>
does this by populating the omni completion list with the text Vim already<br>
knows how to color highlight. It can be used for any filetype and provides a<br>
minimal language-sensitive completion.<br>
<br>
To enable syntax code completion you can run:<br>
<div class="helpExample"> setlocal omnifunc=syntaxcomplete#Complete</div>
<br>
You can automate this by placing the following in your <a class="Identifier" href="starting.html#.vimrc">.vimrc</a> (after any<br>
":filetype" command):<br>
<div class="helpExample"> if has("autocmd") && exists("+omnifunc")<br>
autocmd Filetype *<br>
\ if &omnifunc == "" |<br>
\ setlocal omnifunc=syntaxcomplete#Complete |<br>
\ endif<br>
endif</div>
<br>
The above will set completion to this script only if a specific plugin does<br>
not already exist for that filetype.<br>
<br>
Each filetype can have a wide range of syntax items. The plugin allows you to<br>
customize which syntax groups to include or exclude from the list. Let's have<br>
a look at the PHP filetype to see how this works.<br>
<br>
If you edit a file called, index.php, run the following command:<br>
<div class="helpExample"> syntax list</div>
<br>
The first thing you will notice is that there are many different syntax groups.<br>
The PHP language can include elements from different languages like HTML,<br>
JavaScript and many more. The syntax plugin will only include syntax groups<br>
that begin with the filetype, "php", in this case. For example these syntax<br>
groups are included by default with the PHP: phpEnvVar, phpIntVar,<br>
phpFunctions.<br>
<br>
If you wish non-filetype syntax items to also be included, you can use a <br>
regular expression syntax (added in version 13.0 of autoload\syntaxcomplete.vim)<br>
to add items. Looking at the output from ":syntax list" while editing a PHP file <br>
I can see some of these entries:<br>
<div class="helpExample"> htmlArg,htmlTag,htmlTagName,javaScriptStatement,javaScriptGlobalObjects</div>
<br>
To pick up any JavaScript and HTML keyword syntax groups while editing a PHP<br>
file, you can use 3 different regexs, one for each language. Or you can <br>
simply restrict the include groups to a particular value, without using <br>
a regex string:<br>
<div class="helpExample"> let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+'<br>
let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'</div>
<br>
The basic form of this variable is:<br>
<div class="helpExample"> let g:omni_syntax_group_include_{filetype} = 'regex,comma,separated'</div>
<br>
The PHP language has an enormous number of items which it knows how to syntax<br>
highlight. These items will be available within the omni completion list.<br>
<br>
Some people may find this list unwieldy or are only interested in certain<br>
items. There are two ways to prune this list (if necessary). If you find<br>
certain syntax groups you do not wish displayed you can use two different <br>
methods to identify these groups. The first specifically lists the syntax <br>
groups by name. The second uses a regular expression to identify both <br>
syntax groups. Simply add one the following to your vimrc:<br>
<div class="helpExample"> let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant'<br>
let g:omni_syntax_group_exclude_php = 'php\w*Constant'</div>
<br>
Add as many syntax groups to this list by comma separating them. The basic<br>
form of this variable is:<br>
<div class="helpExample"> let g:omni_syntax_group_exclude_{filetype} = 'regex,comma,separated'</div>
<br>
You can create as many of these variables as you need, varying only the<br>
filetype at the end of the variable name.<br>
<br>
The plugin uses the isKeyword option to determine where word boundaries are<br>
for the syntax items. For example, in the Scheme language completion should<br>
include the "-", call-with-output-file. Depending on your filetype, this may<br>
not provide the words you are expecting. Setting the<br>
g:omni_syntax_use_iskeyword option to 0 will force the syntax plugin to break<br>
on word characters. This can be controlled adding the following to your<br>
vimrc:<br>
<div class="helpExample"> let g:omni_syntax_use_iskeyword = 0</div>
<br>
For plugin developers, the plugin exposes a public function OmniSyntaxList.<br>
This function can be used to request a List of syntax items. When editing a<br>
SQL file (:e syntax.sql) you can use the ":syntax list" command to see the <br>
various groups and syntax items. For example:<br>
<div class="helpExample"> syntax list </div>
<br>
Yields data similar to this:<br>
<div class="helpExample"> sqlOperator xxx some prior all like and any escape exists in is not <br>
or intersect minus between distinct<br>
links to Operator<br>
sqlType xxx varbit varchar nvarchar bigint int uniqueidentifier <br>
date money long tinyint unsigned xml text smalldate <br>
double datetime nchar smallint numeric time bit char <br>
varbinary binary smallmoney<br>
image float integer timestamp real decimal</div>
<br>
There are two syntax groups listed here: sqlOperator and sqlType. To retrieve<br>
a List of syntax items you can call OmniSyntaxList a number of different <br>
ways. To retrieve all syntax items regardless of syntax group: <br>
<div class="helpExample"> echo OmniSyntaxList( [] )</div>
<br>
To retrieve only the syntax items for the sqlOperator syntax group:<br>
<div class="helpExample"> echo OmniSyntaxList( ['sqlOperator'] )</div>
<br>
To retrieve all syntax items for both the sqlOperator and sqlType groups:<br>
<div class="helpExample"> echo OmniSyntaxList( ['sqlOperator', 'sqlType'] )</div>
<br>
A regular expression can also be used:<br>
<div class="helpExample"> echo OmniSyntaxList( ['sql\w\+'] )</div>
<br>
From within a plugin, you would typically assign the output to a List:<br>
<div class="helpExample"> let myKeywords = []<br>
let myKeywords = OmniSyntaxList( ['sqlKeyword'] )</div>
<br>
<div class="helpExample"> </div>
<br>
<span class="Statement">SQL </span><a class="Constant" href="insert.html#ft-sql-omni" name="ft-sql-omni">ft-sql-omni</a><br>
<br>
Completion for the SQL language includes statements, functions, keywords.<br>
It will also dynamically complete tables, procedures, views and column lists<br>
with data pulled directly from within a database. For detailed instructions<br>
and a tutorial see <a class="Identifier" href="ft_sql.html#omni-sql-completion">omni-sql-completion</a>.<br>
<br>
The SQL completion plugin can be used in conjunction with other completion<br>
plugins. For example, the PHP filetype has its own completion plugin.<br>
Since PHP is often used to generate dynamic website by accessing a database,<br>
the SQL completion plugin can also be enabled. This allows you to complete<br>
PHP code and SQL code at the same time.<br>
<br>
<br>
<span class="Statement">XML </span><a class="Constant" href="insert.html#ft-xml-omni" name="ft-xml-omni">ft-xml-omni</a><br>
<br>
Vim 7 provides a mechanism for context aware completion of XML files. It<br>
depends on a special <a class="Identifier" href="insert.html#xml-omni-datafile">xml-omni-datafile</a> and two commands: <a class="Identifier" href="insert.html#:XMLns">:XMLns</a> and<br>
<a class="Identifier" href="insert.html#:XMLent">:XMLent</a>. Features are:<br>
<br>
- after "<" complete the tag name, depending on context<br>
- inside of a tag complete proper attributes<br>
- when an attribute has a limited number of possible values help to complete<br>
them<br>
- complete names of entities (defined in <a class="Identifier" href="insert.html#xml-omni-datafile">xml-omni-datafile</a> and in the<br>
current file with "<!ENTITY" declarations)<br>
- when used after "</" <span class="Special">CTRL-X</span> <span class="Special">CTRL-O</span> will close the last opened tag<br>
<br>
Format of XML data file <a class="Constant" href="insert.html#xml-omni-datafile" name="xml-omni-datafile">xml-omni-datafile</a><br>
<br>
XML data files are stored in the "autoload/xml" directory in <a class="Type" href="options.html#'runtimepath'">'runtimepath'</a>.<br>
Vim distribution provides examples of data files in the<br>
"$VIMRUNTIME/autoload/xml" directory. They have a meaningful name which will<br>
be used in commands. It should be a unique name which will not create<br>
conflicts. For example, the name xhtml10s.vim means it is the data file for<br>
XHTML 1.0 Strict.<br>
<br>
Each file contains a variable with a name like g:xmldata_xhtml10s . It is<br>
a compound from two parts:<br>
<br>
1. "g:xmldata_" general prefix, constant for all data files<br>
2. "xhtml10s" the name of the file and the name of the described XML<br>
dialect; it will be used as an argument for the <a class="Identifier" href="insert.html#:XMLns">:XMLns</a><br>
command<br>
<br>
Part two must be exactly the same as name of file.<br>
<br>
The variable is a <a class="Identifier" href="eval.html#Dictionary">Dictionary</a>. Keys are tag names and each value is a two<br>
element <a class="Identifier" href="eval.html#List">List</a>. The first element of the List is also a List with the names<br>
of possible children. The second element is a <a class="Identifier" href="eval.html#Dictionary">Dictionary</a> with the names of<br>
attributes as keys and the possible values of attributes as values. Example:<br>
<br>
<div class="helpExample"> let g:xmldata_crippled = {<br>
\ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"],<br>
\ 'vimxmlroot': ['tag1'],<br>
\ 'tag1':<br>
\ [ ['childoftag1a', 'childoftag1b'], {'attroftag1a': [],<br>
\ 'attroftag1b': ['valueofattr1', 'valueofattr2']}],<br>
\ 'childoftag1a':<br>
\ [ [], {'attrofchild': ['attrofchild']}],<br>
\ 'childoftag1b':<br>
\ [ ['childoftag1a'], {'attrofchild': []}],<br>
\ "vimxmltaginfo": {<br>
\ 'tag1': ['Menu info', 'Long information visible in preview window']},<br>
\ 'vimxmlattrinfo': {<br>
\ 'attrofchild': ['Menu info', 'Long information visible in preview window']}}</div>
<br>
This example would be put in the "autoload/xml/crippled.vim" file and could<br>
help to write this file:<br>
<br>
<div class="helpExample"> <tag1 attroftag1b="valueofattr1"><br>
<childoftag1a attrofchild><br>
&amp; &lt;<br>
</childoftag1a><br>
<childoftag1b attrofchild="5"><br>
<childoftag1a><br>
&gt; &apos; &quot;<br>
</childoftag1a><br>
</childoftag1b><br>
</tag1></div>
<br>
In the example four special elements are visible:<br>
<br>
1. "vimxmlentities" - a special key with List containing entities of this XML<br>
dialect.<br>
2. If the list containing possible values of attributes has one element and<br>
this element is equal to the name of the attribute this attribute will be<br>
treated as boolean and inserted as <span class="MissingTag">'attrname'</span> and not as 'attrname="'<br>
3. "vimxmltaginfo" - a special key with a Dictionary containing tag<br>
names as keys and two element List as values, for additional menu info and<br>
the long description.<br>
4. "vimxmlattrinfo" - special key with Dictionary containing attribute names<br>
as keys and two element List as values, for additional menu info and long<br>
description.<br>
<br>
<span class="Todo">Note</span>: Tag names in the data file MUST not contain a namespace description.<br>
Check xsl.vim for an example.<br>
<span class="Todo">Note</span>: All data and functions are publicly available as global<br>
variables/functions and can be used for personal editing functions.<br>
<br>
<br>
DTD -> Vim <a class="Constant" href="insert.html#dtd2vim" name="dtd2vim">dtd2vim</a><br>
<br>
On <a class="Identifier" href="intro.html#www">www</a> is the script <a class="Identifier" href="insert.html#dtd2vim">dtd2vim</a> which parses DTD and creates an XML data file<br>
for Vim XML omni completion.<br>
<br>
dtd2vim: <span class="Constant"><a href="http://www.vim.org/scripts/script.php?script_id=1462">http://www.vim.org/scripts/script.php?script_id=1462</a></span><br>
<br>
Check the beginning of that file for usage details.<br>
The script requires perl and:<br>
<br>
perlSGML: <span class="Constant"><a href="http://savannah.nongnu.org/projects/perlsgml">http://savannah.nongnu.org/projects/perlsgml</a></span><br>
<br>
<br>
Commands<br>
<br>
:XMLns <span class="Special">{name}</span> [<span class="Special">{namespace}</span>] <a class="Constant" href="insert.html#:XMLns" name=":XMLns">:XMLns</a><br>
<br>
Vim has to know which data file should be used and with which namespace. For<br>
loading of the data file and connecting data with the proper namespace use<br>
<a class="Identifier" href="insert.html#:XMLns">:XMLns</a> command. The first (obligatory) argument is the name of the data<br>
(xhtml10s, xsl). The second argument is the code of namespace (h, xsl). When<br>
used without a second argument the dialect will be used as default - without<br>
namespace declaration. For example to use XML completion in .xsl files:<br>
<br>
<div class="helpExample"> :XMLns xhtml10s<br>
:XMLns xsl xsl</div>
<br>
<br>
:XMLent <span class="Special">{name}</span> <a class="Constant" href="insert.html#:XMLent" name=":XMLent">:XMLent</a><br>
<br>
By default entities will be completed from the data file of the default<br>
namespace. The XMLent command should be used in case when there is no default<br>
namespace:<br>
<br>
<div class="helpExample"> :XMLent xhtml10s</div>
<br>
Usage<br>
<br>
While used in this situation (after declarations from previous part, | is<br>
cursor position):<br>
<br>
<div class="helpExample"> <|</div>
<br>
Will complete to an appropriate XHTML tag, and in this situation:<br>
<br>
<div class="helpExample"> <xsl:|</div>
<br>
Will complete to an appropriate XSL tag.<br>
<br>
<br>
The script xmlcomplete.vim, provided through the <a class="Identifier" href="eval.html#autoload">autoload</a> mechanism,<br>
has the xmlcomplete#GetLastOpenTag() function which can be used in XML files<br>
to get the name of the last open tag (b:unaryTagsStack has to be defined):<br>
<br>
<div class="helpExample"> :echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack")</div>
<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
8. Insert mode commands <a class="Constant" href="insert.html#inserting" name="inserting">inserting</a><br>
<br>
The following commands can be used to insert new text into the buffer. They<br>
can all be undone and repeated with the "." command.<br>
<br>
<a class="Constant" href="insert.html#a" name="a">a</a><br>
a Append text after the cursor <span class="Special">[count]</span> times. If the<br>
cursor is in the first column of an empty line Insert<br>
starts there. But not when <a class="Type" href="options.html#'virtualedit'">'virtualedit'</a> is set!<br>
<br>
<a class="Constant" href="insert.html#A" name="A">A</a><br>
A Append text at the end of the line <span class="Special">[count]</span> times.<br>
<br>
<span class="Special"><insert></span> or <a class="Constant" href="insert.html#i" name="i">i</a> <a class="Constant" href="insert.html#insert" name="insert">insert</a> <a class="Constant" href="insert.html#<Insert>" name="<Insert>"><Insert></a><br>
i Insert text before the cursor <span class="Special">[count]</span> times.<br>
When using <span class="Special">CTRL-O</span> in Insert mode <a class="Identifier" href="insert.html#i_CTRL-O">i_CTRL-O</a> the count<br>
is not supported.<br>
<br>
<a class="Constant" href="insert.html#I" name="I">I</a><br>
I Insert text before the first non-blank in the line<br>
<span class="Special">[count]</span> times.<br>
When the 'H' flag is present in <a class="Type" href="options.html#'cpoptions'">'cpoptions'</a> and the<br>
line only contains blanks, insert start just before<br>
the last blank.<br>
<br>
<a class="Constant" href="insert.html#gI" name="gI">gI</a><br>
gI Insert text in column 1 <span class="Special">[count]</span> times. <span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#gi" name="gi">gi</a><br>
gi Insert text in the same position as where Insert mode<br>
was stopped last time in the current buffer.<br>
This uses the <a class="Identifier" href="motion.html#'^">'^</a> mark. It's different from "`^i"<br>
when the mark is past the end of the line.<br>
The position is corrected for inserted/deleted lines,<br>
but NOT for inserted/deleted characters.<br>
When the <a class="Identifier" href="motion.html#:keepjumps">:keepjumps</a> command modifier is used the <a class="Identifier" href="motion.html#'^">'^</a><br>
mark won't be changed.<br>
<span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#o" name="o">o</a><br>
o Begin a new line below the cursor and insert text,<br>
repeat <span class="Special">[count]</span> times. <span class="Special">{Vi: blank [count] screen</span><br>
<span class="Special">lines}</span><br>
When the '#' flag is in <a class="Type" href="options.html#'cpoptions'">'cpoptions'</a> the count is<br>
ignored.<br>
<br>
<a class="Constant" href="insert.html#O" name="O">O</a><br>
O Begin a new line above the cursor and insert text,<br>
repeat <span class="Special">[count]</span> times. <span class="Special">{Vi: blank [count] screen</span><br>
<span class="Special">lines}</span><br>
When the '#' flag is in <a class="Type" href="options.html#'cpoptions'">'cpoptions'</a> the count is<br>
ignored.<br>
<br>
These commands are used to start inserting text. You can end insert mode with<br>
<span class="Special"><Esc></span>. See <a class="Identifier" href="insert.html#mode-ins-repl">mode-ins-repl</a> for the other special characters in Insert mode.<br>
The effect of <span class="Special">[count]</span> takes place after Insert mode is exited.<br>
<br>
When <a class="Type" href="options.html#'autoindent'">'autoindent'</a> is on, the indent for a new line is obtained from the<br>
previous line. When <a class="Type" href="options.html#'smartindent'">'smartindent'</a> or <a class="Type" href="options.html#'cindent'">'cindent'</a> is on, the indent for a line<br>
is automatically adjusted for C programs.<br>
<br>
<a class="Type" href="options.html#'textwidth'">'textwidth'</a> can be set to the maximum width for a line. When a line becomes<br>
too long when appending characters a line break is automatically inserted.<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
9. Ex insert commands <a class="Constant" href="insert.html#inserting-ex" name="inserting-ex">inserting-ex</a><br>
<br>
<a class="Constant" href="insert.html#:a" name=":a">:a</a> <a class="Constant" href="insert.html#:append" name=":append">:append</a><br>
:<span class="Special">{range}</span>a[ppend][!] Insert several lines of text below the specified<br>
line. If the <span class="Special">{range}</span> is missing, the text will be<br>
inserted after the current line.<br>
Adding [!] toggles <a class="Type" href="options.html#'autoindent'">'autoindent'</a> for the time this<br>
command is executed.<br>
<br>
<a class="Constant" href="insert.html#:i" name=":i">:i</a> <a class="Constant" href="insert.html#:in" name=":in">:in</a> <a class="Constant" href="insert.html#:insert" name=":insert">:insert</a><br>
:<span class="Special">{range}</span>i[nsert][!] Insert several lines of text above the specified<br>
line. If the <span class="Special">{range}</span> is missing, the text will be<br>
inserted before the current line.<br>
Adding [!] toggles <a class="Type" href="options.html#'autoindent'">'autoindent'</a> for the time this<br>
command is executed.<br>
<br>
These two commands will keep on asking for lines, until you type a line<br>
containing only a ".". Watch out for lines starting with a backslash, see<br>
<a class="Identifier" href="repeat.html#line-continuation">line-continuation</a>.<br>
<br>
When in Ex mode (see <a class="Identifier" href="starting.html#-e">-e</a>) a backslash at the end of the line can be used to<br>
insert a NUL character. To be able to have a line ending in a backslash use<br>
two backslashes. This means that the number of backslashes is halved, but<br>
only at the end of the line.<br>
<br>
<span class="Todo">NOTE</span>: These commands cannot be used with <a class="Identifier" href="repeat.html#:global">:global</a> or <a class="Identifier" href="repeat.html#:vglobal">:vglobal</a>.<br>
":append" and ":insert" don't work properly in between ":if" and<br>
":endif", ":for" and ":endfor", ":while" and ":endwhile".<br>
<br>
<a class="Constant" href="insert.html#:start" name=":start">:start</a> <a class="Constant" href="insert.html#:startinsert" name=":startinsert">:startinsert</a><br>
:star[tinsert][!] Start Insert mode just after executing this command.<br>
Works like typing "i" in Normal mode. When the ! is<br>
included it works like "A", append to the line.<br>
Otherwise insertion starts at the cursor position.<br>
<span class="Todo">Note</span> that when using this command in a function or<br>
script, the insertion only starts after the function<br>
or script is finished.<br>
This command does not work from <a class="Identifier" href="various.html#:normal">:normal</a>.<br>
<span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#:stopi" name=":stopi">:stopi</a> <a class="Constant" href="insert.html#:stopinsert" name=":stopinsert">:stopinsert</a><br>
:stopi[nsert] Stop Insert mode as soon as possible. Works like<br>
typing <span class="Special"><Esc></span> in Insert mode.<br>
Can be used in an autocommand, example:<br>
<div class="helpExample"> :au BufEnter scratch stopinsert</div>
<br>
<a class="Constant" href="insert.html#replacing-ex" name="replacing-ex">replacing-ex</a> <a class="Constant" href="insert.html#:startreplace" name=":startreplace">:startreplace</a><br>
:startr[eplace][!] Start Replace mode just after executing this command.<br>
Works just like typing "R" in Normal mode. When the<br>
! is included it acts just like "$R" had been typed<br>
(ie. begin replace mode at the end-of-line). Other-<br>
wise replacement begins at the cursor position.<br>
<span class="Todo">Note</span> that when using this command in a function or<br>
script that the replacement will only start after<br>
the function or script is finished.<br>
<span class="Special">{not in Vi}</span><br>
<br>
<a class="Constant" href="insert.html#:startgreplace" name=":startgreplace">:startgreplace</a><br>
:startg[replace][!] Just like <a class="Identifier" href="insert.html#:startreplace">:startreplace</a>, but use Virtual Replace<br>
mode, like with <a class="Identifier" href="change.html#gR">gR</a>.<br>
<span class="Special">{not in Vi}</span><br>
<br>
<span class="PreProc">==============================================================================</span><br>
10. Inserting a file <a class="Constant" href="insert.html#inserting-file" name="inserting-file">inserting-file</a><br>
<br>
<a class="Constant" href="insert.html#:r" name=":r">:r</a> <a class="Constant" href="insert.html#:re" name=":re">:re</a> <a class="Constant" href="insert.html#:read" name=":read">:read</a><br>
:r[ead] <span class="Special">[++opt]</span> <span class="Special">[name]</span><br>
Insert the file <span class="Special">[name]</span> (default: current file) below<br>
the cursor.<br>
See <a class="Identifier" href="editing.html#++opt">++opt</a> for the possible values of <span class="Special">[++opt]</span>.<br>
<br>
:<span class="Special">{range}</span>r[ead] <span class="Special">[++opt]</span> <span class="Special">[name]</span><br>
Insert the file <span class="Special">[name]</span> (default: current file) below<br>
the specified line.<br>
See <a class="Identifier" href="editing.html#++opt">++opt</a> for the possible values of <span class="Special">[++opt]</span>.<br>
<br>
<a class="Constant" href="insert.html#:r!" name=":r!">:r!</a> <a class="Constant" href="insert.html#:read!" name=":read!">:read!</a><br>
:<span class="Special">[range]</span>r[ead] <span class="Special">[++opt]</span> !<span class="Special">{cmd}</span><br>
Execute <span class="Special">{cmd}</span> and insert its standard output below<br>
the cursor or the specified line. A temporary file is<br>
used to store the output of the command which is then<br>
read into the buffer. <a class="Type" href="options.html#'shellredir'">'shellredir'</a> is used to save<br>
the output of the command, which can be set to include<br>
stderr or not. <span class="Special">{cmd}</span> is executed like with ":!<span class="Special">{cmd}</span>",<br>
any '!' is replaced with the previous command <a class="Identifier" href="various.html#:!">:!</a>.<br>
See <a class="Identifier" href="editing.html#++opt">++opt</a> for the possible values of <span class="Special">[++opt]</span>.<br>
<br>
These commands insert the contents of a file, or the output of a command,<br>
into the buffer. They can be undone. They cannot be repeated with the "."<br>
command. They work on a line basis, insertion starts below the line in which<br>
the cursor is, or below the specified line. To insert text above the first<br>
line use the command ":0r <span class="Special">{name}</span>".<br>
<br>
After the ":read" command, the cursor is left on the first non-blank in the<br>
first new line. Unless in Ex mode, then the cursor is left on the last new<br>
line (sorry, this is Vi compatible).<br>
<br>
If a file name is given with ":r", it becomes the alternate file. This can be<br>
used, for example, when you want to edit that file instead: ":e! #". This can<br>
be switched off by removing the 'a' flag from the <a class="Type" href="options.html#'cpoptions'">'cpoptions'</a> option.<br>
<br>
Of the <span class="Special">[++opt]</span> arguments one is specifically for ":read", the ++edit argument.<br>
This is useful when the ":read" command is actually used to read a file into<br>
the buffer as if editing that file. Use this command in an empty buffer:<br>
<div class="helpExample"> :read ++edit filename</div>
The effect is that the <a class="Type" href="options.html#'fileformat'">'fileformat'</a>, <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a>, <a class="Type" href="options.html#'bomb'">'bomb'</a>, etc. options are<br>
set to what has been detected for "filename". <span class="Todo">Note</span> that a single empty line<br>
remains, you may want to delete it.<br>
<br>
<a class="Constant" href="insert.html#file-read" name="file-read">file-read</a><br>
The <a class="Type" href="options.html#'fileformat'">'fileformat'</a> option sets the <span class="Special"><EOL></span> style for a file:<br>
<span class="PreProc">'fileformat' characters name </span><br>
"dos" <span class="Special"><CR><NL></span> or <span class="Special"><NL></span> DOS format<br>
"unix" <span class="Special"><NL></span> Unix format<br>
"mac" <span class="Special"><CR></span> Mac format<br>
Previously <a class="Type" href="options.html#'textmode'">'textmode'</a> was used. It is obsolete now.<br>
<br>
If <a class="Type" href="options.html#'fileformat'">'fileformat'</a> is "dos", a <span class="Special"><CR></span> in front of an <span class="Special"><NL></span> is ignored and a <span class="Special">CTRL-Z</span><br>
at the end of the file is ignored.<br>
<br>
If <a class="Type" href="options.html#'fileformat'">'fileformat'</a> is "mac", a <span class="Special"><NL></span> in the file is internally represented by a<br>
<span class="Special"><CR></span>. This is to avoid confusion with a <span class="Special"><NL></span> which is used to represent a<br>
<span class="Special"><NUL></span>. See <a class="Identifier" href="pattern.html#CR-used-for-NL">CR-used-for-NL</a>.<br>
<br>
If the <a class="Type" href="options.html#'fileformats'">'fileformats'</a> option is not empty Vim tries to recognize the type of<br>
<span class="Special"><EOL></span> (see <a class="Identifier" href="editing.html#file-formats">file-formats</a>). However, the <a class="Type" href="options.html#'fileformat'">'fileformat'</a> option will not be<br>
changed, the detected format is only used while reading the file.<br>
A similar thing happens with <a class="Type" href="options.html#'fileencodings'">'fileencodings'</a>.<br>
<br>
On non-MS-DOS, Win32, and OS/2 systems the message "[dos format]" is shown if<br>
a file is read in DOS format, to remind you that something unusual is done.<br>
On Macintosh, MS-DOS, Win32, and OS/2 the message "[unix format]" is shown if<br>
a file is read in Unix format.<br>
On non-Macintosh systems, the message "[Mac format]" is shown if a file is<br>
read in Mac format.<br>
<br>
An example on how to use ":r !":<br>
<div class="helpExample"> :r !uuencode binfile binfile</div>
This command reads "binfile", uuencodes it and reads it into the current<br>
buffer. Useful when you are editing e-mail and want to include a binary<br>
file.<br>
<br>
<a class="Constant" href="insert.html#read-messages" name="read-messages">read-messages</a><br>
When reading a file Vim will display a message with information about the read<br>
file. In the table is an explanation for some of the items. The others are<br>
self explanatory. Using the long or the short version depends on the<br>
<a class="Type" href="options.html#'shortmess'">'shortmess'</a> option.<br>
<br>
<span class="PreProc">long short meaning</span><br>
<span class="Special">[readonly]</span> <span class="Special">{RO}</span> the file is write protected<br>
[fifo/socket] using a stream<br>
<span class="Special">[fifo]</span> using a fifo stream<br>
<span class="Special">[socket]</span> using a socket stream<br>
[CR missing] reading with "dos" <a class="Type" href="options.html#'fileformat'">'fileformat'</a> and a<br>
NL without a preceding CR was found.<br>
[NL found] reading with "mac" <a class="Type" href="options.html#'fileformat'">'fileformat'</a> and a<br>
NL was found (could be "unix" format)<br>
[long lines split] at least one line was split in two<br>
[NOT converted] conversion from <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a> to<br>
<a class="Type" href="options.html#'encoding'">'encoding'</a> was desired but not<br>
possible<br>
<span class="Special">[converted]</span> conversion from <a class="Type" href="options.html#'fileencoding'">'fileencoding'</a> to<br>
<a class="Type" href="options.html#'encoding'">'encoding'</a> done<br>
<span class="Special">[crypted]</span> file was decrypted<br>
[READ ERRORS] not all of the file could be read<br>
<br>
<br>
vim:tw=78:ts=8:ft=help:norl:<br>
</div>
</article>
<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>
<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->
</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。