views:

249

answers:

2

So I do a lot of shell scripts and I am constantly having to enter in paths and I was wondering if anyone knew of a way to get vim to autocomplete paths and files while in insert mode. Just like when you are in your favorite shell you tab to complete the directory or file.

Extra credit if you can get CTRL-D functionality of the shell into vim insert mode (Ie. to see what files/directories are in the current path).

+4  A: 

Theres ctrl-x ctrl-f

:he compl-filename

michael
+3  A: 

For file name omni completion, you can use:

Ctrl-XCtrk-F

CMS
Another vim aha moment.... Thanks. I dont use tab in insert mode anyway so added this to my .vimrc: imap <Tab> <C-X><C-F>
stephenmm
Another good use for <tab> in insert mode is <c-n>. This will autocomplete the word you're typing based on other words in the file your working on. I use it all the time when typing variable or class names.
Derek