Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the video at Watch how i work rails he first obtains the output of find . -type f and uses this list as a regular vim file to search. Ones he finds this file in the list, he can open it in vim. This looks really useful but he does not specify the alias to do it. Can someone give me the alias for the same?

share|improve this question
up vote 2 down vote accepted

What's going on can be pieced together from the author's dotfiles. Warning! The whole thing is pretty convoluted (and smart).

  1. This is the vim- bash command:

    vim-() {
      vim -s <(printf '\eh')

    It opens Vim and simulates a key sequence, <Esc>h.

  2. <Esc>h is mapped to execute a custom command, :FPScratchy which in turn calls an external script, ack_find.

    nmap <ESC>h :FPScratchy "ack_find"<CR>
  3. The purpose of that command is to create a "scratch window" containing the file list generated by the external command and do some remappings for navigation: <CR> in normal mode to open the file under the cursor, <CR> in visual mode to add the selected files to the local arglist and <Esc><CR> in normal mode to open the file under the cursor in a split window.

    function! FPScratchy(...)
      call call(function("Scratchy"), a:000)
      setlocal cursorline
      nmap <buffer> <CR> 0gf
      vmap <buffer> <CR> :Lines2arglocal<CR>
      nmap <buffer> <ESC><CR> 0<c-w>f<c-w>w
    command -nargs=* FPScratchy :call FPScratchy(<args>)
    function! Lines2arglocal() range
      let lines = map(range(a:firstline, a:lastline), 'getline(v:val)')
      execute "arglocal " . join(lines, " ")
    command -range Lines2arglocal <line1>,<line2>:call Lines2arglocal()
  4. The author changed his find-based method to a slightly more involved ack-based one a few years ago. We have no means to know what he used daily but we can assume it was a simple:

    $ find . -type f
share|improve this answer

There are several ways to do that. To get the output of that command into a Vim buffer, open Vim and execute

:r!find . type f

Another way to do that, using vim in a terminal, would be to execute the following at the shell prompt.

$ find . type f | vim -

I usually put the cursor over the desired file name and type


where <C-W> means Ctrl-W. That will open the file in a new window, which avoids the problem of trying to open a new file in a modified buffer.

Another approach would be to first execute

:set nomodified

Then type


That will open the new file in the buffer/window that contained the list of files.

Still another way would be to again put the cursor over the desired file name and execute

:e! <C-R>f<CR>

where <C-R> means Ctrl-R and <CR> means the Enter key. The <C-R>f combination will expand to the file name under the cursor.


:help :r!
:help CTRL-W_f
:help gf
:help 'modified'
:help c_CTRL-R_f
share|improve this answer
Even before that how do i get the file list in vim? – woodstok Aug 21 '13 at 15:23
Probably with :r!find . type f. See :help :r!. I'll update the answer. – garyjohn Aug 21 '13 at 15:26
@MIkhail: If he starts from the command line and not from within an open Vim session, perhaps he is running find . -type f | vim -. This will grab STDIN and put it into the buffer. – Daniel Andersson Aug 21 '13 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .