简体   繁体   English

跨多个操作系统在VIM中进行编译

[英]Compiling in VIM across multiple Operating Systems

The problem I have is this: 我的问题是这样的:

Open up vim on a windows machine, make something that compiles and save it. 在Windows机器上打开vim,进行编译并保存。

Move to a new workstation that is a Mac, open that same file in VIM, makes changes that are correct and get weird results, or sometimes issues with it even compiling. 移至Mac上的新工作站,在VIM中打开相同的文件,进行正确的更改并获得怪异的结果,有时甚至出现编译问题。

From what I have found it seems it is because of the encoding the operating systems use with the line returns. 从我发现的结果来看,这似乎是由于操作系统与行返回一起使用的编码。 Even if the code is good oddities will occur. 即使代码很好,也会发生奇怪的情况。

After looking around I found this to add to my .vimrc: 环顾四周后,我发现这可以添加到我的.vimrc中:

set fileformats=unix,mac,dos

but it does not seem to do the trick. 但这似乎并不能解决问题。 Has anyone else encountered this problem and knows of a efficient solution? 还有其他人遇到过这个问题并且知道有效的解决方案吗?

Thank you 谢谢

The default 'fileformats' setting should already cover all cases of consistent line endings. 默认的'fileformats'设置应该已经涵盖了行尾一致的所有情况。 You do run into trouble when you have mixed (eg LF and some CR-LF) endings, though. 但是,当您混合(例如LF和某些CR-LF)结尾时,确实会遇到麻烦。 You should easily detect those by inspecting the buffer, though. 但是,您应该通过检查缓冲区轻松地检测到那些。 If there are any lines with trailing ^M characters, you can remove those with 如果有尾随^M字符的行,则可以删除带有

:%s/\r$//

In any case, such problems indicate a misconfigured tool chain. 无论如何,此类问题表明工具链配置错误。 Configured well, Revision Control Systems and file transfer utilities should make line endings transparent. 配置良好, 版本控制系统和文件传输实用程序应使行尾透明。 You didn't mention any specifics of your environment, so it's hard to help there. 您没有提及环境的任何细节,因此很难在此提供帮助。

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

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