【问题标题】:Are the ways or plugins to automatically minify CSS, Html and Javascript code in Vim?在 Vim 中自动缩小 CSS、Html 和 Javascript 代码的方法或插件是什么?
【发布时间】:2010-06-24 06:22:22
【问题描述】:

我想知道是否有一种方法可以自动缩小 html、css 或 javascript 文件。 这样每次我保存“源文件”时,Vim 都会自动对文件的缩小版本进行相同的更改(或自动创建或覆盖缩小版本)。

类似这样的:

来源:

// The -is- object is used to identify the browser.  Every browser edition
// identifies itself, but there is no standard way of doing it, and some of
// the identification is deceptive. This is because the authors of web
// browsers are liars. For example, Microsoft's IE browsers claim to be
// Mozilla 4. Netscape 6 claims to be version 5.

var is = {
    ie:      navigator.appName == 'Microsoft Internet Explorer',
    java:    navigator.javaEnabled(),
    ns:      navigator.appName == 'Netscape',
    ua:      navigator.userAgent.toLowerCase(),
    version: parseFloat(navigator.appVersion.substr(21)) ||
             parseFloat(navigator.appVersion),
    win:     navigator.platform == 'Win32'
}
is.mac = is.ua.indexOf('mac') >= 0;
if (is.ua.indexOf('opera') >= 0) {
    is.ie = is.ns = false;
    is.opera = true;
}
if (is.ua.indexOf('gecko') >= 0) {
    is.ie = is.ns = false;
    is.gecko = true;
}

缩小版:

var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}

【问题讨论】:

  • 哈哈。通常我们喜欢看源代码,但这是我认为实际上没有必要的一种情况(我们大多数人都知道缩小意味着什么)。尽管如此... +1 努力
  • 哈,我知道只是最近我问他们,虽然我想将文件“压缩”成 zip 或 gzip 文件。

标签: html css javascript minify


【解决方案1】:

我知道这不是 VIM,但http://code.google.com/p/minify/ Minify 项目在 Internet 上实时压缩它们,因此您不必担心源文件被意外压缩而无法识别。

【讨论】:

    【解决方案2】:

    进入可视模式选择整个文件并按SHIFT-J

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多