In Vim, what is the simplest way to join all lines in a file into a single line?

后端 未结 6 1438
庸人自扰
庸人自扰 2020-12-07 16:32

I want to join all lines in a file into a single line. What is the simplest way of doing this? I\'ve had poor luck trying to use substitution (\\r\\n or

6条回答
  •  北海茫月
    2020-12-07 17:18

    I’m surprised no one even mentioned the other way:

    :%s/\n/ /
    

    I am equally surprised that no one pointed out that the range 1,$ has a shorthand that’s written %.

    (This doesn’t do the same thing as joining the lines, but depending on circumstances that may in fact be more appropriate.)

提交回复
热议问题