我使用vim環繞,我試圖取代:在vim環繞周圍替換報價與字符串
'this text needs to be replaced'
與
**this text needs to be replaced**
我已經做了兩個YSS和CST (即):
:cst**
:yss**
兩者都只能捕捉到第一個*。
如何用字符串包圍文本?
HTML標籤顯然工作正常,我猜他們檢測'<'的第一個實例,並打開輸入緩衝區,但其他文本看起來並不像它的可能。
我使用vim環繞,我試圖取代:在vim環繞周圍替換報價與字符串
'this text needs to be replaced'
與
**this text needs to be replaced**
我已經做了兩個YSS和CST (即):
:cst**
:yss**
兩者都只能捕捉到第一個*。
如何用字符串包圍文本?
HTML標籤顯然工作正常,我猜他們檢測'<'的第一個實例,並打開輸入緩衝區,但其他文本看起來並不像它的可能。
您可以自定義VIM中的行爲,例如基於
let g:surround_42 = "**\r**"
或文件,其中txt
是文件類型
autocmd FileType txt let b:surround_42 = "**\r**"
凡42是用於*
一個ASCII值。然後像往常一樣改變包圍的文本對象,使用單個*
,它將被替換爲**
。
另一種寫法:'let g:surround_ {char2nr('*')} =「** \ r **」'。我發現這提高了可維護性。 –
從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
如果你有兩個surround.vim和repeat.vim然後可以重複另一條線路上這一變化與@:
,你可以這樣做:
ysi'*
.
ds'
所以它做什麼:
注意,如果你沒有repeat.vim
,它處理.
的插件地圖,這樣做這是行不通的。
您是否嘗試過環球的問題跟蹤器? – romainl