blob: b11e00600222259b8fdb60d2a148d5dabc8615ba [file] [log] [blame]
chatsiri rattana27c065c2012-02-12 14:23:32 +07001*omnicppcomplete.txt* Plugin for C/C++ omnicompletion
2*omnicppcomplete*
3
4Author: Vissale NEANG (fromtonrouge AT gmail DOT com)
5Last Change: 26 sept. 2007
6
7OmniCppComplete version 0.41
8
9For Vim version 7.0 and above
10
11==============================================================================
12
131. Overview |omnicpp-overview|
142. Downloads |omnicpp-download|
153. Installation |omnicpp-installation|
164. Options |omnicpp-options|
175. Features |omnicpp-features|
186. Limitations |omnicpp-limitations|
197. FAQ & TIPS |omnicpp-faq|
208. History |omnicpp-history|
219. Thanks |omnicpp-thanks|
22
23==============================================================================
241. Overview~
25 *omnicpp-overview*
26The purpose of this script is to provide an 'omnifunc' function for C and C++
27language. In a C++ file, while in insert mode, you can use CTRL-X CTRL-O to:
28
29 * Complete namespaces, classes, structs and unions
30 * Complete attribute members and return type of functions
31 * Complete the "this" pointer
32 * Complete an object after a cast (C and C++ cast)
33 * Complete typedefs and anonymous types
34
35You can set a "may complete" behaviour to start a completion automatically
36after a '.', '->' or '::'. Please see |omnicpp-may-complete| for more details.
37
38The script needs an |Exuberant_ctags| database to work properly.
39
40==============================================================================
412. Downloads~
42 *omnicpp-download*
43You can download the latest release of the script from this url :
44
45 http://www.vim.org/scripts/script.php?script_id=1520
46
47You can download |Exuberant_ctags| from :
48
49 http://ctags.sourceforge.net
50
51==============================================================================
523. Installation~
53 *omnicpp-installation*
543.1. Script installation~
55
56Unzip the downloaded file in your personal |vimfiles| directory (~/.vim under
57unix or %HOMEPATH%\vimfiles under windows). The 'omnifunc' will be
58automatically set for C and C++ files.
59
60You also have to enable plugins by adding these two lines in your|.vimrc|file: >
61
62 set nocp
63 filetype plugin on
64<
65Please see |cp| and |filetype-plugin-on| sections for more details.
66
673.1.1. Files~
68
69After installation you should find these files :
70
71 after\ftplugin\cpp.vim
72 after\ftplugin\c.vim
73
74 autoload\omni\common\debug.vim
75 \utils.vim
76
77 autoload\omni\cpp\complete.vim
78 \includes.vim
79 \items.vim
80 \maycomplete.vim
81 \namespaces.vim
82 \settings.vim
83 \tokenizer.vim
84 \utils.vim
85
86 doc\omnicppcomplete.txt
87
883.2. Building the Exuberant Ctags database~
89
90To extract C/C++ symbols information, the script needs an |Exuberant_ctags|
91database.
92
93You have to build your database with at least the following options:
94 --c++-kinds=+p : Adds prototypes in the database for C/C++ files.
95 --fields=+iaS : Adds inheritance (i), access (a) and function
96 signatures (S) information.
97 --extra=+q : Adds context to the tag name. Note: Without this
98 option, the script cannot get class members.
99
100Thus to build recursively a ctags database from the current directory, the
101command looks like this:
102>
103 ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
104<
105You can add a map in your |.vimrc| file, eg: >
106
107 map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
108<
109Or you can add these options in your ctags config file (~/.ctags under unix or
110%HOMEPATH%\ctags.cnf under windows) and execute the command : >
111
112 :!ctags -R .
113<
114If your project contains files of other languages you may add the following
115options:
116 --languages=c++ : Builds only the tags for C++ files.
117
118If your project contains macros you may also use the -I option.
119
120Please read the ctags help or ctags man page for more details.
121
1223.3. Setting the 'tags' option~
123
124The default value of the option 'tags' is "./tags,tags" ("./tags,./TAGS,tags,TAGS"
125when |+emacs_tags| is enabled), if you build your tag database with the cmd above,
126you normally don't have to change this setting (The cmd used above generates a
127file with the name "tags"). In this case your current working directory must be
128the directory where the tags file reside.
129
130Note: When |+emacs_tags| is enabled, the script may display members twice, it's
131 recommended to set tags to "./tags,tags' or "./TAGS,TAGS".
132
133If your tags file is not named "tags" you have to add it in the 'tags'
134option eg: >
135
136 set tags+=/usr/tagsdir/mytagfile
137<
138You can ensure that the 'tags' option is set properly by executing the following
139command: >
140
141 :tselect MyClass
142<
143Where MyClass is a class of your project. This command should display all
144possible tags for the type MyClass.
145
1463.4. Simple test~
147
148Now you can do a simple test. Edit a C++ file and write the simplest case : >
149
150 MyClass myObject;
151 myObject.<C-X><C-O>
152<
153You should see class members of MyClass.
154
155==============================================================================
1564. Options~
157 *omnicpp-options*
158
159You can change completion behaviour by setting script options in your |.vimrc|
160configuration file.
161
1624.1. Global scope search toggle~
163 *OmniCpp_GlobalScopeSearch*
164
165You can enable/disable the global scope search by setting the
166OmniCpp_GlobalScopeSearch option.
167
168Possible values are :
169 0 = disabled
170 1 = enabled
171 [default=1] >
172
173 let OmniCpp_GlobalScopeSearch = 1
174<
1754.2. Namespace search method~
176 *OmniCpp_NamespaceSearch*
177
178You can change the 'using namespace' search behaviour by setting the
179OmniCpp_NamespaceSearch option.
180
181Possible values are :
182 0 = namespaces disabled
183 1 = search namespaces in the current buffer
184 2 = search namespaces in the current buffer and in included files
185 [default=1] >
186
187 let OmniCpp_NamespaceSearch = 1
188<
189When OmniCpp_NamespaceSearch is 2, "using namespace" declarations are parsed
190in the current buffer and also in included files. To find included files, the
191script use the vim env 'path', so you have to set it properly.
192
193Note: included files are searched with lvimgrep, thus the location list of the
194current window is changed.
195
196Note: When the 'filetype' is "c", namespace search is always disabled even if
197OmniCpp_NamespaceSearch != 0
198
1994.3. Class scope completion mode~
200 *OmniCpp_DisplayMode*
201
202When you are completing a class scope (eg: MyClass::<C-X><C-O>), depending on
203the current scope, you may see sometimes static, public, protected or private
204members and sometimes you may see all members. By default the choice is done
205automatically by the script but you can override it with the
206OmniCpp_DisplayMode option.
207
208Note: This option can be use when you have friend classes in your project (the
209script does not support friend classes).
210
211Possible values are :
212 0 = auto
213 1 = always show all members
214 [default=0] >
215
216 let OmniCpp_DisplayMode = 0
217<
2184.4. Show scope in abbreviation~
219 *OmniCpp_ShowScopeInAbbr*
220
221By default, in the |omnicpp-popup| menu, you will see the scope of a match in
222the last column. You can remove this column and add the scope at the beginning
223of match abbreviation.
224eg:
225
226OmniCpp_ShowScopeInAbbr = 0
227 +-------------------------------------+
228 |method1( f + MyNamespace::MyClass|
229 |_member1 m + MyNamespace::MyClass|
230 |_member2 m # MyNamespace::MyClass|
231 |_member3 m - MyNamespace::MyClass|
232 +-------------------------------------+
233
234OmniCpp_ShowScopeInAbbr = 1
235 +-------------------------------------+
236 |MyNamespace::MyClass::method1( f + |
237 |MyNamespace::MyClass::_member1 m + |
238 |MyNamespace::MyClass::_member2 m # |
239 |MyNamespace::MyClass::_member3 m - |
240 +-------------------------------------+
241
242Possible values are :
243 0 = don't show scope in abbreviation
244 1 = show scope in abbreviation and remove the last column
245 [default=0] >
246
247 let OmniCpp_ShowScopeInAbbr = 0
248<
2494.5. Show prototype in abbreviation~
250 *OmniCpp_ShowPrototypeInAbbr*
251
252This option allows to display the prototype of a function in the abbreviation
253part of the popup menu.
254
255Possible values are:
256 0 = don't display prototype in abbreviation
257 1 = display prototype in abbreviation
258 [default=0] >
259
260 let OmniCpp_ShowPrototypeInAbbr = 0
261<
2624.6. Show access~
263 *OmniCpp_ShowAccess*
264
265This option allows to show/hide the access information ('+', '#', '-') in the
266popup menu.
267
268Possible values are:
269 0 = hide access
270 1 = show access
271 [default=1] >
272
273 let OmniCpp_ShowAccess = 1
274
2754.7. Default using namespace list~
276 *OmniCpp_DefaultNamespaces*
277
278When |OmniCpp_NamespaceSearch| is not 0, the script will parse using namespace
279declarations in the current buffer and maybe in included files.
280You can specify manually a default namespace list if you want with the
281OmniCpp_DefaultNamespaces option. Each item in the list is a namespace name.
282eg: If you have
283
284 let OmniCpp_DefaultNamespaces = ["std", "MyNamespace"]
285
286 It will be the same as inserting this declarations at the top of the
287 current buffer :
288
289 using namespace std;
290 using namespace MyNamespace;
291
292This option can be use if you don't want to parse using namespace declarations
293in included files and want to add namespaces that are always used in your
294project.
295
296Possible values are :
297 List of String
298 [default=[]] >
299
300 let OmniCpp_DefaultNamespaces = []
301<
3024.8. May complete behaviour~
303 *omnicpp-may-complete*
304
305This feature allows you to run automatically a completion after a '.', '->'
306or '::'. By default, the "may complete" feature is set automatically for '.'
307and '->'. The reason to not set this feature for the scope operator '::' is
308sometimes you don't want to complete a namespace that contains many members.
309
310To enable/disable the "may complete" behaviour for dot, arrow and scope
311operator, you can change the option OmniCpp_MayCompleteDot,
312OmniCpp_MayCompleteArrow and OmniCpp_MayCompleteScope respectively.
313
314 *OmniCpp_MayCompleteDot*
315Possible values are :
316 0 = May complete disabled for dot
317 1 = May complete enabled for dot
318 [default=1] >
319
320 let OmniCpp_MayCompleteDot = 1
321<
322 *OmniCpp_MayCompleteArrow*
323Possible values are :
324 0 = May complete disabled for arrow
325 1 = May complete enabled for arrow
326 [default=1] >
327
328 let OmniCpp_MayCompleteArrow = 1
329<
330 *OmniCpp_MayCompleteScope*
331Possible values are :
332 0 = May complete disabled for scope
333 1 = May complete enabled for scope
334 [default=0] >
335
336 let OmniCpp_MayCompleteScope = 0
337<
338
339Note: You can obviously continue to use <C-X><C-O>
340
3414.9. Select/Don't select first popup item~
342 *OmniCpp_SelectFirstItem*
343
344Note: This option is only used when 'completeopt' does not contain "longest".
345
346When 'completeopt' does not contain "longest", Vim automatically select the
347first entry of the popup menu. You can change this behaviour with the
348OmniCpp_SelectFirstItem option.
349
350Possible values are:
351 0 = don't select first popup item
352 1 = select first popup item (inserting it to the text)
353 2 = select first popup item (without inserting it to the text)
354 [default=0] >
355
356 let OmniCpp_SelectFirstItem = 0
357
3584.10 Use local search function for variable definitions~
359 *OmniCpp_LocalSearchDecl*
360
361The internal search function for variable definitions of vim requires that the
362enclosing braces of the function are located in the first column. You can
363change this behaviour with the OmniCpp_LocalSearchDecl option. The local
364version works irrespective the position of braces.
365
366Possible values are:
367 0 = use standard vim search function
368 1 = use local search function
369 [default=0] >
370
371==============================================================================
3725. Features~
373 *omnicpp-features*
3745.1. Popup menu~
375 *omnicpp-popup*
376Popup menu format:
377 +-------------------------------------+
378 |method1( f + MyNamespace::MyClass|
379 |_member1 m + MyNamespace::MyClass|
380 |_member2 m # MyNamespace::MyClass|
381 |_member3 m - MyNamespace::MyClass|
382 +-------------------------------------+
383 ^ ^ ^ ^
384 (1) (2)(3) (4)
385
386(1) name of the symbol, when a match ends with '(' it's a function.
387
388(2) kind of the symbol, possible kinds are :
389 * c = classes
390 * d = macro definitions
391 * e = enumerators (values inside an enumeration)
392 * f = function definitions
393 * g = enumeration names
394 * m = class, struct, and union members
395 * n = namespaces
396 * p = function prototypes
397 * s = structure names
398 * t = typedefs
399 * u = union names
400 * v = variable definitions
401
402(3) access, possible values are :
403 * + = public
404 * # = protected
405 * - = private
406Note: enumerators have no access information
407
408(4) scope where the symbol is defined.
409Note: If the scope is empty it's a global symbol
410Note: anonymous scope may end with __anon[number]
411eg: If you have an anonymous enum in MyNamespace::MyClass : >
412
413 namespace MyNamespace
414 {
415 class MyClass
416 {
417 private:
418
419 enum
420 {
421 E_ENUM0,
422 E_ENUM1,
423 E_ENUM2
424 };
425 };
426 }
427<
428
429You should see :
430
431 +----------------------------------------------+
432 |E_ENUM0 e MyNamespace::MyClass::__anon1|
433 |E_ENUM1 e MyNamespace::MyClass::__anon1|
434 |E_ENUM2 e MyNamespace::MyClass::__anon1|
435 +----------------------------------------------+
436 ^
437 __anon[number]
438
4395.2. Global scope completion~
440
441The global scope completion allows you to complete global symbols for the base
442you are currently typing. The base can start with '::' or not.
443Note: Global scope completion only works with a non empty base, if you run a
444completion just after a '::' the completion will fail. The reason is that if
445there is no base to complete the script will try to display all the tags in
446the database. For small project it could be not a problem but for others you
447may wait 5 minutes or more for a result.
448
449eg1 : >
450
451 pthread_cr<C-X><C-O> => pthread_create
452<
453Where pthread_create is a global function.
454eg2: >
455 ::globa<C-X><C-O> => ::global_func(
456 +----------------+
457 |global_func( f|
458 |global_var1 v|
459 |global_var2 v|
460 +----------------+
461<
462Where global_var1, global_var2 and global_func are global symbols
463eg3: >
464 ::<C-X><C-O> => [NO MATCH]
465<
466No match because a global completion from an empty base is not allowed.
467
4685.3. Namespace scope completion~
469
470You can complete namespace members after a 'MyNamespace::'. Contrary to global
471scope completion you can run a completion from an empty base.
472Possible members are:
473 * Namespaces
474 * Classes
475 * Structs
476 * Unions
477 * Enums
478 * Functions
479 * Variables
480 * Typedefs
481
482eg: >
483 MyNamespace::<C-X><C-O>
484 +--------------------------------+
485 |E_ENUM0 e MyNamespace|
486 |E_ENUM1 e MyNamespace|
487 |E_ENUM2 e MyNamespace|
488 |MyClass c MyNamespace|
489 |MyEnum g MyNamespace|
490 |MyStruct s MyNamespace|
491 |MyUnion u MyNamespace|
492 |SubNamespace n MyNamespace|
493 |doSomething( f MyNamespace|
494 |myVar v MyNamespace|
495 |something_t t MyNamespace|
496 +--------------------------------+
497
4985.4. Class scope completion~
499
500You can complete class members after a 'MyClass::'. Contrary to global scope
501completion you can run a completion from an empty base.
502By default, there is two behaviours for class scope completion.
503
504 a) Completion of a base class of the current class scope
505
506 When you are completing a base class of the current class scope, you
507 will see all members of this class in the popup menu.
508 eg: >
509
510 class A
511 {
512 public:
513 enum
514 {
515 E_ENUM0,
516 E_ENUM1,
517 E_ENUM2,
518 };
519
520 void func1();
521 static int _staticMember;
522
523 private:
524 int _member;
525 };
526
527 class B : public A
528 {
529 public:
530 void doSomething();
531 };
532
533
534 void MyClassB::doSomething()
535 {
536 MyClassA::<C-X><C-O>
537 +---------------------------+
538 |E_ENUM0 e MyClassA|
539 |E_ENUM1 e MyClassA|
540 |E_ENUM2 e MyClassA|
541 |func1( f + MyClassA|
542 |_member m - MyClassA|
543 |_staticMember m + MyClassA|
544 +---------------------------+
545 }
546<
547
548 b) Completion of a non base class of the current class scope
549
550 When you are completing a class that is not a base class of the
551 current class you will see only enumerators and static members.
552 eg: >
553
554 class C
555 {
556 public:
557 void doSomething();
558 };
559
560 void MyClassC::doSomething()
561 {
562 MyClassA::<C-X><C-O>
563 +---------------------------+
564 |E_ENUM0 e MyClassA|
565 |E_ENUM1 e MyClassA|
566 |E_ENUM2 e MyClassA|
567 |_staticMember m + MyClassA|
568 +---------------------------+
569 }
570<
571You can override the default behaviour by setting the
572|OmniCpp_DisplayMode| option.
573
5745.5. Current scope completion~
575
576When you start a completion from an empty instruction you are in "Current
577scope completion" mode. You will see possible members of each context in
578the context stack.
579eg: >
580 void MyClass::doSomething()
581 {
582 using namespace MyNamespace;
583 using namespace SubNamespace;
584
585 // You will see members of each context in the context stack
586 // 1) MyClass members
587 // 2) MyNamespace::SubNamespace members
588 // 3) MyNamespace members
589
590 <C-X><C-O>
591 +------------------------------------------+
592 |_member1 m + MyClass |
593 |_member2 m # MyClass |
594 |func1( f MyNamespace::SubNamespace|
595 |var v MyNamespace::SubNamespace|
596 |func1( f MyNamespace |
597 |var v MyNamespace |
598 +------------------------------------------+
599 }
600<
601
6025.6. Class, Struct and Union members completion~
603
604You can complete members of class, struct and union instances after a '->' or
605'.'.
606eg: >
607 MyClass myObject;
608 myObject.<C-X><C-O>
609 +-----------------------+
610 |_member1 m + MyClass |
611 |_member2 m # MyClass |
612 +-----------------------+
613<
614
6155.7. Attribute members and returned type completion~
616
617You can complete a class member or a return type of a function.
618eg: >
619 MyClass myObject;
620
621 // Completion of the member _member1
622 myObject._member1-><C-X><C-O>
623 +------------------------+
624 |get( m + AnotherClass1|
625 +------------------------+
626
627 // Completion of the return type of the function get()
628 myObject._member1->get()-><C-X><C-O>
629 +--------------------------+
630 |_member1 m + AnotherClass2|
631 |_member2 m # AnotherClass2|
632 |_member3 m - AnotherClass2|
633 +--------------------------+
634
6355.8. Anonymous type completion~
636
637Note: To use this feature you need at least|Exuberant_ctags| version 5.6
638
639You can complete an anonymous type like this : >
640 struct
641 {
642 int a;
643 int b;
644 int c;
645 }globalVar;
646
647 void func()
648 {
649 globalVar.<C-X><C-O>
650 +---------------+
651 |a m + __anon1|
652 |b m + __anon1|
653 |c m + __anon1|
654 +---------------+
655 }
656<
657Where globalVar is a global variable of an anonymous type
658
6595.9. Typedef completion~
660
661You can complete a typedef. The typedef is resolved recursively, thus typedef
662of typedef of... may not be a problem.
663
664You can also complete a typedef of an anonymous type, eg : >
665 typedef struct
666 {
667 int a;
668 int b;
669 int c;
670 }something_t;
671
672 something_t globalVar;
673
674 void func()
675 {
676 globalVar.<C-X><C-O>
677 +---------------+
678 |a m + __anon1|
679 |b m + __anon1|
680 |c m + __anon1|
681 +---------------+
682 }
683<
684Where globalVar is a global variable of typedef of an anonymous type.
685
6865.10. Completion of the "this" pointer~
687
688You can complete the "this" pointer.
689eg: >
690 this-><C-X><C-O>
691 +-----------------------+
692 |_member1 m + MyClass |
693 |_member2 m # MyClass |
694 +-----------------------+
695
696 (*this).<C-X><C-O>
697 +-----------------------+
698 |_member1 m + MyClass |
699 |_member2 m # MyClass |
700 +-----------------------+
701<
702
7035.11. Completion after a cast~
704
705You can complete an object after a C or C++ cast.
706eg: >
707 // C cast style
708 ((AnotherStruct*)pStruct)-><C-X><C-O>
709
710 // C++ cast style
711 static_cast<AnotherStruct*>(pStruct)-><C-X><C-O>
712<
713
7145.12. Preview window~
715
716If the 'completeopt' option contains the setting "preview" (this is the
717default value), you will see a preview window during the completion.
718This window shows useful information like function signature, filename where
719the symbol is define etc...
720
721The preview window contains tag information, the list below is non exhaustive.
722
723 * name : name of the tag
724 * cmd : regexp or line number that helps to find the tag
725 * signature : signature for prototypes and functions
726 * kind : kind of the tag (eg: namespace, class etc...)
727 * access : access information (eg: public, protected, private)
728 * inherits : list of base classes
729 * filename : filename where the tag is define
730
7315.13. Code tokenization~
732
733When you start a completion, the current instruction is tokenized ignoring
734spaces, tabs, carriage returns and comments. Thus you can complete a symbol
735even if the current instruction is on multiple lines, has comments between
736words etc... :
737eg: this case is unrealistic but it's just for illustration >
738
739 myObject [ 0 ]/* Why is there a comment here ?*/
740 ->_member
741 -> <C-X><C-O>
742<
743
744==============================================================================
7456. Limitations~
746 *omnicpp-limitations*
747Some C++ features are not supported by the script, some implemented features
748may not work properly in some conditions. They are multiple reasons like a
749lack of information in the database, performance issues and so on...
750
7516.1. Attribute members and returned type completion~
752
753To work properly, the completion of attribute members and returned type of
754functions depends on how you write your code in the class declaration.
755Because the tags database does not contain information like return type or
756type of a member, the script use the cmd information of the tag to determine
757the type of an attribute member or the return type of a function.
758
759Thus, because the cmd is a regular expression (or line number for #define) if
760you write your code like this : >
761
762 class MyClass
763 {
764 public:
765
766 MyOtherClass
767 _member;
768 };
769<
770The type of _member will not be recognized, because the cmd will be
771/^ _member;$/ and does not contain the type MyOtherClass.
772The correct case should be : >
773
774 class MyClass
775 {
776 public:
777
778 MyOtherClass _member;
779 };
780<
781It's the same problem for return type of function : >
782
783 class MyClass
784 {
785 public:
786
787 MyOtherClass
788 getOtherClass();
789 };
790<
791Here the cmd will be /^ getOtherClass();$/ and the script won't find the
792return type.
793The correct case should be : >
794 class MyClass
795 {
796 public:
797
798 MyOtherClass getOtherClass();
799 };
800<
801
8026.2. Static members~
803
804It's the same problem as above, tags database does not contain information
805about static members. The only fast way to get this information is to use the
806cmd.
807
8086.3. Typedef~
809
810It's the same problem as above, tags database does not contain information
811about the type of a typedef. The script use the cmd information to resolve the
812typedef.
813
8146.4. Restricted inheritance access~
815
816Tags database contains inheritance information but unfortunately inheritance
817access are not available. We could use the cmd but we often find code
818indentation like this : >
819
820 class A :
821 public B,
822 protected C,
823 private D
824 {
825 };
826<
827Here the cmd will be /^class A :$/, we can't extract inheritance access.
828
8296.5. Using namespace parsing~
830
831When you start a completion, using namespace declarations are parsed from the
832cursor position to the first scope to detect local using namespace
833declarations. After that, global using namespace declarations are parsed in the
834file and included files.
835
836There is a limitation for global using namespace detection, for performance
837issues only using namespace that starts a line will be detected.
838
8396.6. Friend classes~
840
841Tags database does not contain information about friend classes. The script
842does not support friend classes.
843
8446.7. Templates~
845
846At the moment, |Exuberant_ctags| does not provide additional information for
847templates. That's why the script does not handle templates.
848
849==============================================================================
8507. FAQ & TIPS~
851 *omnicpp-faq*
852
853* How to complete STL objects ?
854 If you have some troubles to generate a good ctags database for STL you
855 can try this solution :
856
857 1) Download SGI's STL from SGI's site
858 (http://www.sgi.com/tech/stl/download.html)
859 2) Replace all __STL_BEGIN_NAMESPACE by "namespace std {" and
860 __STL_END_NAMESPACE by "}" from header and source files. (with Vim,
861 or with tar and sed or another tool)
862 3) Run ctags and put the generated tags file in a directory eg:
863 ~/MyTags/stl.tags
864 4) set tags+=~/MyTags/stl.tags
865
866 The main problem is that you can't tell to ctags that
867 __STL_BEGIN_NAMESPACE = "namespace std {" even with the option -I.
868 That's why you need the step 2).
869
870 Here is another solution if you have STL sources using _GLIBCXX_STD macro
871 (Tip by Nicola Bonelli) : >
872
873 let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
874<
875* How to close automatically the preview window after a completion ?
876 (Tip by Kamil Renczewski)
877
878 You can add to your |vimrc| the following lines : >
879
880 autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
881 autocmd InsertLeave * if pumvisible() == 0|pclose|endif
882<
883==============================================================================
8848. History~
885 *omnicpp-history*
886Version O.41
887 - It's recommended to update ctags to version 5.7 or higher
888 - The plugin is now activated for C files
889 - New value for OmniCpp_SelectFirstItem when the option is equal to
890 2 the first item is selected without inserting it to
891 the text (patch from Marek Olszewski)
892 - Bug when completing union members fixed with ctags 5.7
893 (reported by Willem-Jan de Hoog)
894 - New option OmniCpp_LocalSearchDecl (patch from Roland Kuck)
895 - Bug when tags=something,,somethingelse (reported by Tobias Pflug)
896 - Bug with nested structure (reported by Mikhail Daen)
897 - Bug where the script fails to detect the type of a variable when
898 the ignorecase option is on (reported by Alexey Vakhov)
899 - Error message when trying to use completion on a not yet saved
900 Vim buffer (reported by Neil Bird)
901 - Error message when trying to use completion on an file opened from
902 a tselect command (reported by Henrique Andrade)
903
904Version 0.4
905 - The script is renamed to OmniCppComplete according to the library
906 script directory structure.
907 - OmniCpp_ClassScopeCompletionMethod renamed to OmniCpp_DisplayMode
908 - Fixed a bug where the quickfix list is modified after a completion.
909 - OmniCpp_ShowPrototypeInAbbr option added. It allows to show the
910 function signature in the abbreviation.
911 - OmniCpp_ShowAccess option added. It allows to hide the access
912 information in the popup menu.
913 - The tags database format must be a ctags 5.6 database if you want to
914 complete anonymous types.
915 - Fixed current scope detection not working properly in destructors.
916 - Don't show protected and private members according to the current scope.
917 - Overloaded functions are now filtered properly.
918 - New cache system using less memory.
919 - The class scope of a method is now resolved properly with "using
920 namespace" declarations.
921 - OmniCpp_SelectFirstItem option added. It allows to not select the first
922 item in the popup menu when 'completeopt' does not contain "longest".
923 - Fixed the bug where a "random" item in the popup menu is selected
924 by default when 'completeopt' does not contain "longest" option.
925 - The script is now split in library scripts.
926 - Cache added for 'using namespace' search in included files
927 - Default value for OmniCpp_NamespaceSearch is now 1 (search only in the
928 current buffer).
929 - Namespace search automatically disabled for C files even if
930 OmniCpp_NamespaceSearch != 0.
931 - To avoid linear search in tags files, the ignorecase option is now
932 disabled when getting tags datas (the user setting is restored after).
933 - Fixed a bug where friend functions may crash the script and also crash vim.
934
935Version 0.32
936 - Optimizations in search members methods.
937 - 'May complete' behaviour is now set to default for dot '.' and arrow
938 '->' (mappings are set in after/ftplugin/cpp.vim)
939 - Fixed the option CppOmni_ShowScopeInAbbr not detected after the first
940 completion.
941 - Exceptions catched from taglist() when a tag file is corrupted.
942 - Fixed a bug where enumerators in global scope didn't appear in the
943 popup menu.
944
945Version 0.31
946 WARNING: For this release and future releases you have to build your tags
947 database with this cmd :
948 "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
949 Please read installation instructions in the documentation for details
950
951 - May complete added, please see installation notes for details.
952 - Fixed a bug where the completion works while in a comment or in a string.
953
954Version 0.3
955 WARNING: For this release and future releases you have to build your tags
956 database with this cmd :
957 "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
958 Please read installation instructions in the documentation for details
959
960 - Documentation added.
961 - Fixed a bug where typedefs were not correctly resolved in namespaces
962 in some cases.
963 - Fixed a bug where the type can not be detected when we have a decl
964 like this: class A {}globalVar;
965 - Fixed a bug in type detection where searchdecl() (gd) find
966 incorrect declaration instruction.
967 - Global scope completion now only works with non-empty base.
968 - Using namespace list is now parsed in the current buffer and in
969 included files.
970 - Fixed a bug where the completion fails in some cases when the user
971 sets the ignorecase to on
972 - Preview window information added
973 - Some improvements in type detection, the type can be properly detected
974 with a declaration like this:
975 'Class1 *class1A = NULL, **class1B = NULL, class1C[9], class1D[1] = {};'
976 - Fixed a bug where parent scopes were not displayed in the popup menu
977 in the current scope completion mode.
978 - Fixed a bug where an error message was displayed when the last
979 instruction was not finished.
980 - Fixed a bug where the completion fails if a punctuator or operator was
981 immediately after the cursor.
982 - The script can now detect parent contexts at the cursor position
983 thanks to 'using namespace' declarations.
984 It can also detect ambiguous namespaces. They are not included in
985 the context list.
986 - Fixed a bug where the current scope is not properly detected when
987 a file starts with a comment
988 - Fixed a bug where the type is not detected when we have myObject[0]
989 - Removed the system() call in SearchMembers(), no more calls to the
990 ctags binary. The user have to build correctly his database with the cmd:
991 "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
992 - File time cache removed, the user have to rebuild his data base after a
993 modification.
994
995Version 0.22
996 - Completion of unnamed type (eg: You can complete g_Var defined like
997 this 'struct {int a; int b;}g_Var;'). It also works for a typedef of
998 an unnamed type (eg: 'typedef struct {int a; int b;}t_mytype; t_mytype
999 g_Var;').
1000 - Tag file's time cache added, if a tag file has changed the global
1001 scope result cache is cleared.
1002 - Fixed a bug where the tokenization process enter in an infinite loop
1003 when a file starts with '/*'.
1004
1005Version 0.21
1006 - Improvements on the global scope completion.
1007 The user can now see the progression of the search and complete
1008 matches are stored in a cache for optimization. The cache is cleared
1009 when the tag env is modified.
1010 - Within a class scope when the user complete an empty word, the popup
1011 menu displays the members of the class then members of the global
1012 scope.
1013 - Fixed a bug where a current scope completion failed after a punctuator
1014 or operator (eg: after a '=' or '!=').
1015
1016Version 0.2
1017 - Improvements in type detection (eg: when a variable is declared in a
1018 parameter list, a catch clause, etc...)
1019 - Code tokenization => ignoring spaces, tabs, carriage returns and comments
1020 You can complete a code even if the instruction has bad
1021 indentation, spaces or carriage returns between words
1022 - Completion of class members added
1023 - Detection of the current scope at the cursor position.
1024 If you run a completion from en empty line, members of the current
1025 scope are displayed. It works on the global namespace and the current
1026 class scope (but there is not the combination of the 2 for the moment)
1027 - Basic completion on the global namespace (very slow)
1028 - Completion of returned type added
1029 - this pointer completion added
1030 - Completion after a cast added (C and C++ cast)
1031 - Fixed a bug where the matches of the complete menu are not filtered
1032 according to what the user typed
1033 - Change the output of the popup menu. The type of the member
1034 (function, member, enum etc...) is now display as a single letter.
1035 The access information is display like this : '+' for a public member
1036 '#' for a protected member and '-' for a private member.
1037 The last information is the class, namespace or enum where the member is define.
1038
1039Version 0.12:
1040 - Complete check added to the search process, you can now cancel
1041 the search during a complete search.
1042
1043Version 0.1:
1044 - First release
1045
1046==============================================================================
10479. Thanks~
1048 *omnicpp-thanks*
1049 * For advices, bug report, documentation, help, ideas :
1050 Alexey Vakhov (bug report)
1051 Arthur Axel "fREW" Schmidt (documentation)
1052 Dennis Lubert (bug report)
1053 Henrique Andrade (bug report)
1054 Kamil Renczewski (tips)
1055 Marek Olszewski (patch)
1056 Markus Trenkwalder (bug report)
1057 Martin Stubenschrott (bug report)
1058 Mikhail Daen (bug report)
1059 Neil Bird (bug report)
1060 Nicola Bonelli (tips)
1061 Robert Webb (bug report)
1062 Roland Kuck (patch)
1063 Tobias Pflug (bug report)
1064 Willem-Jan de Hoog (bug report)
1065 Yegappan Lakshmanan (advices)
1066
1067
1068 * Darren Hiebert for Exuberant Ctags
1069
1070 * All Vim devs for Vim
1071
1072 * Bram Moolenaar for Vim
1073
1074 * You for using this script :)
1075
1076==============================================================================
1077
1078 vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: