Don't allow gj type mappings

Assuming a small screen and 'wrap' set:

The cursor is forced to stay in a certain column, so doing gj on a wrapped
line will jump into an area outside the position [x] and jump back into it
immediately effectively breaking navigation.

Solution: use local mappings that just do the usual h/j/k/l dance.

References #156.
This commit is contained in:
Marco Hinz 2015-04-22 11:11:41 +02:00
parent 3e143739d7
commit eccf570aea

View file

@ -134,20 +134,10 @@ function! startify#insane_in_the_membrane() abort
setlocal nomodifiable nomodified setlocal nomodifiable nomodified
nnoremap <buffer><silent> e :enew<cr> call s:set_mappings()
nnoremap <buffer><silent> i :enew <bar> startinsert<cr>
nnoremap <buffer><silent> <insert> :enew <bar> startinsert<cr>
nnoremap <buffer><silent> b :call <sid>set_mark('B')<cr>
nnoremap <buffer><silent> s :call <sid>set_mark('S')<cr>
nnoremap <buffer><silent> t :call <sid>set_mark('T')<cr>
nnoremap <buffer><silent> v :call <sid>set_mark('V')<cr>
nnoremap <buffer><silent> <cr> :call startify#open_buffers()<cr>
nnoremap <buffer><silent> <2-LeftMouse> :execute 'normal' matchstr(getline('.'), '\w\+')<cr>
nnoremap <buffer><silent> q :call <sid>close()<cr>
call cursor(s:firstline + (s:show_special ? 2 : 0), 5) call cursor(s:firstline + (s:show_special ? 2 : 0), 5)
autocmd startify CursorMoved <buffer> call s:set_cursor() autocmd startify CursorMoved <buffer> call s:set_cursor()
set filetype=startify set filetype=startify
silent! doautocmd <nomodeline> User Startified silent! doautocmd <nomodeline> User Startified
endfunction endfunction
@ -556,6 +546,35 @@ function! s:set_cursor() abort
call cursor(s:newline, 5) call cursor(s:newline, 5)
endfunction endfunction
" Function: s:set_mappings {{{1
function! s:set_mappings() abort
nnoremap <buffer><silent> e :enew<cr>
nnoremap <buffer><silent> i :enew <bar> startinsert<cr>
nnoremap <buffer><silent> <insert> :enew <bar> startinsert<cr>
nnoremap <buffer><silent> b :call <sid>set_mark('B')<cr>
nnoremap <buffer><silent> s :call <sid>set_mark('S')<cr>
nnoremap <buffer><silent> t :call <sid>set_mark('T')<cr>
nnoremap <buffer><silent> v :call <sid>set_mark('V')<cr>
nnoremap <buffer><silent> <cr> :call startify#open_buffers()<cr>
nnoremap <buffer><silent> <2-LeftMouse> :execute 'normal' matchstr(getline('.'), '\w\+')<cr>
nnoremap <buffer><silent> q :call <sid>close()<cr>
" Prevent 'nnoremap j gj' mappings, since they would break navigation.
" (One can't leave the [x].)
if !empty(mapcheck('h', 'n'))
nnoremap <buffer> h h
endif
if !empty(mapcheck('j', 'n'))
nnoremap <buffer> j j
endif
if !empty(mapcheck('k', 'n'))
nnoremap <buffer> k k
endif
if !empty(mapcheck('l', 'n'))
nnoremap <buffer> l l
endif
endfunction
" Function: s:set_mark {{{1 " Function: s:set_mark {{{1
" "
" Markers are saved in the s:marked dict using the follow format: " Markers are saved in the s:marked dict using the follow format: