changeset 34367:9ddc74d06433

runtime(less): reset readonly setting when disabling less mode Commit: https://github.com/vim/vim/commit/103f1dfb7df350650a5d7caadb0364bd79e9d25b Author: Christian Brabandt <cb@256bit.org> Date: Thu Feb 15 21:44:05 2024 +0100 runtime(less): reset readonly setting when disabling less mode While at it, also do the unmap only if a specific key has been mapped. There are some keys that are only selectively mapped and it would cause an error if we are trying to unmap such a key (e.g. z when your foldmethod is not manual). fixes: #14040 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 15 Feb 2024 22:00:02 +0100
parents 1f5f3d58ed28
children a3236a7ac392
files runtime/macros/less.vim
diffstat 1 files changed, 172 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/macros/less.vim
+++ b/runtime/macros/less.vim
@@ -227,67 +227,181 @@ noremap q :q<CR>
 " Switch to editing (switch off less mode)
 map v :silent call <SID>End()<CR>
 fun! s:End()
-  set ma
+  set modifiable noreadonly
   if exists('s:lz')
     let &lz = s:lz
   endif
-  unmap h
-  unmap H
-  unmap <Space>
-  unmap <C-V>
-  unmap f
-  unmap <C-F>
-  unmap z
-  unmap <Esc><Space>
-  unmap F
-  unmap d
-  unmap <C-D>
-  unmap <CR>
-  unmap <C-N>
-  unmap e
-  unmap <C-E>
-  unmap j
-  unmap <C-J>
-  unmap b
-  unmap <C-B>
-  unmap w
-  unmap <Esc>v
-  unmap u
-  unmap <C-U>
-  unmap k
-  unmap y
-  unmap <C-Y>
-  unmap <C-P>
-  unmap <C-K>
-  unmap r
-  unmap <C-R>
-  unmap R
-  unmap g
-  unmap <
-  unmap <Esc><
-  unmap G
-  unmap >
-  unmap <Esc>>
-  unmap %
-  unmap p
-  unmap n
-  unmap N
-  unmap q
-  unmap v
-  unmap /
-  unmap ?
-  unmap <Up>
-  unmap <Down>
-  unmap <PageDown>
-  unmap <kPageDown>
-  unmap <PageUp>
-  unmap <kPageUp>
-  unmap <S-Down>
-  unmap <S-Up>
-  unmap <Home>
-  unmap <kHome>
-  unmap <End>
-  unmap <kEnd>
+  if !empty(maparg('h'))
+    unmap h
+  endif
+  if !empty(maparg('H'))
+    unmap H
+  endif
+  if !empty(maparg('<Space>'))
+    unmap <Space>
+  endif
+  if !empty(maparg('<C-V>'))
+    unmap <C-V>
+  endif
+  if !empty(maparg('f'))
+    unmap f
+  endif
+  if !empty(maparg('<C-F>'))
+    unmap <C-F>
+  endif
+  if !empty(maparg('z'))
+    unmap z
+  endif
+  if !empty(maparg('<Esc><Space>'))
+    unmap <Esc><Space>
+  endif
+  if !empty(maparg('F'))
+    unmap F
+  endif
+  if !empty(maparg('d'))
+    unmap d
+  endif
+  if !empty(maparg('<C-D>'))
+    unmap <C-D>
+  endif
+  if !empty(maparg('<CR>'))
+    unmap <CR>
+  endif
+  if !empty(maparg('<C-N>'))
+    unmap <C-N>
+  endif
+  if !empty(maparg('e'))
+    unmap e
+  endif
+  if !empty(maparg('<C-E>'))
+    unmap <C-E>
+  endif
+  if !empty(maparg('j'))
+    unmap j
+  endif
+  if !empty(maparg('<C-J>'))
+    unmap <C-J>
+  endif
+  if !empty(maparg('b'))
+    unmap b
+  endif
+  if !empty(maparg('<C-B>'))
+    unmap <C-B>
+  endif
+  if !empty(maparg('w'))
+    unmap w
+  endif
+  if !empty(maparg('<Esc>v'))
+    unmap <Esc>v
+  endif
+  if !empty(maparg('u'))
+    unmap u
+  endif
+  if !empty(maparg('<C-U>'))
+    unmap <C-U>
+  endif
+  if !empty(maparg('k'))
+    unmap k
+  endif
+  if !empty(maparg('y'))
+    unmap y
+  endif
+  if !empty(maparg('<C-Y>'))
+    unmap <C-Y>
+  endif
+  if !empty(maparg('<C-P>'))
+    unmap <C-P>
+  endif
+  if !empty(maparg('<C-K>'))
+    unmap <C-K>
+  endif
+  if !empty(maparg('r'))
+    unmap r
+  endif
+  if !empty(maparg('<C-R>'))
+    unmap <C-R>
+  endif
+  if !empty(maparg('R'))
+    unmap R
+  endif
+  if !empty(maparg('g'))
+    unmap g
+  endif
+  if !empty(maparg('<'))
+    unmap <
+  endif
+  if !empty(maparg('<Esc><'))
+    unmap <Esc><
+  endif
+  if !empty(maparg('G'))
+    unmap G
+  endif
+  if !empty(maparg('>'))
+    unmap >
+  endif
+  if !empty(maparg('<Esc>>'))
+    unmap <Esc>>
+  endif
+  if !empty(maparg('%'))
+    unmap %
+  endif
+  if !empty(maparg('p'))
+    unmap p
+  endif
+  if !empty(maparg('n'))
+    unmap n
+  endif
+  if !empty(maparg('N'))
+    unmap N
+  endif
+  if !empty(maparg('q'))
+    unmap q
+  endif
+  if !empty(maparg('v'))
+    unmap v
+  endif
+  if !empty(maparg('/'))
+    unmap /
+  endif
+  if !empty(maparg('?'))
+    unmap ?
+  endif
+  if !empty(maparg('<Up>'))
+    unmap <Up>
+  endif
+  if !empty(maparg('<Down>'))
+    unmap <Down>
+  endif
+  if !empty(maparg('<PageDown>'))
+    unmap <PageDown>
+  endif
+  if !empty(maparg('<kPageDown>'))
+    unmap <kPageDown>
+  endif
+  if !empty(maparg('<PageUp>'))
+    unmap <PageUp>
+  endif
+  if !empty(maparg('<kPageUp>'))
+    unmap <kPageUp>
+  endif
+  if !empty(maparg('<S-Down>'))
+    unmap <S-Down>
+  endif
+  if !empty(maparg('<S-Up>'))
+    unmap <S-Up>
+  endif
+  if !empty(maparg('<Home>'))
+    unmap <Home>
+  endif
+  if !empty(maparg('<kHome>'))
+    unmap <kHome>
+  endif
+  if !empty(maparg('<End>'))
+    unmap <End>
+  endif
+  if !empty(maparg('<kEnd>'))
+    unmap <kEnd>
+  endif
 endfun
 
 " vim: sw=2