Coding Life

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

什么都不说,先来看看一个 gif 演示吧:

如果没看明白,可以访问此网站,上面还提供了一个在线演示(需要 JavaVM),效果很不错的:

http://nickgravgaard.com/elastictabstops/

简单来说,就是辅助编辑代码,有效减少了因对齐代码插入/删除 tab 而敲击按键的次数。为了避免这个图片失效,下面就用原文提供的例子来简单说明一下:

假设我们有这么一段代码:

#include <stdio.h>
int someDemoCode(	int fred,
					int wilma)
{
	x();						/* try making*/
	printf("hello again!\n");	/* this comment */
	makeThisFunction();			/* a bit longer*/
	for(i = start; i < end; ++i)
	{
		if (isPrime(i))
		{
			++numPrimes;
		}
	}
	return numPrimes;
}

可以看到三行注释都是对齐的(如果不是,那只是网页显示的问题。。。。),又假设现在需要编辑第七行的 makeThisFunction,改成 makeThisFunctionABitLonger,那么必然会导致改行后面的注释无法跟其上两行注释对齐,可是 Elastic Tabstops 就可以在编辑的同时自动给它对齐,变成下面这样:

#include <stdio.h>
int someDemoCode(	int fred,
					int wilma)
{
	x();									/* try making*/
	printf("hello again!\n");				/* this comment */
	makeThisFunctionABitLonger();			/* a bit longer*/
	for(i = start; i < end; ++i)
	{
		if (isPrime(i))
		{
			++numPrimes;
		}
	}
	return numPrimes;
}

  

按照作者的说法,VS2010 的插件版本 will soon be available to a small number of users in the form of a limited public beta,看来还要再等一段时间才能看到实际实现起来的效果了。

posted on 2011-08-28 23:38  yonken  阅读(3680)  评论(3编辑  收藏  举报