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 " Swap movement mappings that act on display lines with the real ones, making it
" easier to navigate long wrapped lines. " easier to navigate long wrapped lines.
noremap j gj function! MapWrapMovement()
noremap k gk if &wrap
noremap 0 g0 noremap j gj
noremap ^ g^ noremap k gk
noremap $ g$ noremap 0 g0
noremap gj j noremap ^ g^
noremap gk k noremap $ g$
noremap g0 0 noremap gj j
noremap g^ ^ noremap gk k
noremap g$ $ 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 " Convert Unix timestamp to human readable
" Mnemonic: "Unix timestamp convert" with pun to UTC " Mnemonic: "Unix timestamp convert" with pun to UTC