【发布时间】:2010-05-13 15:45:40
【问题描述】:
我只是在看this post,它描述了如何在 vim 中包装整个单词。接受的解决方案是这样的:
:set formatoptions=l
:set lbr
使用此文本(选项卡显示为 \t):
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will wr|ap here
|\t\tcan you see the wrap |
| |
|---------------------------------------|
这完成了这样的行为(选项卡显示为 \t):
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
|wrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
然而,我想重新定义这个函数。我希望包裹线前面的制表符数量与上面的线加一相同。即:
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
|\t\t\twrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
有什么想法吗?
【问题讨论】:
-
+1 表示为使问题尽可能清晰而付出的努力。
-
您希望文本在窗口边缘软换行,还是在行达到一定长度时硬换行?我认为您想要硬换行(在“将”一词之后在文本中插入换行符),但是从您的示例中很难分辨。
-
@Bill,我最感兴趣的是软包装,但硬包装解决方案也是可以接受的。
-
你想要的功能目前还没有内置到 Vim 中。然而,有一个接近的补丁:groups.google.com/group/vim_dev/web/vim-patches(它是 #15,“正确缩进换行”)。
-
相关:VimCasts 有一个关于使用外部 unix 实用程序处理此问题的精彩片段:vimcasts.org/e/18