崇高的文本多个光标? [英] Sublime text multiple cursors?

查看:32
本文介绍了崇高的文本多个光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sublime Text 太先进了,这似乎是个愚蠢的问题,但是...

我开始用 PHP 编写 for 循环(使用 SFTP),我喜欢它让我可以选择自动生成循环.然而,它进入了这种奇怪的多光标模式,

1)我不确定如何在不使用鼠标的情况下使用/退出;
2)它似乎没用,因为所有 3 个类型都键入相同的内容,即使我需要更改,例如,$i > x 或 $i = x.

解决方案

虽然 Sublime 确实支持多游标的想法(这是一个令人难以置信的节省时间并且非常有用,正如我们即将看到的那样),你在这里真正要问的是一个

首先回答问题中的第 2 点,这远非无用.如此处所示,我输入文本 for,然后按 Tab 将代码段展开.这里要注意的第一件事是状态行显示 Field 1 of 4 告诉我我在一个片段中并且它包含四个字段.

第一个字段是循环的控制变量的名称,所有这些都被选中,这样当我更改名称时,它们都会同时更改,因为当有多个光标时,您键入的文本同时出现.

更改完变量名后,我再次按 Tab 转到下一个字段,这使我可以轻松更改循环开始的点.再按一次 Tab 将我带到第三个字段,在那里我可以指定循环结束的位置.

最后一次按 Tab 退出代码段并选择循环中的文本,这样我就可以开始编写代码(注意:我不是 PHP 开发人员).

此时你可以看到 Sublime 为 echo 提供了另一个片段,它会扩展为一个带有引号的 echo 语句,然后允许我编辑文本回声并跳到最后.

回到问题中的第一点,您可以随时使用 Esc 跳出片段并返回常规编辑.您还可以使用 TabShift+Tab 在代码段中的字段之间移动,然后在代码段的最后一个字段处按 Tab 退出也一样.

在这种特殊情况下,代码段中的第一个字段设置了多个游标,因此在该字段处于活动状态时退出代码段会使多个游标有效.您可以再按一次 Esc 跳回单个光标(无论您最终如何使用多个光标,都是如此).

Sublime Text is so damn advanced and this seems like such a stupid question, but...

I started writing a for loop in PHP (using SFTP), loved that it gave me a choice to auto-generate the loop. However, it enters this weird multi-cursor mode, which

1)I am not really sure how to use/exit without using the mouse;
2) it seems useless, seeing as all 3 type the same thing, even though I need to change, for example, the $i > x or $i = x.

解决方案

Although Sublime does indeed support the idea of multiple cursors (which is an incredible time saver and useful as all get out, as we're about to see), what you're actually asking about here is a snippet which in this case happens to also include multiple cursors.

The general idea is that for code that you're likely to type many times (e.g. a for loop), you can create a snippet that will generate the bulk of the text for you in one shot, and then allow you to easily customize it as needed. In this case, the snippet in question is part of the default functionality of Sublime and is provided by the shipped PHP package.

To answer point #2 in your question first, this is far from useless. As seen here, I enter the text for and then press Tab to expand the snippet out. The first thing to notice here is that the status line says Field 1 of 4 to tell me that I'm in a snippet and that it contains four fields.

The first field is the name of the control variable for the loop, and all of them are selected so that as I change the name, all of them change at the same time because when there are multiple cursors, the text you type appears at all of them at the same time.

Once I'm done changing the name of the variable, I press Tab again to go to the next field, which allows me to easily change the point at which the loop starts. Another press of Tab takes me to the third field, where I can specify where the loop ends.

One last press of Tab exits the snippet and selects the text in the loop, so I can start writing my code (caveat: I am not a PHP developer).

At this point you can see Sublime offering another snippet for echo, which would expand out to an echo statement complete with quotes, then allow me to edit the text in the echo and skip to the end.

Circling back around to the first point in your question, you can use Esc at any point to jump out of a snippet and go back to regular editing. You can also use Tab or Shift+Tab to move through the fields in the snippet, and pressing Tab at the last field in the snippet exits it as well.

In this particular case, the first field in the snippet sets up multiple cursors, and so exiting the snippet while this field is active leaves multiple cursors in effect. You can jump back to a single cursor by pressing Esc one more time (this is true regardless of how you ended up with multiple cursors).

这篇关于崇高的文本多个光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆