无意中发现 vim 会自动追加一个 \n 到文本行末尾。去论坛问了一下,找到了答案:
*'endofline'* *'eol'* *'noendofline'* *'noeol'*
'endofline' 'eol' boolean (default on)
local to buffer
{not in Vi}
When writing a file and this option is off and the 'binary' option
is on, no <EOL> will be written for the last line in the file. This
option is automatically set when starting to edit a new file, unless
the file does not have an <EOL> for the last line in the file, in
which case it is reset. Normally you don't have to set or reset this
option. When 'binary' is off the value is not used when writing the
file. When 'binary' is on it is used to remember the presence of a
<EOL> for the last line in the file, so that when you write the file
the situation from the original file can be kept. But you can change
it if you want to.
通过 set noendofline 和 set binary ,vim 新创建一个文件时,结尾的 \n 可以去掉,但对于已存在的文件,却不起作用。
vim 行尾自动追加 \n 去除
猜你喜欢
转载自blog.csdn.net/weixin_37989267/article/details/113986916
今日推荐
周排行