From fd73556a456cd0761726dbe458b5f50d4538d936 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Tue, 12 Mar 2024 19:05:03 +0900 Subject: [PATCH 1/2] Escape surrounding pattern --- plugin/commentary.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/commentary.vim b/plugin/commentary.vim index 5370106..250a22b 100644 --- a/plugin/commentary.vim +++ b/plugin/commentary.vim @@ -60,7 +60,7 @@ function! s:go(...) abort \'\=substitute(submatch(0)+1-uncomment,"^0$\\|^-\\d*$","","")','g') endif if force_uncomment - if line =~ '^\s*' . l + if line =~ '\v\C^\s*' . escape(l, '!#$%&()*+,-./:;<=>?@[\]^{|}~') let line = substitute(line,'\S.*\s\@ Date: Tue, 12 Mar 2024 19:16:32 +0900 Subject: [PATCH 2/2] Don't apply nesting tranform for :Commentary! --- plugin/commentary.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/commentary.vim b/plugin/commentary.vim index 250a22b..8bdae4a 100644 --- a/plugin/commentary.vim +++ b/plugin/commentary.vim @@ -54,7 +54,7 @@ function! s:go(...) abort let lines = [] for lnum in range(lnum1,lnum2) let line = getline(lnum) - if strlen(r) > 2 && l.r !~# '\\' + if strlen(r) > 2 && l.r !~# '\\' && !force_uncomment let line = substitute(line, \'\M' . substitute(l, '\ze\S\s*$', '\\zs\\d\\*\\ze', '') . '\|' . substitute(r, '\S\zs', '\\zs\\d\\*\\ze', ''), \'\=substitute(submatch(0)+1-uncomment,"^0$\\|^-\\d*$","","")','g')