Vim Tips Wiki
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 11: Line 11:
 
|category2=
 
|category2=
 
}}
 
}}
In addition to [[VimTip4|any word completion]] you can use Ctrl-X completion mode to complete whole lines, filenames, keywords, and more. While entering text in insert mode, press Ctrl-X (written as <C-X> below), then another key to indicate the type of completion.
+
In addition to [[VimTip4|any word completion]] you can use whole <C-x> completion mode. It can complete whole lines (<C-X><C-L>, then <C-P>, <C-N>), filenames (<C-X><C-F>), keywords, words from custom dictionary and many, many others. This mode has many other powerful features, for example when completing word (by <C-X><C-P> or just by <C-P>) you can continue completion with another <C-X><C-P>. For example, after writing such text:
 
*<C-X><C-L> complete whole lines
 
*<C-X><C-P> complete words (<C-P> has the same effect; <C-X> is not needed)
 
*<C-X><C-F> complete file names
 
*<C-X><code>s</code> spelling suggestions (after <code>:setl spell</code> to enable spell checking)
 
 
While completion is active, type <C-P> or <C-N> to select the previous or next item.
 
 
For more information, see {{help|ins-completion}}.
 
 
==Example==
 
For example, suppose the following text is entered:
 
 
<pre>
 
<pre>
 
this is first line
 
this is first line
Line 29: Line 17:
 
</pre>
 
</pre>
   
  +
Placing cursor at third line and pressing <C-X><C-L> will double last line - <C-N>, <C-P> in this moment can be used to manipulate completed line. Or, instead of completing whole line you can press 'f' and then complete by <C-P> which will result in the word, "first". After that you can <C-X><C-P> to get "line" word (since this is next word after "first"). Try yourself for other powerful combinations.
With the cursor on the empty third line, and while still in insert mode, pressing <C-X><C-L> will insert a copy of the second line. Select another line with <C-P> or <C-N>.
 
 
If "th" is typed at the start of the third line, pressing <C-X><C-L> will insert the first line because it starts with "th".
 
   
  +
For more help about completion, type
As an example of word completion, suppose "f" is typed at the start of the third line. Press <C-P> to complete the word using the previous occurrence that starts with "f"—that will insert "first". If you then press <C-X><C-P> the following word will also be inserted (the result will be "first line").
 
   
  +
<pre><nowiki>:</nowiki>help ins-completion</pre>
 
==Comments==
 
==Comments==
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)