VIM在文件末尾禁用自动换行 [英] VIM Disable Automatic Newline At End Of File

查看:156
本文介绍了VIM在文件末尾禁用自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在PHP商店工作,我们都使用不同的编辑器,而且我们都必须在Windows上工作.我使用vim,并且商店中的每个人都在抱怨,每当我编辑文件时,底部都会有一个换行符.我四处搜寻,发现这是vi& vim ...但是我想知道是否有某种方法可以禁用此功能. (最好是可以针对特定的文件扩展名禁用它.)

So I work in a PHP shop, and we all use different editors, and we all have to work on windows. I use vim, and everyone in the shop keeps complaining that whenever I edit a file there is a newline at the bottom. I've searched around and found that this is a documented behavior of vi & vim... but I was wondering if there was some way to disable this feature. (It wouldbe best if I could disable it for specific file extensions).

如果有人知道这一点,那就太好了!

If anyone knows about this, that would be great!

推荐答案

对于vim 7.4+,您可以使用(最好在.vimrc上使用)(感谢罗泽轩提供的最新消息!):

And for vim 7.4+ you can use (preferably on your .vimrc) (thanks to 罗泽轩 for that last bit of news!):

:set nofixendofline

现在有关vim的旧版本.

即使文件已经以结尾的新行保存了:

Even if the file was already saved with new lines at the end:

vim -b file 并且一次在vim中:

vim -b file and once in vim:

:set noeol
:wq

完成.

或者,您可以使用:e ++bin file

还有另一种选择:

:set binary
:set noeol
:wq

这篇关于VIM在文件末尾禁用自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆