当文件末尾有换行符时,我如何在 vim 中看到?似乎 vim 总是显示一个,无论它是否真的存在。
例如,打开一个末尾有换行符的文件:
echo "hi" > hi
# confirm that there are 3 characters, because of the extra newline added by echo
wc -c hi
# open in binary mode to prevent vim from adding its own newline
vim -b hi
:set list
由此可见:
hi$
现在相比之下,没有换行符的文件:
# prevent echo from adding newline
echo -n "hi" > hi
# confirm that there are only 2 characters now
wc -c hi
# open in binary mode to prevent vim from adding its own newline
vim -b hi
:set list
仍然显示:
hi$
那么如何在 vim 中查看文件是否真的有换行符呢?