简体   繁体   English

在文本编辑器中将光标移动到html标记

[英]Move cursor across html tags in text editor

How can I move the cursor across HTML tags in a text editor like Sublime Text or anything else instead of pressing ctrl + arrow (not a direct move) keys so many times? 如何在文本编辑器(如Sublime Text或其他任何内容)中将光标移动到HTML标记,而不是按ctrl + arrow (不是直接移动)键这么多次?
Is there any shortcut available?, if not, how can I create one for Sublime Text editor? 有没有可用的快捷方式?如果没有,我如何为Sublime Text编辑器创建一个?
Here is how I want to move the cursor. 这是我想要移动光标的方式。

    <html>
       <p>
            "a"
       </p>
       <div>
            "b"
       </div>
    </html>

I want move the cursor from position a to b using a shortcut. 我想使用快捷方式将光标从位置a移动到b。

I'm not familiar with Sublime but I have heard that it's very similar to Textmate, it may actually be based on Textmate, I'm not sure. 我不熟悉Sublime,但我听说它与Textmate非常相似,它实际上可能基于Textmate,我不确定。

I am familiar with Textmate 1.5 though, and it does have a feature like this which allows you to setup tab triggers and templates by using the built in Bundle Editor. 我熟悉Textmate 1.5,它确实有这样的功能,允许您使用内置的Bundle Editor设置制表符触发器和模板。

note: it's worth noting that there is a newer version of Textmate available. 注意:值得注意的是有更新版本的Textmate可用。 I believe the current version is 2.0 but I tried it and decided to stick with 1.5 because 2.0 implemented some major changes and I preferred to stick with what I was familiar and happy with. 我相信目前的版本是2.0,但我尝试了它并决定坚持1.5因为2.0实现了一些重大变化,我更喜欢坚持我熟悉和满意的。

A very basic example of how tab triggers can be used in Textmate would be.. Tabmate触发器如何在Textmate中使用的一个非常基本的例子是...

<table border="0" cellpadding="$1" cellspacing="0"><tr><td height="$2"><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table></td></tr></table>

This is a simple table spacer that I use in emails rather than using transparent shims. 这是一个简单的表格垫片,我在电子邮件中使用而不是使用透明垫片。 By nesting a table within a table it will prevent it from collapsing and works as a cross-compatible alternative to transparent gif images for email layouts. 通过在表格中嵌套表格,可以防止表格折叠,并且可以作为电子邮件布局的透明gif图像的交叉兼容替代方案。

By setting this up in Textmate, all I have to do is type tspace followed by a Tab and this code automatically populates at the position of the cursor. 通过在Textmate中设置它,我所要做的就是键入tspace后跟一个Tab ,这段代码会自动填充到光标的位置。 Subsequent Tab 's will jump the cursor to each $ notation, which is Textmate's own syntax. 后续Tab会将光标跳转到每个$表示法,这是Textmate自己的语法。

So tspace + Tab generates the code, + Tab jumps to $1 where I then fill in the appropriate value, + Tab jumps to $2 where I fill in the appropriate value + Tab jumps to the end of the code block. 所以tspace + Tab生成代码,+ Tab跳转到$ 1,然后我填入适当的值,+ Tab跳转到$ 2,我填写适当的值+ Tab跳转到代码块的末尾。

note: you can also set it up where any placeholder is repeated so if I notate $1 in more than one location, it will automatically populate everywhere that variable is, the first time I fill it in. 注意:你也可以在任何占位符重复的地方设置它,所以如果我在多个位置记下$ 1,它将自动填充变量所在的任何地方,我第一次填写它。

This is only the most basic of examples. 这只是最基本的例子。 There are other similar features in Textmate, and they are only limited by how complex you set them up to be. Textmate中还有其他类似的功能,它们仅限于您设置它们的复杂程度。


Though, as I mentioned, I'm not familiar with Sublime, I did look into it briefly and found this article which outlines the exact same functionality that I've described and how it works within Sublime. 虽然,正如我所提到的,我对Sublime并不熟悉,但我确实对其进行了简要介绍,并发现这篇文章概述了我所描述的完全相同的功能以及它在Sublime中的工作原理。

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

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