Проверьте это..
closetag.vim
Functions and mappings to close open HTML/XML tags
https://www.vim.org/scripts/script.php? script_id=13
я использую что-то подобное.
String.gsub должен помочь.
Цитирование документов:
gsub (шаблон, замена) → new_str
Возвращает копию str с ] все вхождения шаблона заменен на второй аргумент. Шаблон обычно представляет собой Regexp; если задано как String, любые метасимволы регулярного выражения содержит будет интерпретироваться буквально, например,
\\ d
будет соответствовать backlash followed byd
, instead of a digit.
I could explain why sub
just replaces the first match of a pattern, but I think the documentation does it so much better (from ri String#sub
on the command line):
str.sub(pattern, replacement) => new_str
str.sub(pattern) {|match| block } => new_str
Returns a copy of _str_ with the _first_ occurrence of _pattern_
replaced with either _replacement_ or the value of the block.