ctrlp

Open all selected files as hidden buffer?


Is there a way Ctrl-P can open all selected files as hidden buffer? This is how I tried to load files into my buffer:

<c-p>               (opens Ctrl-P in file mode)
<c-o>               
a                   (marks all files in the match window)
i

The last "i" was intended to open the selected files as hidden buffers. Instead "i" appeared in the search dialog.

From :help CtrlP

Opening multiple files:

  <c-z>
    - Mark/unmark a file to be opened with <c-o>.
    - Mark/unmark a file to create a new file in its directory using <c-y>.

  <c-o>
    - Open files marked by <c-z>.
    - When no file has been marked by <c-z>, open a console dialog with the
      following options:

      Open the selected file:
        t - in a tab page.
        v - in a vertical split.
        h - in a horizontal split.
        r - in the current window.
        i - as a hidden buffer.
        x - (optional) with the function defined in |g:ctrlp_open_func|.

      Other options (not shown):
        a - mark all files in the match window.
        d - change CtrlP's local working directory to the selected file's
            directory and switch to find file mode.

Solution

  • Here is how to open all selected files as hidden buffer.

    Add this line to vimrc:

    let g:ctrlp_open_multiple_files = 'ij'
    

    where

    i - all files as hidden buffers.
    j - after opening, jump to the first opened tab or window.
    

    In Vim:

    <c-p>               open Ctrl-P in file mode
    <c-o>               open a console dialog
    a                   mark all files in the match window
    <c-z>               mark/unmark a file
    <c-o>               open marked files as hidden buffers