我有文本文件:
gvim file.txt In UNIX you can type this at any command prompt. If you are running Microsoft Windows, open an MS-DOS prompt window and enter the command. In either case, Vim starts editing a file called file.txt. Because this is a new file, you get a blank window. This is what your screen will look like: +---------------------------------------+ |# | |~ | |~ | |~ | |~ | |"file.txt" [New file] | +---------------------------------------+ ('#" is the cursor position.) The tilde (~) lines indicate lines not in the file. In other words, when Vim runs out of file to display, it displays tilde lines. At the bottom of the screen, a message line indicates the file is named file.txt and shows that you are creating a new file. The message information is temporary and other information overwrites it.
树文件:
^$ text. text\n - join lines in this block, because ends block dot more text.\n ^$ ^$ text.\n text: text\n - join lines in this block, because ends block > more text>\n ^$ text.\n - but not this, because don't ends '., :, > or !' text\n ^$
TASK:
.
,:
,>
或!
仅使用正则表达式我想了解操作的不同之处,选择使用文本的最佳工具。
尝试在Vim中创建一个正则表达式:
/^\s*\(.*\).
这将选择所有块文本
/[!\.:>]$
此选择已结束.
,:
,>
或!
/^\s*\(.*\)[!\.:>]$
此仅限选择行已结束.
,:
,>
或!
/^\s*\(.*\)[!\.:>]
此选择仅包含.
,:
,>
或!
答案 0 :(得分:0)
选择具有多行结尾的单行:
/^(.*)[!.:>]$/;
如果我尝试使用perl处理块,那么我会一次处理一行并匹配每一行。
答案 1 :(得分:0)
顺便说一句,如果你的主要目的是修复Unix和Windows之间的结束差异,那么值得知道简单的Unix工具dos2unix
将转换任意方向的文本文件。
答案 2 :(得分:0)
在vim中,请执行以下操作:
:#s/^(.*)[!.:>]$/ /gc;