简体   繁体   English

是否可以为多个游标键入不同的值?

[英]Is it possible to type different value for multiple cursors?

When doing multi cursor selection, often you need to type a different value for each, you've to cancel selection even though all cursors are where you want them to be.在进行多 cursor 选择时,通常您需要为每个输入不同的值,即使所有光标都在您想要的位置,您也必须取消选择。

Is it possible to activate some sort of mode and press tab to automatically iterate through each one by one on every tab and type your value.是否可以激活某种模式并按 Tab 以在每个选项卡上自动逐个迭代并键入您的值。 Esc to cancel the mode. Esc 取消模式。

在此处输入图像描述

Note: how in end I had to type 1, 2, 3, 4 manually.注意:最后我必须手动输入 1、2、3、4。 Those could have been food categories, clothing size, select options etc.这些可能是食品类别、服装尺寸、select 选项等。

For the special case of when you want to insert values that follow a sequence at your multiple cursor locations, then the powerful Insert Nums package for Sublime Text can help.对于特殊情况,当您想在多个光标位置插入一个序列的值时,强大的 Sublime Text 的Insert Nums包可以提供帮助。

Insert Nums can fill in numbered blanks (1,2,3,4, ... 10), and much more. Insert Nums 可以填充编号的空格(1,2,3,4, ... 10)等等。 Just about anything you could write as a for loop can be generated and inserted at the multiple cursors.几乎任何可以作为 for 循环编写的内容都可以生成并插入到多个游标处。 This includes integer/float/string, count up/down, arbitrary start/stop/step values, and formatting to hex, binary, etc., representation.这包括整数/浮点数/字符串、向上/向下计数、任意开始/停止/步长值以及格式化为十六进制、二进制等表示。 You can also evaluate an expression at each index, so for example you can create a geometric or power series or a pattern of bit shifts.您还可以在每个索引处计算表达式,例如,您可以创建几何或幂级数或位移模式。

The default case for Insert Nums is integers, starting at 1, incrementing by 1, and ending when all selections are filled. Insert Nums 的默认情况是整数,从 1 开始,递增 1,并在所有选择都填满时结束。 For the example problem in the question of numbering Items , all you'd have to do is Ctrl + Alt + N , then Return .对于编号Items问题中的示例问题,您所要做的就是Ctrl + Alt + N ,然后Return The numbers 1 through 5 would be filled in.将填写数字 1 到 5。

In case you don't want to install extension, you can copy sample data (which is generated by your favorite scripts or tools , for example) then paste it to the current cursors.如果您不想安装扩展,您可以复制示例数据(例如由您最喜欢的脚本或工具生成),然后将其粘贴到当前光标。

For example, I generate numbers by a cent JavaScript:例如,我通过一分 JavaScript 生成数字:

Array(10).fill(0).map((a, i) => i + 1).join('\n')

Then,然后,

在此处输入图片说明

I can only answer for Sublime, and there core Sublime can't do this out of the box, but you can add the capability to do it to via a third party package.我只能回答 Sublime,核心 Sublime 不能开箱即用,但您可以通过第三方包添加执行此操作的功能。

The PowerCursors package is one way to go with this. PowerCursors包是解决此问题的一种方法。 With it installed it's as simple as Alt+[ and Alt+] to cycle between existing cursors (the binds use Ctrl instead if you're on MacOS) and type what you like, amongst other capabilities.安装后,它就像Alt+[Alt+]一样简单,可以在现有光标之间循环(如果您使用的是 MacOS,则绑定使用Ctrl代替)并键入您喜欢的内容,以及其他功能。

There may well be other packages that incorporate something similar as well, so it may be worth casting around a little bit on packagecontrol.io to see what you can dig up.很可能还有其他包也包含了类似的东西,所以可能值得在packagecontrol.io上多花点时间看看你能挖掘到什么。

For CudaText editor, plugin "Carets Numbering" exists, which does this job.对于CudaText编辑器,存在插件“ Carets Numbering”,它可以完成这项工作。 You enter starting number, etc, and it inserts increasing numbers at multi-carets positions.您输入起始编号等,它会在多插入符号位置插入递增的数字。

在此处输入图片说明

Text Pastry is a vscode extension which does exactly these type of things. Text Pastry是一个 vscode 扩展,它可以做这些事情。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM