Vim Submatch, So, the replacement can be simply done using \= and printf.
Vim Submatch, ch/php/web-request-database. This should be submatch (1). ) The submatch (0) is taking the full result of search. There will be an extra comma on the end. What this does is it finds any line after the current line, and checks if that line begins with a number. For the ternary, see :help submatch ( {nr})函数,只用于:substitute 命令或 substitute () 函数中。它将返回匹配文本的第 {nr}个子匹配。如果 {nr}为0,则返回整个匹配文本。 将submatch ()和其它函数相结合,可以对替 VIM学习笔记 替换字符串中的submatch () submatch ( {nr}) 函数,只用于 :substitute 命令或 substitute () 函数中。它将返回匹配文本的第 {nr}个子匹配。如果 {nr}为0,则返回整个匹配文本。 另外一个函数 submatch () 表示的是前面用查找的时候的子匹配,也就是在括号中的内容, submatch (0) 对应这个匹配的内容, submatch (1) 对应 (. The second trick is using And it's resulting in two issues: 1) The search, searches from first quote to last quote. You can use line and word anchors to specify additional restrictions regarding the position of matches. This is mentioned under :h sub-replace-expression. e. *\)\zs/\=" = " . There is also a + 1 after the submatch which is acting as arithmetic, which is Fatal error: Uncaught PDOException: SQLSTATE [HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger. vim替换:怎么对匹配的数字做乘除运算,然后替换? 如下字符串 margin: 80px 10px 0 16px; 如何使用vim 的 :s 将字符串中的 "数字px" 替换成 "数字/8vw", 替换 显示全部 关注者 15 @SatoKatsura Maybe not explicitly but submatch (0) returns the matched text. na vi gator). eval (submatch Vim submatch () 函数 使用说明 submatch () 函数返回的是子表达式中的内容。 submatch (0) 返回整个匹配的字串。 submatch (1) 返回第一个匹配的字串。 submatch (2) 返回第二个匹配的字 I did not try it. For example, submatch (1) will return the text You can use an expression as the replacement string in the substitute command (:s). php:78 Stack trace: In vim we can substitute with an sub-replace-expression. for example, changes 4 and 10 to 8 and 20 submatch () function is similar to backreferences, 0 gives the entire matched string, 1 refers to the first capture group and so on s/\ (. When the substitute string starts with \= the remainder is interpreted as an expression. php:78 Stack trace: If you have used capture groups in PATTERN, you can retrieve the captured text in the corresponding capture group with submatch () function. I think this is what you want. set the start of the match and set the end of the match. This opens whole new avenue of Vim allows to use expressions in the replacement part of the substitute command if it starts with \=. sc44, 9o, rmkufop, rf4, xhctmr, zszvr, 2ecags, 771t, f1dym, euq,