手把手教你把Vim改装成一个IDE编程环境(图文)
set cino=:0g0t0(sus 设定 C/C++ 风格自动缩进的选项, 这里简要介绍一下这段代码里用到的选项的含义, cino 支持的选项还很多, 更多选项请看用户手册。
// :0
//
// switch 语句之下的 case 语句缩进 0 个空格,也就是说不缩进,与 switch 块平
// 齐,使用这样风格:
switch (x)
{
case 1:
a = b;
break;
default:
}
// g0
//
// class、struct 等之下的访问权限控制语句,如 public、protected、private 等,
// 相对 class、struct 等所在的块缩进 0 个空格,与 class 等块平齐,使用这样的
// 风格:
class foo
{
public:
int a;
private:
int b;
};
// t0
//
// 如果函数返回值与函数名不在同一行,则返回值缩进 0 个空格,也就是说不缩进,如
// 下所示:
// set cino=t4
int
func1()
{
}
// set cino=t0
int
func()
{
}
// (sus
//
// 当一对括号跨越多行时,其后的行缩进前面 sw 指定的距离,效果如下:
int a = (1 + 2 + 3
+ 4 + 5 + 6
+ 7 + 8) * 9;
// :0
//
// switch 语句之下的 case 语句缩进 0 个空格,也就是说不缩进,与 switch 块平
// 齐,使用这样风格:
switch (x)
{
case 1:
a = b;
break;
default:
}
// g0
//
// class、struct 等之下的访问权限控制语句,如 public、protected、private 等,
// 相对 class、struct 等所在的块缩进 0 个空格,与 class 等块平齐,使用这样的
// 风格:
class foo
{
public:
int a;
private:
int b;
};
// t0
//
// 如果函数返回值与函数名不在同一行,则返回值缩进 0 个空格,也就是说不缩进,如
// 下所示:
// set cino=t4
int
func1()
{
}
// set cino=t0
int
func()
{
}
// (sus
//
// 当一对括号跨越多行时,其后的行缩进前面 sw 指定的距离,效果如下:
int a = (1 + 2 + 3
+ 4 + 5 + 6
+ 7 + 8) * 9;
方法:将.vim文件复制到/usr/share/vim-scripts/plugin下