In Vim how do I split a long string into multiple lines by a character?
我有一根很长的regex线
1  | (\.#.+|__init__\.py.*|\.wav|\.mp3|\.mo|\.DS_Store|\.\.svn|\.png|\.PNG|\.jpe?g|\.gif|\.elc|\.rbc|\.pyc|\.swp|\.psd|\.ai|\.pdf|\.mov|\.aep|\.dmg|\.zip|\.gz|\.so|\.shx|\.shp|\.wmf|\.JPG|\.jpg.mno|\.bmp|\.ico|\.exe|\.avi|\.docx?|\.xlsx?|\.pptx?|\.upart)$  | 
我想用
所以最后的形式是这样的
1 2 3 4 5 6 7  | (\.#.+| __init__\.py.*| \.wav| \.mp3| \.mo| \.DS_Store| ... etc  | 
我知道我可以用宏的形式来完成这个任务,但我认为聪明的人可以找到更快更容易的方法。
任何提示和帮助都会受到感激。谢谢!
尝试一下:
1 2  | :s/|/| /g  | 
以上内容将在当前行中有效。
要对整个文件执行替换,请在s之前添加一个
1 2  | :%s/|/| /g  | 
击穿:
1 2 3 4 5 6 7 8 9 10  | :    - enter command-line mode % - operate on entire file s - substitute / - separator used for substitute commands (doesn't have to be a /) | - the pattern you want to replace / - another separator (has to be the same as the first one) | - what we want to replace the substitution pattern with / - another separator g - perform the substitution multiple times per line  | 
用自身和换行符(
1 2  | :s/|/| /g  | 
(确保执行前光标位于有问题的行上)
实际上,您不必在模式前添加
/g