vim path auto completion, how do I enter a directory?
When I want to open a file in vim, I enter :e to see directories on my disk (set wildmenu). Vim shows me list of directories I have, then I press tab several times to choose directory I need, and when I select that directory (vim highlights it) what should I do to stop completion on current level and enter that directory?
I know that in insert mode completion it's ctrl-y, from vim help file:
*complete_CTRL-Y*
When the popup menu is displayed you can use CTRL-Y to stop completion and
accept the currently selected entry. The CTRL-Y is not inserted. Typing a
space, Enter, or some other unprintable character will leave completion mode
and insert that typed character."
how to do that in command mode?
I think its Ctrl E in command mode
From vim docs,
*complete_CTRL-E*
When completion is active you can use CTRL-E to stop it and go back to the originally typed text. The CTRL-E will not be inserted.
I tried this in my gVim and it works.
EDIT : Thanks to the suggestion by @François, Ctrl D does the same thing with some additional info. ie it stops completion in the current level and also shows the contents of the current selection
Something like
:e eclipse-cpp-indigo-SR2-incubation-win32-x86_64eclipse <Ctrl><D>
artifacts.xml eclipse.exe epl-v10.html p2
configuration eclipse.ini features plugins
dropins eclipsec.exe notice.html readme
It is showing the contents inside the folder eclipse
too apart from stopping completion at the eclipse directory level.
When you reach the required directory pressing the tab key, press the right arrow key (or type a character and erase it). After that completion use the directory as the base one and iterates through its subdirectories.
For example, you have the following file structure in the current directory:
- a - b - c - d
You type the e command and press the tab key. The first suggested directory is a. Press the tab key again to select the next directory - b. And now press the right arrow key. After that the b directory is selected and completion starts inside it.
As I said before you may type a character and erase it. If you leave a character (or a sequence of characters, eg prefix) it is used as a filter (selects only those directories whose name starts from the prefix).
I think there are other solutions. But the two above is fully enough for me.
One more option: when I want to select and continue, I just enter another "/" and continue tabbing. Looks a little ugly in my status line, but it's one keystroke and I don't have to leave my home row.
链接地址: http://www.djcxy.com/p/37636.html上一篇: Vim插入模式文件路径完成
下一篇: vim路径自动完成,如何进入目录?