Traversing directories with vim file name completion in insert mode (Ctrl-X Ctrl-F)

孤者浪人 提交于 2019-12-07 00:22:59

问题


I’m trying to use vim’s compl-filename feature (Ctrl-XCtrl-F) to complete paths in INSERT mode, but I can’t work out how to traverse into directories without (temporarily) ending the completion mode:

Let’s say I want to complete the path /etc/sysconfig/network-scripts/ifup.

I would like to be able to do something like:

/eCtrl-XCtrl-F
/etc/
/etc/sysCtrl-F
/etc/sysconfig/
/etc/sysconfig/netCtrl-F
/etc/sysconfig/netconsoleCtrl-N
/etc/sysconfig/networkCtrl-N
/etc/sysconfig/network-scripts/
/etc/sysconfig/network-scripts/ifupCtrl-Y
/etc/sysconfig/network-scripts/ifup

The issue is, as soon as I start typing* after a path match (like /etc/), it ends file name completion. I would like it to stay in file name completion, so that I can still use Ctrl-F, Ctrl-N, etc. Since it ends completion, I have to type Ctrl-XCtrl-F again to restart it, and the helpful completion popup menu disappears in the meantime.

Is there an option I can set to change this?

* By ‘typing’ here, I am referring to characters in 'isfname' -- of course, typing other characters (like space or punctuation) should not continue file name completion.


回答1:


I'm not sure exactly what you're saying, but you can just press Ctrl-XCtrl-F again on a directory while you're in the completion menu to expand it. You don't have to close out of the menu first. I just keep Ctrl held down and tap xf to traverse a directory, n and p to move up and down and w to go back up.

If you don't use :h i_CTRL-F then you could remap it. For example,

inoremap <C-f> <C-x><C-f>



回答2:


Vim doesn't do auto-completion.

For that, you'll need a dedicated plugin like AutoComplPop or NeoComplCache




回答3:


Please use insert "i" first before using cntr+x+f. I was in similar situation. :)



来源:https://stackoverflow.com/questions/13327285/traversing-directories-with-vim-file-name-completion-in-insert-mode-ctrl-x-ctrl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!