Linux 在vim中将垂直文本转换为水平文本
我想将文件中的垂直文本转换为水平文本。像Linux 在vim中将垂直文本转换为水平文本,linux,vim,Linux,Vim,我想将文件中的垂直文本转换为水平文本。像 1 2 3 到 我可以使用tr命令tr'\n''选择行并用J连接它们 从:h J: *J* J Join [count] lines, with a minimum of two lines. Remove the indent and insert up to two spaces (see below).
1
2
3
到
我可以使用tr命令
tr'\n''选择行并用J
连接它们
从:h J
:
*J*
J Join [count] lines, with a minimum of two lines.
Remove the indent and insert up to two spaces (see
below).
*v_J*
{Visual}J Join the highlighted lines, with a minimum of two
lines. Remove the indent and insert up to two spaces
(see below). {not in Vi}
简单的。使用从第一行到最后一行的范围,并在它们之间添加空格:
:0,$join
另一种方式:
将\n
替换为
:{fromLine},{toLine}s/\n/ /g
而且,只是为了好玩:
:{fromLine},{toLine}!tr '\n' ' '
甚至更短的:%j
:{fromLine},{toLine}!tr '\n' ' '