首页 \ 问答 \ Vim(7.3.3 Windows 64位):如果没有(^ f = unix),将^ M加到行尾(Vim (7.3.3 Windows 64bit): Add ^M to end of line if there is none (ff=unix))

Vim(7.3.3 Windows 64位):如果没有(^ f = unix),将^ M加到行尾(Vim (7.3.3 Windows 64bit): Add ^M to end of line if there is none (ff=unix))

我有大约10万个以上的文件,其中有部分损坏的数据,混合文本+二进制文件(带有http头的单个jpg图像数据文件),其中一些头字段具有dos样式^ M ^ J行终止,并且一些只有unix样式^ J 。 当vim打开这样的文件时,它将它视为unix格式。 因此,所有没有^ M的标题行需要添加。 但这已被证明是非常艰难的。

:1,11s/Cache-Control:.*\zs^M\{0,}$/^M/

不起作用,并且我尝试了各种各样的变体,甚至使用\ = printf(“%s”,“^ M”)作为替换字符串。 但结果始终是文件中的新空行。

唯一能够通过命令添加^ M的方法就是通过

:exe "normal A\<cq>\<cm>\<Esc>"

好的,一种方法是首先删除任何现有的^ M,然后按照前面的方法添加它。 但是,有没有更优雅的一个命令解决方案?

(所以不会有更多的误解,下面是这样一个文件的简短例子:

HTTP/1.1 200 OK
Server: Apache/2.2.3
(more lines...)
Cache-Control: public, max-age=214748
(more lines...)

ÿØÿá Exif  II*            ÿì

编辑/解决方案:关于100,000多个文件,这里有一个版本(关于仅在缓存控制线上丢失^ M),只有在^ M丢失时才匹配(因为并非所有文件都被损坏,这将节省大量时间,更新“)!

:1,11s/^Cache-Control:.\{-}\zs\(^M*$\)\(^M\)\@<!/\^M/i


I have some 100,000+ files with partially mangled data, mixed text+binary files (a single file of jpg image data with http headers), where some header fields have dos style ^M^J line termination, and some only unix style ^J. When vim opens a file like this, it treats it as unix format. So all header lines where there is no ^M, one needs to be added. But this has proven to be very tough.

:1,11s/Cache-Control:.*\zs^M\{0,}$/^M/

doesn't work, and i've tried all kinds of variations of that, even using \=printf("%s","^M") as substitution string. But the result is always a new empty line in the file.

The ONLY way i'm able to add a ^M by a command at all is by

:exe "normal A\<c-q>\<c-m>\<Esc>"

Ok so one way would be to first remove any existing ^M, and then add it by previous. But is there a more elegant, one command solution?

(So that there would be no more misunderstandings, here's a short example of such a file:

HTTP/1.1 200 OK
Server: Apache/2.2.3
(more lines...)
Cache-Control: public, max-age=214748
(more lines...)

ÿØÿá Exif  II*            ÿì

)

Edit/solution: regarding 100,000+ files, here's a version (regarding missing ^M only on cache-control lines) that only matches if ^M is missing (as not all files are mangled, this will save large amounts of time together with "update!"):

:1,11s/^Cache-Control:.\{-}\zs\(^M*$\)\(^M\)\@<!/\^M/i


原文:https://stackoverflow.com/questions/11688853
更新时间:2023-03-30 12:03

最满意答案

如果你想使用更高的一个获得最大高度并使用所有的盒子。

var maxHeight = 0;

$(yourelemselector).each(function(){
   var thisH = $(this).height();
   if (thisH > maxHeight) { maxHeight = thisH; }
});

$(yourelemselector).height(maxHeight);

编辑

如果工作,为什么你不接受答案? 第二个你不能用同一个帖子提出不同的问题,顺便提一下你怎么说'怎么把我最高输入组'不清楚


If you wanna use the heighter one get the max height and use for all the box.

var maxHeight = 0;

$(yourelemselector).each(function(){
   var thisH = $(this).height();
   if (thisH > maxHeight) { maxHeight = thisH; }
});

$(yourelemselector).height(maxHeight);

EDIT

If work why you don't accept the answer ? Second u can't use the same post for different question, by the way what you ask about 'how put i top input group' is not clear

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。