现在有一个表及其所有的字段名称,需要定义常量名称以供后期使用。
需求:有字符串
TDate SalesName SCode SalesCode SName ActBuyNum BMoney ActSellNum SMoney PBuy CPrice CTypeDes ChgRadio RChange1DO RChange2DO RChange3DO RChange5DO RChange10DO RChange20DO RChange15DO RChange30DO RChange1DC RChange2DC RChange3DC RChange5DC RChange10DC RChange15DC RChange20DC RChange30DC RChange1M RChange3M RChange6M RChange1Y
需要改写成下面的文本
public static final String COLUMN_NAME_TDATE="TDATE"; public static final String COLUMN_NAME_SALESNAME="SALENAME"; public static final String COLUMN_NAME_SCODE="SCODE"; public static final String COLUMN_NAME_SALESCODE="SALESCODE"; public static final String COLUMN_NAME_SNAME="SNAME"; public static final String COLUMN_NAME_ACTBUYNUM="ACTBUYNUM"; public static final String COLUMN_NAME_BMONEY="BMONEY"; public static final String COLUMN_NAME_ACTSELLNUM="ACTSELLNUM"; public static final String COLUMN_NAME_SMONEY="SMONEY"; public static final String COLUMN_NAME_PBUY="PBUY"; public static final String COLUMN_NAME_CPRICE="CPRICE"; public static final String COLUMN_NAME_CTYPEDES="CTYPEDES"; public static final String COLUMN_NAME_CHGRADIO="CHGRADIO"; public static final String COLUMN_NAME_RCHANGE1DO="RCHANGE1DO"; public static final String COLUMN_NAME_RCHANGE2DO="RCHANGE2DO"; public static final String COLUMN_NAME_RCHANGE3DO="RCHANGE3DO"; public static final String COLUMN_NAME_RCHANGE5DO="RCHANGE5DO"; public static final String COLUMN_NAME_RCHANGE10DO="RCHANGE10DO"; public static final String COLUMN_NAME_RCHANGE20DO="RCHANGE20DO"; public static final String COLUMN_NAME_RCHANGE15DO="RCHANGE15DO"; public static final String COLUMN_NAME_RCHANGE30DO="RCHANGE30DO"; public static final String COLUMN_NAME_RCHANGE1DC="RCHANGE1DC"; public static final String COLUMN_NAME_RCHANGE2DC="RCHANGE2DC"; public static final String COLUMN_NAME_RCHANGE3DC="RCHANGE3DC"; public static final String COLUMN_NAME_RCHANGE5DC="RCHANGE5DC"; public static final String COLUMN_NAME_RCHANGE10DC="RCHANGE10DC"; public static final String COLUMN_NAME_RCHANGE15DC="RCHANGE15DC"; public static final String COLUMN_NAME_RCHANGE20DC="RCHANGE20DC"; public static final String COLUMN_NAME_RCHANGE30DC="RCHANGE30DC"; public static final String COLUMN_NAME_RCHANGE1M="RCHANGE1M"; public static final String COLUMN_NAME_RCHANGE3M="RCHANGE3M"; public static final String COLUMN_NAME_RCHANGE6M="RCHANGE6M"; public static final String COLUMN_NAME_RCHANGE1Y="RCHANGE1Y";
则在vim中只需要执行以下命令操作。
qa^wi<Enter><Esc>q 999@a<Enter> gg gUG<Enter> gg qb^ywipublic static final String COLUMN_NAME_<Esc>$i="<Esc>pi";<Esc>2$q 30@b
学会了vim确实可以不用Excel了。
当然例子中的实现方式有很多种,本例子是采用了录制的方式。也可以使用visual block mode下的I 来insert字符串,也是很快的。win vim使用CTRL+q进入visual block模式。因为CTRL+V在windows下表示复制。