Sunday, July 7, 2019

settings - VIM Disable Automatic Newline At End Of File



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!


Answer



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




:set nofixendofline


Now regarding older versions of vim.



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



vim -b file
and once in vim:




:set noeol
:wq


done.



alternatively you can open files in vim with :e ++bin file



Yet another alternative:




:set binary
:set noeol
:wq

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...