Home > Backend Development > PHP Tutorial > How to remove line terminator in vi/vim editor

How to remove line terminator in vi/vim editor

WBOY
Release: 2023-03-02 13:06:01
Original
3037 people have browsed it

<code>vim hello.txt
# 输入hello
# :wq 保存退出
cat hello.txt</code>
Copy after login
Copy after login

The result is like this:
How to remove line terminator in vi/vim editor

However:

<code>echo -n "hello" > hello.txt
cat hello.txt</code>
Copy after login
Copy after login

The result is like this:
How to remove line terminator in vi/vim editor
Yes, the cat at this time has a termination mark, and the file will display with no line terminators

But when I edit it with vim and save it, the line terminator appears again.

You can see this newline character using nano, but I don’t know how to use nano and don’t use nano very often (don’t laugh)

--The following content has nothing to do with the topic, it just describes the background of the accident--

This problem caused me to have an extra newline character when using ssi in nginx, so that the style and js address were spliced ​​into newlines, and most browsers could not load normally.

<code><link type="text/css" href="<!--#include virtual='/inc/cdn.inc'-->/public/index.css?v=<!--#include virtual='/inc/version.inc" /></code>
Copy after login
Copy after login

file: cdn.inc, due to manual vim editing of the file, most users of the website were not aware of the style failure (extra line breaks)

<code>mydomain.com</code>
Copy after login
Copy after login

file: version.inc, the script will update this file when it goes online to clear the browser cache

<code>1477452280307</code>
Copy after login
Copy after login

Reply content:

<code>vim hello.txt
# 输入hello
# :wq 保存退出
cat hello.txt</code>
Copy after login
Copy after login

The result is like this:
How to remove line terminator in vi/vim editor

However:

<code>echo -n "hello" > hello.txt
cat hello.txt</code>
Copy after login
Copy after login

The result is like this:
How to remove line terminator in vi/vim editor
Yes, the cat at this time has a termination mark, and the file will display with no line terminators

But when I edit it with vim and save it, the line terminator appears again.

You can see this newline character using nano, but I don’t know how to use nano and don’t use nano very often (don’t laugh)

--The following content has nothing to do with the topic, it just describes the background of the accident--

This problem caused me to have an extra newline character when using ssi in nginx, so that the style and js address were spliced ​​into newlines, and most browsers could not load normally.

<code><link type="text/css" href="<!--#include virtual='/inc/cdn.inc'-->/public/index.css?v=<!--#include virtual='/inc/version.inc" /></code>
Copy after login
Copy after login

file: cdn.inc, due to manual vim editing of the file, most users of the website were not aware of the style failure (extra line breaks)

<code>mydomain.com</code>
Copy after login
Copy after login

file: version.inc, the script will update this file when it goes online to clear the browser cache

<code>1477452280307</code>
Copy after login
Copy after login

<code>:set noendofline binary
:w</code>
Copy after login

Check if set ff is set to dos

For Linux, the configuration is usually set ff=unix, right?

----- Editor----
I experimented and it seems to have nothing to do with ff-. -

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template