本文介绍了Sublime Text 2 代码格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我说我来自 Microsoft 背景,Visual Studio 是我的支柱.它有一个命令(键绑定是任意的)可以自动格式化任何代码语法.相同的命令适用于 HTML、CSS、Javascript、C# 等.

First let me say I come from a Microsoft background and Visual Studio is my bread and butter. It has a command (keybind is arbitrary) that auto-formats any code syntax. The same command works in HTML, CSS, Javascript, C#, etc.

我已经尝试过 ST2 的插件,但到目前为止我发现大多数插件都不能在 Windows 机器上运行,如果可以,那只是为了一个非常特定的目的,就像 Javascript.

I have tried plugins for ST2 and so far I've found most don't work on a Windows box and if they do, it's for a very specific purpose like just Javascript.

我已经尝试过(并在适当的地方打开了问题):

I have tried (and opened Issues where appropriate):

https://github.com/victorporof/Sublime-HTMLPrettify

https://github.com/jdc0589/JsFormat(这个确实有效)

https://github.com/welovewordpress/SublimeHtmlTidy

是否有任何 ST2 的 Windows 用户发现任何可以格式化 CSS/HTML/Javascript 的东西,最好是一次性的?

Have any Windows users of ST2 found anything that works to format CSS/HTML/Javascript, preferably in one shot?

由于这个问题在没有活动的情况下获得了很多视图,我会说我正在仍在寻找一个可以格式化各种脚本类型的插件相同的命令.

Since this question is getting lots of views with no activity, I'll say that I am still looking for a plugin that can format various script types within the same command.

2013 年 10 月仍然没有找到任何涵盖 JS+CSS+HTML 的内容,但到目前为止我已经确定了 JsFormat最有效和无错误,只为 JavaScript 进行最少的配置.

October 2013Still haven't found anything that covers JS+CSS+HTML well however I have settled on JsFormat as by far the most effective and bug free with the least amount of configuration for just JavaScript.

推荐答案

我不能说第二还是第三,但是如果你先安装 Node,Sublime-HTMLPrettify 工作得很好.安装后,您必须设置自己的快捷键.我在 Windows 上注意到的一件事,你可能需要在 %PATH% 变量中编辑你的节点路径,如果它已经很长(我认为 %PATH% 变量的限制是 1024,之后的任何内容都被忽略.)

I can't speak for the 2nd or 3rd, but if you install Node first, Sublime-HTMLPrettify works pretty well. You have to setup your own key shortcut once it is installed. One thing I noticed on Windows, you may need to edit your path for Node in the %PATH% variable if it is already long (I think the limit is 1024 for the %PATH% variable, and anything after that is ignored.)

有一个 Windows 错误,但在问题中有一个修复程序.您需要编辑 HTMLPrettify.py 文件 - https://github.com/victorporof/Sublime-HTMLPrettify/issues/12

There is a Windows bug, but in the issues there is a fix for it. You'll need to edit the HTMLPrettify.py file - https://github.com/victorporof/Sublime-HTMLPrettify/issues/12

这篇关于Sublime Text 2 代码格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:48