Unite.vim preview navigation

204 Views Asked by At

I'm using Vim with the Unite plugin. How to prevent jump to first line in unite preview, when cursor is in last position and key down J is pressed and otherwise jump from first line to last line, when key up K is pressed?

2

There are 2 best solutions below

2
On BEST ANSWER

Not too hard, given the Unite docs. Lines for your vimrc:

augroup my_unite
    autocmd!
    autocmd FileType unite call s:unite_my_settings()
augroup END

function! s:unite_my_settings()
    nmap <buffer><expr> j line('.') == line('$') ? '' : '<Plug>(unite_loop_cursor_down)'
    nmap <buffer><expr> k line('.') == 1 ? '' : '<Plug>(unite_loop_cursor_up)'
endfunction
1
On

You can find out if there is a mapping on your J by typing

:map j

If there is, and you do not like, you can unmap it by putting this into your vimrc

autocmd VimEnter * unmap j

It should do the trick (the same for the K).

There is also another way (:help after-directory) but I prefer this one.