分享
 
 
 

vim -- cppcomplete : C/C++ and Java code completion

王朝c/c++·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

http://www.vim.org/scripts/script.php?script_id=527

cppcomplete : C/C++ and Java code completion

script karma

Rating 179/76, Downloaded by 5947

created by

Peter Puck

script type

utility

description

This plugin helps you complete things like:

variableName.abc

variableName->abc

typeName::abc

from the members of the struct/class/union that starts with abc.

If you just type abc will the script complete it with the names that

starts with abc and ignore any current scope.

The default key mapping to complete the code are:

Alt+l in insert mode will try to find the possible completions and display

them in a popup menu. Also normal completions to the names in

cppcomplete.tags.

Alt+j in insert mode will show the popup menu with the last results.

Selecting one of the items will paste the text.

F8/F9 will work in a similar way as Ctrl+N, Ctrl+P in unextended vim so the

script can be used without the popup menu.

F5 in insert mode will lookup the class and display it in a preview window

The key mapping are only tested under Windows and linux and they will not

work on all platforms. Changing the mappings is easy.

The plugin is depending on that exuberant ctags has generated a tags file

called cppcomplete.tags with the same options as in the following example:

ctags -n -f cppcomplete.tags --fields=+ai --C++-types=+p *

The script has a command called GenerateTags that executes the above ctags

command. The tag file cppcomplete.tags is local to the script so you can

use other tag files without affecting cppcomplete.

Java users do not need the --C++-types flag.

For C/C++ can the script generate the cppcomplete.tags from the included

files for you. This is based on vims checkpath function. The path must be

set correct, see the vim documentation.

This script do not requires grep anymore but it is supported. If the option

is set to build an internal list with derived classes and the first

completion takes a very long time may grep speed things up.

For Windows does the DJGPP port of grep works.

You only need grep.exe from the grep'version'b.zip file.

A good place for grep.exe could be the compilers bin directory.

The zip file is in the v2gnu directory, it can be downloaded from here:

http://www.delorie.com/djgpp/getting.html

It is possible to define a set of lines from cppcomplete.tags with regular

expressions. I call the set for a block. The functions for this:

BuildBlockFromRegexp the command to build the block, see below.

NextInBlock jump to the line described in the block, can be called by Shift+F8

PrevInBlock same as the above but in the other direction, use Shift+F9

EchoBlock shows the block itself

BuildMenuFromBlock builds a menu in GUI mode from the block

The jumps are done with an internal function so the tag stack will not be

affected.

Some simple examples there > is the prompt:

>class:l

Gives a block with all members that has a scope of a class beginning with l

>^a.*\ts\t

all structures beginning with an a

>^\(a\|b\|c)

Everything that starts with a,b or c

The full vim history mechanism can be used.

The script has a number of variables that can be set from the menu in the

GUI or wildmenu versions. They are at the top of the script file with descriptions if

you want to change them more permanent.

For Java do you probably want to generate a cppcomplete.tags file from the

sources of the Java SDK. The use is like with C/C++ but you will get a

better result if you change some of the configuration variables.

The default access is treated as if it was public.

If you are new to vim and have not heard about ctags, regexp, grep are they

all described in the online documentation. Just type :help followed by the word you

want more information about. They are excellent tools that can be used for

many things.

BUGS/Features

This plugin does not really understand any C/C++ code, it is not a real parser.

It works surprisingly well but can of course give a surprising result. :)

The current scope is unknown.

Multidimensional arrays should not have a space between ][, e.g.

xyz[1][2].abc should be OK but not xyz[1] [2].abc

The script does not accept functions, e.g. xyc()->abc will not be completed or rather

it will be completed but from all names beginning with abc.

(GTK) If the mouse leaves and then reenters the popup menu is the text cursor affected.

(GTK) The popup is displayed at the mouse position and not the text cursor position.

For internal use is register c used.

Requires exuberant ctags.

The only tested platforms for the popup menu are GTK (linux) and Windows.

+ probably a lot of other issues

Anyway, I have done some testing with MFC, DX9 framework (not COM), Java SDK, STL with

good results.

install details

I put it in .vim/plugin for automatic loading.

Exuberant ctags is also needed.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有