]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
Manpager: apply g flag conditionally to s command (#12679)
authorFilip Gospodinov <f@gospodinov.ch>
Wed, 9 Aug 2023 16:00:36 +0000 (18:00 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2023 16:00:36 +0000 (18:00 +0200)
Problem: The `s` command with `g` flag only substitutes
         one occurrence when `gdefault` is set.
Solution: Use `g` flag conditionally.

runtime/plugin/manpager.vim

index 1738dc9439bce477f0f8bec1c8a358fdcc82df80..076aca5f8302977cfbcbad27f9d177cd11885baf 100644 (file)
@@ -30,10 +30,10 @@ function s:ManPager()
   setlocal modifiable
 
   " Emulate 'col -b'
-  silent! keepj keepp %s/\v(.)\b\ze\1?//ge
+  exe 'silent! keepj keepp %s/\v(.)\b\ze\1?//e' .. (&gdefault ? '' : 'g')
 
   " Remove ansi sequences
-  silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge
+  exe 'silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//e' .. (&gdefault ? '' : 'g')
 
   " Remove empty lines above the header
   call cursor(1, 1)