sublime text 3 plugin,add digit and letter index in the beginning of every row
notice:
This Plugin (include the shortcut key
and command palette
) is invalid when the number of selected row <= 1.
shortcut key default setting:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Key Bindings – Default
shortcut key custom setting:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Key Bindings – User
- OS X: cmd+ctrl+x
- Linux: ctrl+alt+x
- Windows: ctrl+alt+x
example image:
- OS X: cmd+ctrl+shift+x
- Linux: ctrl+alt+shift+x
- Windows: ctrl+alt+shift+x
show popup menu, then use arrow-key(up/down) to select,
example image:
menu -> Tool -> Command Palette,(or use shortcut-key open Command Palette
)
input add row index
in Command Palette
, rather enter
- command-1
AddRowIndex: add row index
: According toPlugin Params Of Setting
,insert digit in the beginning of every row - command-2
AddRowIndex: add row index, 0,1,2,3...
: insert:0,1,2,3... - command-3
AddRowIndex: add row index, 1,2,3,4...
: insert:1,2,3,4... - command-4
AddRowIndex: add row index, a,b,c,d...
: insert:a,b,c,d...z,When > z, don`t insetrt letter - command-5
AddRowIndex: add row index, A,B,C,D...
: insert:A,B,C,D...Z,When > Z, don`t insetrt letter - command-6
AddRowIndexWithPopup: add row index with popup menu
: show popup menu, is equal toShortcut key 2
(show popup menu)
Default Setting:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Settings – Default
Custom setting:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Settings – User
setting option:
original text of test case, all texts is selected:
first row
second row
third row
default value: 0
start number
of inserted digit
when add_digit_index_start_number
is 0, after insert digit index::
0first row
1second row
2third row
when add_digit_index_start_number
is 1, after insert digit index::
1first row
2second row
3third row
default value: 1
digit step
when add_digit_index_step
is 1, after insert digit index::
0first row
1second row
2third row
when add_digit_index_step
is 2, after insert digit index::
0first row
2second row
4third row
default value: true
search digit in beginning of first row, if have digit, use this digit as add_digit_index_start_number
original text of test case, all texts is selected:
2 first row
second row
third row
when add_digit_index_is_parse_first_row
is true, after insert digit index:
2
is detected in beginning of the firt row, add_digit_index_start_number
is set to 2
2 first row
3second row
4third row
when add_digit_index_is_parse_first_row
is false, after insert digit index:
ignore didit 2
in beginning of the firt row, add_digit_index_start_number
is default value (2
)
0 2 first row
1second row
2third row
default value: true
insert the cursor at the back of the index number
This Plugin (include the shortcut key
and command palette
) is valid when the number of selected row > 1.
In addition, multiple rows with the cursor, this plugin is also valid :
sublime text 3 插件,给选中的每一行的行首增加数字索引,而且数字是递增的
注意:
当前选中的行数只有1行时,下面的方法1快捷键不会生效,方法2的command Command Palette里面也不会出现对应的选项
选中的行数必须 >= 2
快捷键 默认设置:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Key Bindings – Default
快捷键 自定义设置:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Key Bindings – User
- OS X: cmd+ctrl+x
- Linux: ctrl+alt+x
- Windows: ctrl+alt+x
如下图:
- OS X: cmd+ctrl+shift+x
- Linux: ctrl+alt+shift+x
- Windows: ctrl+alt+shift+x
然后使用 上、下方向键 选择,如下图
menu -> Tool -> Command Palette,(或者使用快捷键打开Command Palette)
在弹出框 输入 “add row index” ,回车即可
- command-1
AddRowIndex: add row index
: 根据插件的设置,在每行的行首插入相应的数字索引 - command-2
AddRowIndex: add row index, 0,1,2,3...
: 插入:0,1,2,3... - command-3
AddRowIndex: add row index, 1,2,3,4...
: 插入:1,2,3,4... - command-4
AddRowIndex: add row index, a,b,c,d...
: 插入:a,b,c,d...z,超出z的行,不插入字符 - command-5
AddRowIndex: add row index, A,B,C,D...
: 插入:A,B,C,D...Z,超出Z的行,不插入字符 - command-6
AddRowIndexWithPopup: add row index with popup menu
: 弹出选择菜单,等同于快捷键 2
默认设置:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Settings – Default
自定义设置:sublime text -> Preferences -> Package Settings -> AddRowIndex -> Settings – User
设置选项:
下面文字为测试用例,假设下面的三行文字为选中状态,原文如下:
第一行
第二行
第三行
默认值为:0
在每行的行首插入数字的时候的起始数字,
当add_digit_index_start_number
为0时,插入数字后的效果如下:
0第一行
1第二行
2第三行
当add_digit_index_start_number
为1时,插入数字后的效果如下:
1第一行
2第二行
3第三行
默认值为:1
在每行插入数字时,数字的递增的步长
当add_digit_index_step
为1时,插入数字后的效果如下:
0第一行
1第二行
2第三行
当add_digit_index_step
为2时,插入数字后的效果如下:
0第一行
2第二行
4第三行
默认值为:true
检测第一行的行首,是否有数字,有的话,使用此数字作为 add_digit_index_start_number
测试用例原文如下,假设下面的文件是选中状态:
2 第一行
第二行
第三行
当add_digit_index_is_parse_first_row
为 true 时,插入数字后的效果如下:
这里检测到第一行的行首有数字**“2”,所以就使用2**做为起始数字
2 第一行
3第二行
4第三行
当add_digit_index_is_parse_first_row
为 false 时,插入数字后的效果如下:
这里忽略了第一行的数字2,使用默认设置,从0开始计数
0 2 第一行
1第二行
2第三行
默认值为:true
对每行插入数字后,在数字后面也插入光标,以便用户继续操作:插入其它符号,
如果不需要再插入字符,那么使用ESC
就可以取消光标
如果要让该插件的快捷键
或者command Palette
生效,那么需要选择多行文本(即选择的行数 >= 2),
否则的话,快捷键
会无效,command Palette
也不会显示可用的的选项
只要改行有选中的文本,那么改行就算是被选中,没必要把改行的文字全部选中,如下图:
另外,光标多选也算,即只要本行有光标插入也可,如下图: