3

To open a file in vim, I usually type ":e " and then hit tab until the file I want appears.

However, I always get in a rhythm and inadvertently go ONE past the desired file. Without knowing how to move backwards, I end up tabbing all the way to the end and repeating the whole process.

Is there a way to perform the filename completion in reverse order?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user85509
  • 36,612
  • 7
  • 33
  • 26

3 Answers3

8

Shift-Tab goes backwards.

You can also use set wildmenu to get a list of matching file names above the status bar when you do file name completition with Tab. Then you can select the file name with the arrow keys from this list.

sth
  • 222,467
  • 53
  • 283
  • 367
  • That does not work on my setup: Ubuntu with the standard vim package (Vim 7.1.314) and a basically empty .vimrc. Shift-Tab moves in the same direction as Tab. – user85509 Apr 01 '09 at 06:30
  • I tested it on debian (over ssh using putty), and there it works. I couldn't find any special setting in the config files that explicitly enables this. My guess would be it depends on the terminal if Shift-Tab is sent correctly to the application... – sth Apr 01 '09 at 07:38
  • It works fine on Mac OS X (Vim, not gvim, or MacVim) in the terminal. – George V. Reilly Apr 01 '09 at 07:42
1

Shift+Tab and Ctrl+P both go backward.

However Shift+Tab only works with the GUI [1]. Since I am using vim and not gvim, Shift+Tab would not work. Ctrl+P works perfectly.

[1] And on the Amiga and MS-DOS. See ":help cmdline-completion" for more info.

Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
user85509
  • 36,612
  • 7
  • 33
  • 26
0

If you got here because your vim autocompletion starts with the last item when you use "Tab", cycles backward from there AND you're using the Supertab plugin, here is your solution: https://stackoverflow.com/a/17105393/332451

let g:SuperTabDefaultCompletionType = "<c-n>"
exic
  • 2,220
  • 1
  • 22
  • 29