Search code examples
vimvim-pluginunite.vim

Unite.vim preview navigation


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?


Solution

  • 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