

Getting CMD-T in vim "for free" - eof
http://gd0t.com/node/11

======
jcr
If you always want tab completion to work, just turn it on.

    
    
      " Command/TAB Completion
      "set wildchar=<number>	   " Character typed to start wildcard expansion
      set wildmenu
      set wildmode=longest,list,full   " use ksh/tcsh autolist TAB completion
    

EDIT: removed my stupid condescending remark about knowing how to configure
vim. sorry.

~~~
eof
I wrote that article, and it is true I don't know anything about configuring
vim that I didn't learn by wanting it to do something it wasn't doing.

However, I am not sure

    
    
      :e **/

does what you are talking about.

Tab completion has always worked for me "out of the box" (though without that
wildmenu which is cool); but only in one directory at a time.

This allows me to open vim in /home/eof and type

    
    
      :e **/foo<tab>
    

and tab between

    
    
      /home/eof/somefolder/deeper/food.gif

and

    
    
      /home/eof/something/very/deep/foolsinlove.mp3
    

This is really useful, obviously, if you are jumping around a larger project.

~~~
jcr
I really should have phrased that a bit more politely. Sorry.

The cool part about learning to configure vim is by doing so, you are actually
learning to both _USE_ and enhance vim. It is definitely worth the effort.

My all time favorite "configuration" of vim is automatically reloading
~/.vimrc on save.

    
    
      " auto-reload vimrc on save changes
      au! BufWritePost .vimrc source %
    

With the above, you do have to be a bit careful though, since if you define
something save/reload, then delete said definition line and save/reload again,
it is still defined.

For me, and obviously many others, it is important for tab completion to be
consistent between my editor and my shell. In my case using ksh for my shell,
the above settings make tab completion in vim behave just like it does in my
shell.

If ``:e __/foo'' is used in a shallow and lightly filled subdirectory, like
for some project dir, it's more usable and useful. On the other hand, if you
have tons of stuff in your current (home) directory, it takes far too long. If
you're not really specific with your search term, you'll get the "E77: Too
many file names" error.

Though often wishful thinking, I prefer to remember where the hell I put the
damn files. ;)

~~~
eof
Ah; I am using bash. I'll take a deeper look at ksh.

It's really fine, I don't know how to configure vim. To be fair, there are a
lot of options and you can get a long way just figuring out easy ways to do
things you do all the time; while never really bothering to study it in depth.

All that being said, I downloaded and ran ksh; and I don't think what you've
said is capturing the functionality of

    
    
      :e **/
    

It's not usually a matter of 'remembering' where I put my files; it's being in
/modules/module_dir/specific_module/module.file and needing to edit
/views/view_name/js/some_shit.js

,esome_s<tab> is a nice way of jumping to that file

~~~
jcr
I've never really learned bash, so I'm more than a bit ignorant there. On the
other hand, tab completion in ksh is very useful. The first time you hit tab,
it completes, but if you hit tab a second time, it gives you a nice list of
options for completion (i.e. directory listing with matching if provided). It
does not do the kind of find(1) type search that ``e: __/'' will do, but if
you have a vague idea where something is located, what it is called and don't
want to type out everything, the ksh-style tab completion (one or two taps) is
very useful and often much faster than than a depth search.

~~~
eof
ah. I see now you typed

    
    
      :e **/
    

but it came out without the stars because of formatting.

------
tm65atcolumbia
This is cool. But often I wish there is a shortcut to open a bunch of files
using wildcard characters, e.g :e <dir>/*.rb.

~~~
jcr
You can! just use this:

    
    
      :args *.rb
    

Sadly, the above is easy to forget if you don't use it a lot but such is life
for everything in a powerful text editor.

Now here's the fun part. The above will open each of the files in a new
buffer. You might want each buffer to be put into it's own tab, so just add
the following to your ~/.vimrc to map CTR-ALT-T to create a new tab for each
of the existing buffers.

    
    
      " open each buffer in it's own tab
      map  <C-M-T>  :tab sball<CR>
    

If the vim default CTRL-t drives you nuts because you use a web browser far
too often, you can remap it in vim to create a new tab. I've got mine set as
follows so it not only makes CTRL-t create a new tab, but it also puts your
focus in the vim command and fills in the ":e " so you can open a new file:

    
    
      " Open New Tab
      map  <C-T>  :tabnew<CR>:e 
    

Yes, this last bit is due to the personal annoyance of hitting CTRL-t and
mistakenly expecting a new tab to appear when vim doesn't work that way by
default.

