Vim Tips Wiki
 
(7 intermediate revisions by 7 users not shown)
Line 14: Line 14:
   
 
==Overview==
 
==Overview==
To turn on omnicompletion in the .vimrc file add the following lines:
+
Omni completion is not usually enabled by default. To turn on omni completion, add the following to your [[vimrc]]:
  +
<pre>
filetype plugin on
+
filetype plugin on
 
set ofu=syntaxcomplete#Complete
+
set omnifunc=syntaxcomplete#Complete
  +
</pre>
Various languages are supported in Vim7, including C. Omni completion scripts can be written to support other languages, and to customize behavior. {{help|new-omni-completion}} {{help|compl-omni}}
 
   
  +
Various programming languages are supported in Vim 7. For many languages such as SQL, HTML, CSS, JavaScript and PHP, omni completion will work out of the box. Other languages such as C and PHP will also take advantage of a tags file - if one exists. Omni completion using a tags file will complete the names of defined constants, functions, classes and other names from included and other external files. Omni completion scripts can be written to support other languages, and to customize behavior. {{help|new-omni-completion}} {{help|compl-omni}}
Windows users need to install a recent version of [http://ctags.sourceforge.net/ Exuberant Ctags] (Ctags 5.7, released September 2007, is recommended). {{help|ft-c-omni}}
 
   
 
When generating a tags file, [http://ctags.sourceforge.net/ Exuberant Ctags] should be used. Windows users need to install a recent version of [http://ctags.sourceforge.net/ Exuberant Ctags] (Ctags 5.7, released September 2007, or newer, is recommended). {{help|ft-c-omni}}
See [[VimTip1608|C++ code completion]] for omni completion in C++ programs.
 
   
  +
==Using omni completion==
  +
To use omni completion, type <code>&lt;C-X&gt;&lt;C-O&gt;</code> while open in Insert mode.
  +
If matching names are found, a pop-up menu opens which can be navigated using the <code>&lt;C-N&gt;</code> and <code>&lt;C-P&gt;</code> keys.
   
 
==Related tips==
 
==Related tips==
Line 40: Line 43:
 
'''Random thoughts on IDE'''
 
'''Random thoughts on IDE'''
 
*[[VimTip1439|1439 Using vim as an IDE all in one]]
 
*[[VimTip1439|1439 Using vim as an IDE all in one]]
  +
  +
'''Usage with C++'''
 
* See [[VimTip1608|C++ code completion]] for omni completion in C++ programs.
   
 
'''Usage with Python'''
 
'''Usage with Python'''

Latest revision as of 07:00, 15 June 2013

Tip 1591 Printable Monobook Previous Next

created February 16, 2008 · complexity basic · author Metacosm · version 7.0


Omni completion provides smart autocompletion for programs. When invoked, the text before the cursor is inspected to guess what might follow. A popup menu offers word completion choices that may include struct and class members, system functions, and more. A similar feature in Microsoft Visual Studio is known as IntelliSense.

Overview[]

Omni completion is not usually enabled by default. To turn on omni completion, add the following to your vimrc:

filetype plugin on
set omnifunc=syntaxcomplete#Complete

Various programming languages are supported in Vim 7. For many languages such as SQL, HTML, CSS, JavaScript and PHP, omni completion will work out of the box. Other languages such as C and PHP will also take advantage of a tags file - if one exists. Omni completion using a tags file will complete the names of defined constants, functions, classes and other names from included and other external files. Omni completion scripts can be written to support other languages, and to customize behavior. :help new-omni-completion :help compl-omni

When generating a tags file, Exuberant Ctags should be used. Windows users need to install a recent version of Exuberant Ctags (Ctags 5.7, released September 2007, or newer, is recommended). :help ft-c-omni

Using omni completion[]

To use omni completion, type <C-X><C-O> while open in Insert mode. If matching names are found, a pop-up menu opens which can be navigated using the <C-N> and <C-P> keys.

Related tips[]

 TO DO 

  • This is to be an overview of omnicompletion, with links to more detailed tips as required.
  • Need to make sense of related tips, and probably merge a few.
  • Meanwhile, keep the following list as a useful reference for readers and editors.

Popup menu and mappings

Random thoughts on IDE

Usage with C++

Usage with Python

Insenvim

Comments[]