Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate results (candidates) in Unite.vim?

Tags:

vim

unite.vim

After a search in unite.vim, you open a candidate. Is there an easy way to jump to the next one without having to run the search command again? Similar plugins (ack.vim, git-grep) use the quickfix window, so you can type :cn and :cp to jump to next/previous results. Is there anything similar in unite.vim?

Thanks!

like image 969
MetalElf0 Avatar asked Feb 19 '14 10:02

MetalElf0


2 Answers

I haven't managed to find a way to put results into the quickfix or location lists, though I'm sure you could extend Unite to include that action.

Meanwhile, this little exerpt from the Unite documentation can help you re-open the Unite buffer you just recently had open:

:UniteResume [{options}] [{buffer-name}]    *:UniteResume*
        Reuses the unite buffer named {buffer-name} that you opened
        previously.  Narrowing texts or candidates are
        as-is.  If {options} are given, context information gets
        overridden.

        Note: Reuses the last unite buffer you used in current tab if
        you skip specifying {buffer-name}.

I use this in the following way in my vimrc:

 " Press <leader>ll to re-open last Unite buffer
 nnoremap <silent><leader>ll :<C-u>UniteResume<CR>

Another useful snippet from the docs:

    -no-quit
    Doesn't close unite buffer after firing an action.  Unless you
    specify it, a unite buffer gets closed when you selected an
    action which is "is_quit".

    -keep-focus
    Keep the focus on a unite buffer after firing an action.
    Note: This option is used with "-no-quit" option.

For example, you could bind

nnoremap <silent><leader>lg :<C-u>Unite -no-quit -keep-focus grep<CR>

To be able to press <leader>lg to grep through your source files, without closing or de-focusing the Unite buffer when you select an item.

like image 123
OliverUv Avatar answered Nov 05 '22 02:11

OliverUv


Good news, everyone! I created an issue-724 with your request in Unite repo and it has been implemented in the blink of an eye! Glory to Shougo!

From the docs:

:UniteNext [{buffer-name}] *:UniteNext*
 Do the default action with next candidates in the unite buffer
 with {buffer-name}.
 You can use it like |:cnext|.

:UnitePrevious [{buffer-name}] *:UnitePrevious*
 Do the default action with previous candidates in the unite
 buffer with {buffer-name}.
 You can use it like |:cprevious|.
like image 6
baltazar Avatar answered Nov 05 '22 02:11

baltazar