我们的项目中有一个CSV文件导出的功能, 他可以以Schedule的方式运行. 今天我们要压力测试他.
GUI界面可以每次添加一条Schedule, 我要添加60个, 间隔为1分钟的, 每小时执行一次的Schedule.
显然GUI有点慢, 于是我们要直接操作数据库:
于是今天使用vim的目的便是得到形如下面样子的一堆Sql:
INSERT INTO ME.SCHEDULE(..., DATETIME, ...) VALUES(..., '2009-01-01 01:01:00.0', ...)
INSERT INTO ME.SCHEDULE(..., DATETIME, ...) VALUES(..., '2009-01-01 01:02:00.0', ...)
INSERT INTO ME.SCHEDULE(..., DATETIME, ...) VALUES(..., '2009-01-01 01:03:00.0', ...)
....
方法1: 使用Vim命令
2. Y
3. 58p
4. :'<,'>s/2009-01-01 01:\zs\d\d\ze:/\=line(".") - line("'<") - 1
vim的替换命令中是可以使用变量的,关于命令4的详细解释可以参照下面链接, 里面有详细的讲解还有其他例子:
下面是一个转载地址,都放到了一起,便于阅读.
方法2: 使用VisIncr插件
这个插件很酷, 很像Excel中拖动时,以序列方式填充的效果.
可以对数字, 日期, 星期, 字母进行序列填充, 方式有升序和降序, 同时可以指定step间隔.
插件地址:VisIncr
安装后可以使用":he visincr-examples" 命令查看附带帮助.
下面是附带的例子, 可窥用法一斑.
==============================================================================
4. Examples: *visincr-examples*
LEFT JUSTIFIED INCREMENTING EXAMPLES
:I :I 2 *ex-visincr-I*
Use ctrl-V to Use ctrl-V to
Original Select, :I Original Select, :I 2
8 8 8 8
8 6 8 10
8 4 8 12
8 2 8 14
8 0 8 16
:I -1 :I -2
Use ctrl-V to Use ctrl-V to
Original Select, :I -1 Original Select, :I -3
8 8 8 8
8 7 8 5
8 6 8 2
8 5 8 -1
8 4 8 -4
RIGHT JUSTIFIED INCREMENTING EXAMPLES
:II :II 2 *ex-visincr-II*
Use ctrl-V to Use ctrl-V to
Original Select, :II Original Select, :II 2
8 8 8 8
8 308 8 10
8 308 8 12
8 308 8 14
8 308 8 16
:II -1 :II -2
Use ctrl-V to Use ctrl-V to
Original Select, :II -1 Original Select, :II -3
8 8 8 8
8 7 8 5
8 6 8 2
8 5 8 -1
8 4 8 -4
DATE INCREMENTING EXAMPLES
:IMDY *ex-visincr-IMDY*
Use ctrl-V to Use ctrl-V to
Original Select, :IMDY Original Select, :IMDY 7
06/10/03 6/10/03 06/10/03 6/10/03
06/10/03 6/11/03 06/10/03 6/11/03
06/10/03 6/12/03 06/10/03 6/12/03
06/10/03 6/13/03 06/10/03 6/13/03
06/10/03 6/14/03 06/10/03 6/14/03
:IYMD *ex-visincr-IYMD*
Use ctrl-V to Use ctrl-V to
Original Select, :IYMD Original Select, :IYMD 7
03/06/10 03/06/10 03/06/10 03/06/10
03/06/10 03/06/11 03/06/10 03/06/17
03/06/10 03/06/12 03/06/10 03/06/24
03/06/10 03/06/13 03/06/10 03/07/ 1
03/06/10 03/06/14 03/06/10 03/07/ 8
:IDMY *ex-visincr-IDMY*
Use ctrl-V to Use ctrl-V to
Original Select, :IDMY Original Select, :IDMY 7
10/06/03 10/06/03 10/06/03 10/06/03
10/06/03 11/06/03 10/06/03 17/06/03
10/06/03 12/06/03 10/06/03 24/06/03
10/06/03 13/06/03 10/06/03 1/07/03
10/06/03 14/06/03 10/06/03 8/07/03
ALPHABETIC INCREMENTING EXAMPLES
:IA *ex-visincr-IA*
Use ctrl-V to Use ctrl-V to
Original Select, :IA Original Select, :IA 2
a) e) A) A)
a) g) A) C)
a) i) A) E)
a) k) A) G)
DAYNAME INCREMENTING EXAMPLES
:ID *ex-visincr-ID*
Use ctrl-V to Use ctrl-V to
Original Select, :ID Original Select, :ID 2
Sun Sun Sun Sun
Sun Mon Sun Tue
Sun Tue Sun Thu
Sun Wed Sun Sat
Sun Thu Sun Mon
:ID
Use ctrl-V to Use ctrl-V to
Original Select, :ID Original Select, :ID 2
Sunday Sunday Sunday Sunday
Sunday Monday Sunday Monday
Sunday Tuesday Sunday Tuesday
Sunday Wednesday Sunday Wednesday
Sunday Thursday Sunday Thursday
MONTHNAME INCREMENTING EXAMPLES
:IM *ex-visincr-IM*
Use ctrl-V to Use ctrl-V to
Original Select, :IM Original Select, :IM 2
Jan Jan Jan Jan
Jan Feb Jan Mar
Jan Mar Jan May
Jan Apr Jan Jul
Jan May Jan Sep
:IM
Use ctrl-V to Use ctrl-V to
Original Select, :IM Original Select, :IM 2
January January January January
January February January March
January March January May
January April January July
January May January September
==============================================================================