Fandom

Vim Tips Wiki

Line/word/file/whatever completion

Redirected from VimTip295

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 295 Printable Monobook Previous Next

created 2002 · complexity intermediate · author Nopik · version 6.0


In addition to 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.

  • <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>s spelling suggestions (after :setl spell 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.

ExampleEdit

For example, suppose the following text is entered:

this is first line
second line is here

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".

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").

CommentsEdit

Also on Fandom

Random Wiki