在Vim的代码块周围创建一个ascii框
是否可以在代码块周围创建ASCII注释框?
> ASCII框应足够智能,以扩展框周围 >以可视模式选择代码块 这是一个例子. 之前 ; Convert to radians theta45 = (theta + 45.)/!RADEG theta90 = (theta + 90.)/!RADEG theta = theta / !RADEG Ey = Ey * normal ; Engineering shear strain Gxy = shear * Exy 后 ; -----------------------------------------; ; Convert to radians ; theta45 = (theta + 45.)/!RADEG ; theta90 = (theta + 90.)/!RADEG ; theta = theta / !RADEG ; Ey = Ey * normal ; ; ; Engineering shear strain ; Gxy = shear * Exy ; ; -----------------------------------------; 到目前为止我尝试过的 '<,'>s/^(s*)(.*)$/=join([submatch(1),';',submatch(2),repeat('-',50-len(submatch(1)) - len(submatch(2))),';'],'') 注意我首先选择了一个视觉块. 问题 >它为每一行添加’ – ‘字符,而不是第一行和最后一行 以下是它的外观: ;; Convert to radians ------------------; ;theta45 = (theta + 45.)/!RADEG------------------; ;theta90 = (theta + 90.)/!RADEG------------------; ;theta = theta / !RADEG ------------------; ;Ey = Ey * normal ------------------; ;--------------------------------------------------; ;; Engineering shear strain ------------------; ;Gxy = shear * Exy ------------------------; 虽然,它并不是我想要得到的.我只能走到这一步! 感谢您的阅读和帮助. 解决方法
这个怎么样:
<esc>'>o;<esc>'<O;<esc>v'>j:norm 51A <C-v><esc>51|Dr;<cr>:'<s/ /-/g<cr>:'>&&<cr> 说明: 首先,我们需要添加额外的行.所以我们< esc>视觉模式,跳到我们之前选择的结尾并添加一个带分号的换行符. “>○;< ESC取代.然后,跳回上一个选择的开头,并向上添加一个带分号的换行符’< O;< esc>.现在,我们需要在此行上启动可视模式,跳转到上一行,再一行v’> j.现在,缓冲区看起来像这样: ; Here are a whole bunch of uneven lines ; 它都是视觉选择的.然后,我们需要将每一行填充到50个空格.所以, :norm 51A <C-v><esc>51Dr; 首先添加51个空格,然后跳转到第51列,删除到最后,并用分号替换50.现在我们的缓冲区如下所示: ; ; Here ; are ; a whole bunch of ; uneven ; lines ; ; ; 现在,我们只是在选择的开头用空格替换破折号: :'<s/ /-/g<cr> 并在选择结束时执行相同的替换: :'>&&<cr> 现在缓冲区看起来像这样: ;-------------------------------------------------; ;Here ; ;are ; ;a whole bunch of ; ;uneven ; ;lines ; ;-------------------------------------------------; 显然,为了方便起见,您可能希望将其包装在映射,函数或宏中. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |