How to delete the '\n' of every line in a file
So I have a huge file that I would like to format using vim.
So I want to delete the 'n' of every line, here is a file example:
I
Want
to
be
just one
line
I was trying to do it using this:
:%g/^/norm!(a keyword that deletes the /n)
I just don't know which keyword might work for that, so in other words, I would like to know a way to automate the manual commands 'I(press delete button)' on every line.
Thanks in advance!
The most idiomatic way of joining all lines in a buffer is to use the :join
command:
:%j!
(Remove the !
sign if you want Vim to insert space between joined lines. From the wording of the question I assume that you do not want to add spaces.)
The same could be done interactively, if you prefer:
ggVGgJ
(Again, use J
instead of gJ
if you want to separate joined lines with spaces.)
Another option is the :substitute
command:
:%s/n//
ggVGJ
Broken down:
why use vim? You could easily
tr -d 'n' < file
链接地址: http://www.djcxy.com/p/49332.html
上一篇: Vim:如何添加一个新行
下一篇: 如何删除文件中每一行的'\ n'