我正在使用vim-surround,我正在尝试替换:
'this text needs to be replaced'使用
**this text needs to be replaced**我做过yss和cst (即):
:cst**
:yss**并且两者都只捕获到第一个*。
如何用字符串将文本包围起来?
HTML标记显然工作得很好,我猜他们会检测到'<‘的第一个实例,并打开输入缓冲区,但对于其他文本,这似乎不太可能。
发布于 2014-01-09 16:17:16
你可以在VIM中自定义行为,例如
let g:surround_42 = "**\r**"或基于文件,其中txt是文件类型
autocmd FileType txt let b:surround_42 = "**\r**"其中42是*的ASCII值。然后像往常一样用单个*更改周围的文本对象,它将被替换为**。
发布于 2014-01-09 16:29:06
在sorround帮助文件中:
A replacement argument is a single character, and is required by |cs|, |ys|,
and |vS|. Undefined replacement characters (with the exception of alphabetic
characters) default to placing themselves at the beginning and end of the
destination, which can be useful for characters like / and |.因此,实际上您只能在替换中使用单个字符。无论如何,surround是可以定制的,您可以采用另一个答案中提出的解决方案。
但是在这种情况下,为什么不使用一些普通的vim替换呢?
:s/'/**/g 然后,您可以使用@:在另一行上重复此更改
发布于 2014-01-10 00:10:47
如果你同时拥有surround.vim和repeat.vim,你可以这样做:
ysi'*
.
ds'那么它的作用是:
使用asterisks.
请注意,如果您没有处理插件映射等.的repeat.vim,这将不起作用。
https://stackoverflow.com/questions/21011866
复制相似问题