Textmate 切换折叠/展开 CSS 规则命令?

发布于 2024-08-07 00:57:04 字数 960 浏览 7 评论 0原文

有谁知道 Textmate / 命令(不是宏) "http://e-texteditor.com/" rel="nofollow noreferrer">E 文本编辑器 / Redcar< /a> / 等等。会将多行 CSS 规则折叠为一行或者,如果规则已经在一行上,请将其扩展为多行?我已经了解代码折叠,但这不是我所需要的 - 我需要能够在单行和多行之间切换规则,并像这样编辑和保存它们。

例如,如果我有这样的:

h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}

我希望能够将光标放在规则内的任何位置,点击键盘快捷键,它会变成这样:

h1 {
  font-size:3em;
  line-height:1;
  margin-bottom:0.5em;
}

再次点击快捷键时,它将转换回单行。

有这样的事情存在吗?有没有人有任何代码可以实现类似的功能,我可以重新调整用途(最好是 Ruby)?有谁知道这在 Textmate 中是否可行?

更新:CSS规则折叠和展开似乎是在 Textmate 中实现为一对宏。但是,这不是切换,并且在 E 文本编辑器(不支持宏)中也不起作用。不确定它是否适用于 Redcar。是否可以实现类似于可以进行切换的命令的功能?

Does anyone know of a command (not a macro) for Textmate / E Text Editor / Redcar / etc. that will collapse a multi-line CSS rule down to one line OR, if the rule is already on one line, expand it out to multi-line? I already know about code folding and that's not what I require - I need to be able to toggle the rules between single and multi-line and have them be edited and saved like that.

For example, if I have this:

h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}

I would like to be able to place my cursor anywhere within the rule, hit a keyboard shortcut and it would turn into this:

h1 {
  font-size:3em;
  line-height:1;
  margin-bottom:0.5em;
}

On hitting the shortcut again, it would convert back into single-line.

Does anything like this exist? Does anyone have any code that does something similar I could repurpose (ideally Ruby)? Does anyone know if this is even possible in Textmate?

Update: it seems that CSS rule collapsing and expanding is implemented as a pair of macros in Textmate. However, this isn't toggling and it also doesn't work in E Text Editor (which doesn't support macros). Not sure whether it works in Redcar. Is it possible to implement something similar as a command that can do toggling?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

国际总奸 2024-08-14 00:57:04

我最终创建了自己的命令来执行此操作。 在这里获取

有一个限制,为了使命令起作用,光标必须位于规则声明内的空白处;即,不在属性/值对范围内。我发现将光标放在左大括号内是触发命令的好地方。

如果有人知道如何选择父范围,那就太好了。

I ended up creating my own command to do this. Grab it here.

There is a limitation in that for the command to work, the cursor has to be in whitespace within a rule declaration; i.e., not in a property/value pair scope. I've found placing the cursor just inside the opening brace to be a good place to trigger the command from.

If anyone knows how to select a parent scope that would be neat.

北恋 2024-08-14 00:57:04

使用 CSS 包 ctrl + opt + Q 会将当前选定的规则折叠成 1 行。

Using the CSS bundle ctrl + opt + Q will collapse the currently selected rule into 1 line.

青衫儰鉨ミ守葔 2024-08-14 00:57:04

附加到 Mark Story 的答案,ctrl + Q 执行相反的操作,将一行 CSS 转换为格式良好的 CSS。

Appending to Mark Story's answer, ctrl + Q does the opposite, turning a single line of CSS into nicely formatted CSS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文