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

后端 未结 6 1442
庸人自扰
庸人自扰 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 16:56

    You can do it with 3 keystrokes starting from normal mode:

    :%j
    
    • : enters command mode
    • % refers to all lines in the file
    • j executes the join command

    Now it seems that this adds a space between the lines. I am not sure if you want this.

提交回复
热议问题