Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In a directory I type vi and then tab (twice), this gives me

user$ vi 
CMakeFiles/ global/     libs/

whereas ls followed by 2 tabs gives me

user$ ls 
! core.log CMakeFiles/ global/     libs/ _jni/

(Note: ls is aliased to `ls -Ah --color=auto', _jni is a symlink, and none of the files are hidden.)

I think vi is not showing any files, but only directories during tab-completion. Why is this happening? How to make vi behave same way as ls? I put following line in ~/.vimrc after going through one of the posts on SE. But it doesn't seem to do anything in this case.

set wildmode=longest,list,full
set wildmenu

Version of vi: VIM - Vi IMproved version 7.3.429
Version of ls: ls (GNU coreutils) 8.13

share|improve this question

3 Answers 3

up vote 3 down vote accepted

I had the same problem on Arch Linux, and finally I found that was the completion function's problem.

use complete -r vim to remove the completer. (or put that line to your bashrc)

share|improve this answer
    
Thanks! complete -r vi did it for me. –  user13107 Oct 30 '12 at 4:20

This behavior is not directly related to the ls command or the vi binary. It is, instead, controlled by the tab completion function of your shell. If you're using bash on linux, you've probably got /etc/bash_completion and /etc/bash_completion.d/* full of rules for how to implement completion.

share|improve this answer
    
Thanks. Does this mean I should ideally put the line complete -r vi in /etc/bash_completion? Also what does -r (or other options) mean. Both man complete and complete --help don't seem to tell this. –  user13107 Oct 30 '12 at 4:26
    
@user13107 bash builtins are hard to find good documentation for. What you probably want to do is get rid of /etc/bash_completion.d/vi or some file similar to that –  Sparr Oct 30 '12 at 4:58
    
@user13107 Since complete is a bash built-in, use help complete or search for it in the SHELL BUILTIN COMMANDS section in man bash. The latter one is usually more detailed. –  Dubu Jul 2 at 8:46

Check that line similar to below is present in your file /etc/bash_completion:

complete -f -X '*.@(o|so|so.!(conf)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite

Execute this command on shell. Alternatively add above line in the file /etc/bash_completion and execute:

bash /etc/bash_completion
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.