vim:keys: Map display movements only when wrapping

This commit is contained in:
2022-12-27 04:24:21 +01:00
parent 92589d5423
commit 46ec34826e

View File

@@ -200,16 +200,35 @@ nmap Q gqap
" Swap movement mappings that act on display lines with the real ones, making it
" easier to navigate long wrapped lines.
noremap j gj
noremap k gk
noremap 0 g0
noremap ^ g^
noremap $ g$
noremap gj j
noremap gk k
noremap g0 0
noremap g^ ^
noremap g$ $
function! MapWrapMovement()
if &wrap
noremap j gj
noremap k gk
noremap 0 g0
noremap ^ g^
noremap $ g$
noremap gj j
noremap gk k
noremap g0 0
noremap g^ ^
noremap g$ $
else
noremap j j
noremap k k
noremap 0 0
noremap ^ ^
noremap $ $
noremap gj gj
noremap gk gk
noremap g0 g0
noremap g^ g^
noremap g$ g$
endif
endfunction
augroup WrapMovementMappings
au!
au OptionSet wrap call MapWrapMovement()
augroup END
" Convert Unix timestamp to human readable
" Mnemonic: "Unix timestamp convert" with pun to UTC