2

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?

Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
dkiyatkin
  • 614
  • 7
  • 11

2 Answers2

3

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
VanLaser
  • 1,144
  • 6
  • 8
1

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.

ryuichiro
  • 3,765
  • 1
  • 16
  • 21
  • Thx for answer, but this not help.. unite don't provide built-in command for key up/down without loop to start/end.. – dkiyatkin Sep 15 '15 at 16:29